1 Reply Latest reply on Jan 29, 2008 8:16 AM by F BI

    Injection in SeamTest

    F BI Newbie


      I'm facing some problems with my injected properties in my TestNG tests.
      Probably this is very easy to solve, but I currently don't have the "right" idea.

      The class to be tested is as follows:

      public class EntityManager implements Serializable, PagedEntityManager {
       * The injected entity class name.
       @In(value = "#{entityClassName}", create=true)
       private String m_overrideEntityClassName;
       public void showEntity(){
       //access the injected field

      Note that the name entityManager is just arbitrary and has nothing to do with EJB or JPA EntityManager!

      Now my testclass looks like this

      public class EntityManagerTest
       extends SeamTest {
       public void testPersistEntity() throws Exception {
       assert !super.isSessionInvalid();
       new FacesRequest() {
       protected void updateModelValues() throws Exception
       //try to set the entityClassName
       protected void invokeApplication() throws Exception
       //Invoke method that uses previously set entityClassName

      The problem is: entityClassName is never injected into the entityManager. When accessing the private field it in the method showEntity, it is always null.

      Am I missing something?

      Thanks for any help.