[jboss-user] [JBoss Tools (users)] - injection in tests ?

berkay do-not-reply at jboss.com
Thu Dec 27 13:17:33 EST 2007


Hi. 
Want to test my action classes with hibernateSession instead of EntityManager and my actions like below..


  | 
  | @In(create=true)
  | private Session hibernateSession;
  | 
  | @Out @In(required=false)
  | Category category;
  | 
  | public String save(){
  |         //bla bla
  |         hibernateSession.saveOrUpdate(category);
  |         hibernateSession.flush();
  |         return "success";
  |     }
  | 

when i want to test this action with testNG, hibernate session doesnt initialize..

@Test
  | 	public void testAddCategory() throws Exception {
  | 		Category cat = new Category();
  | 		cat.setName("test");
  | 		CategoryAction action = new CategoryAction();
  | 		action.setCategory(cat);
  | 		//
  | 		assert "categoryTree".equals(action.save());//throws nullpointer  because of the not initialized hibernate session
  | 	}
  | 

and according to me seam doesn't works while testing because Logger and  In annotation doesnt works either..
All the examples are about EntityManagerFactory & EntityManager..

How can i find a solution for this test case with hibernate session ??

thanx.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115763#4115763

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115763



More information about the jboss-user mailing list