How to unit test Hibernate DAO’s with H2 and Spring

May 12, 2014 Comments off

Source can be downloaded from link;

Writing Unit test cases are very common these days.We can write a Unit test for the functionality with Mocking.I personally feel we should not do Mocking while testing DAO.I prefer to write test cases for the DAO’s by pointing to the Database itself.Here the problem is we cannot execute tests on the production or development database since it will spoil the existing data, because we can build the same project any number of time, especially when we configure continues integration.

In memory databases or file based database comes in handy in this particular situation.There are lot many databases available of this kind like h2, HSQLDB e.t.c.

Here below i have extended a sample created in the below post and have written unit test with h2 database.

Link :

Project Structure



Create a test class with the similar package structure as source class in src/test/java


Sample Insert.sql below.


Sample delete.sql below


Now the main part come into the picture.applicationcontext.xml

We need to configure the h2 database data source as per below.


and the Session Factory as per below.


and we have to add spring-test dependency to the pom file.


Categories: H2, Hibernate, Java, Maven, Spring Tags:

Performance optimizations for Apache Camel

April 16, 2014 Comments off
Categories: Apache Camel, Java Tags:

Integrating WebDav enabled server to a java applications

February 23, 2014 Comments off

HI Guys, this time my task is to integrate a WebDav enabled server to my java application.First of all, what is WevDav, sound completely new? with a quick google search I landed on this link.

Web Distributed Authoring and Versioning (WebDAV) is an extension of the Hypertext Transfer Protocol (HTTP) that facilitates collaboration between users in editing and managing documents and files stored on World Wide Web servers.

I am not going much into details about the WevDav.But it’s a really cool standard for collaboration over Http.

By implementing WebDAV we can make our web server/application server to behave like a cloud storage.

Link for converting tomcat to a WebDav Server

similar way we can convert Apache HTTP server as a WebDAV server.

The browser is the best client to navigate through the webdav server.but it you want to integrate with your java application, Home :there are quite a few apis available like Sardine, Jackrabbit e.t.c.After a long research i found Saradine in is the most easiest api to i continued with saradine.

Note : Disadvantage of Saradine is most of the security protocols are implemented,but i faced few problems with NTML i am testing it,will post the results once it is completed.

Below are the few useful links for using sardine.


working with saradine is straightforward.check out the code and have a look at its test.

Restrictions : 

Sardine validates https certificates very strictly.if you want to ignore the certificated u have to implement your own httpclient object and pass it to the SaradineImpl class and construct.

please leave a post if any one needs some help while implementing this.

Categories: Cloud, General, Java, Storage Tags: ,

Integrating Ubuntu One drive to a java Application.

January 6, 2014 Comments off

HI Guys,I have been working for a while on integrating Ubuntu One cloud storage  and i would like to share my experiences here.

First of all What is Ubuntu One ? Ubuntu One is a cloud space provided by ubuntu, like dropbox,google drive e.t.c.The advantage Ubuntu One gives

  • Gives you 5Gb of free space,to store any thing whatever you would like.
  • All latest versions of Ubunutu distributions comes with Ubuntu One not need to install any extra clients.
  • It has provided a rich set of apis for application integration as REST services.
  • Web client,where you can view,download and upload files without installing any of the client.

Now the pain points :

  • even though Ubuntu One has provided apis with documentation,its really hard to find out quick samples for,after a long struggle i have found out few projects in the Ubuntu Code Space.

Ubuntu One uses OAuth 1.0 authentication while communicating with their apis.

Below are the Useful Links.

Ubuntu One api Documentation :

Ubuntu One java api :

Ubuntu One java api source :

You can download the code,modify and use it.

Note : Check the license,before you redistribute this.

I will post few examples and sample projects in my next posts.

Good Links

June 30, 2013 Comments off

Interview Preparation

Data Structures and Algorithms

Sample Questions:

Linked List:

Quick Sort:

Bubble Sort:

All Sorts:


Java Threads and Concurrency

Java Collections


Hibernate Exception – No CurrentSessionContext configured

June 30, 2013 Comments off

Java – Response was of unexpected text/html ContentType. Incoming portion of HTML stream: (none)

June 30, 2013 Comments off

Exception : Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: (none)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(
at $Proxy701.processThirdPartyRequest(Unknown Source)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(
at org.springframework.jms.listener.DefaultMessageListenerContainer$
Caused by: org.apache.cxf.interceptor.Fault: Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: (none)
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
at org.apache.cxf.endpoint.ClientImpl.onMessage(
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
at org.apache.cxf.transport.AbstractConduit.close(
at org.apache.cxf.transport.http.HTTPConduit.close(
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
at org.apache.cxf.endpoint.ClientImpl.doInvoke(
at org.apache.cxf.endpoint.ClientImpl.invoke(
at org.apache.cxf.endpoint.ClientImpl.invoke(
at org.apache.cxf.endpoint.ClientImpl.invoke(
at org.apache.cxf.frontend.ClientProxy.invokeSync(
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(
… 13 more


Check the WSDL URL.

URL has to be given till ?wsdl

%d bloggers like this: