Java Mailing List Archive

http://www.junlu.com/

Home » JBoss User »

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

manik.surtani@jboss.com

2007-12-28


Author LoginPost Reply
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=4115864#4115864

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115864
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.