6 Replies Latest reply on Jan 2, 2008 5:32 AM by Pete Muir

    injection in tests ?

    Berkay Aktan Newbie

      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.