i am using datasource in weblogic server and, using the datasource in Hibernate.
With HibernateUtil class am getting the SessionFactory, now i want write test cases for my DAO layer by using JUnit.
- How to get the SessionFactory in my Test class.
- I am able to get the datasource by jndi lookup in setUp method in my Test Class
is there any better way of writing test classes in this environment?
You can get the datasource JNDI, using javax.naming.InitialContext. But I think wouldn’t be a good idea make the test dependent on container (weblogic).
I had only 2 ideas:
Loading this test-file-configuration can be done using reflection or a mock.