[jboss-user] [JBoss Seam] - injection in tests ?

berkay do-not-reply at jboss.com
Fri Dec 28 03:55:46 EST 2007

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

  | 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..

  | 	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 ??


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

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

More information about the jboss-user mailing list