2 Replies Latest reply on Feb 16, 2007 4:31 AM by denis-karpov

    TestNg problem with my seam application

    argomauro

      I've create an application with SEAM and i've create a simple test class with testNg. I put in my classpath the embedded-ejb/conf but it's not work.

      My Test class is:

      public class TestManagerProfilo extends SeamTest {
      
       @Test
       public void testInsertProfilo() throws Exception{
       new Script() {
       @Override
       protected void updateModelValues() throws Exception {
       EntityProfilo profilo = (EntityProfilo) Component.getInstance(
       "profilo", true);
       assert profilo != null;
       profilo.setId(new Integer(3));
       profilo.setNome("mauro");
       profilo.setDescrizione("Gavin King");
       }
      
       @Override
       protected void invokeApplication() {
       ManagerProfilo manager = (ManagerProfilo) Component
       .getInstance("managerProfilo", true);
       String outcome = manager.insert();
       assert "/registered.jsp".equals(outcome);
       }
      
       @Override
       protected void renderResponse() {
       EntityProfilo profilo = (EntityProfilo) Component.getInstance(
       "profilo", true);
       assert profilo != null;
       profilo.setId(new Integer(3));
       profilo.setNome("mauro");
       profilo.setDescrizione("Gavin King");
       }
       }.run();
       }
      
      }
      


      My Entity class "EntityProfilo" is:
      @Entity
      @Name("profilo")
      @Scope(SESSION)
      @Table(name="profilo")
      public class EntityProfilo implements Serializable {
      
       private static final long serialVersionUID = 1881413500711441951L;
      
       public EntityProfilo(Integer id, String nome, String descrizione)
       {
       this.id = id;
       this.nome = nome;
       this.descrizione = descrizione;
       }
      
       public EntityProfilo(){}
      
       private Integer id;
       private String nome;
       private String descrizione;
       //private Set<EntityUtente> utenti = new HashSet<EntityUtente>(0);
      
       public void setId(Integer id) {
       this.id = id;
       }
       @Id @GeneratedValue
       public Integer getId() {
       return id;
       }
      
       public void setNome(String nome) {
       this.nome = nome;
       }
      
       @NotNull @Length(min=5, max=15)
       public String getNome() {
       return nome;
       }
      
       public void setDescrizione(String descrizione) {
       this.descrizione = descrizione;
       }
      
       @NotNull @Length(min=5, max=15)
       public String getDescrizione() {
       return descrizione;
       }
      }
      
      


      And my Session bean "ManagerProfilo" is:
      @Stateless
      @Name("managerProfilo")
      public class ManagerProfilo implements Serializable, ICrud {
      
       @In (value="profilo")
       private EntityProfilo profilo;
      
       @PersistenceContext
       private EntityManager em;
       @Logger
       private Log log;
      
      
       public String insert() {
      
       em.persist(profilo);
       log.info("Profilo #{profilo.nome}");
       return "insertProfilo";
       }
      
      }
      

      The problem is that when my test run this exception is throw:
      INFO 26-10 09:21:16,093 (Log4JLogger.java:info:94) -no components.xml file found
      INFO 26-10 09:21:16,156 (Log4JLogger.java:info:94) -reading properties from: /jndi.properties
      INFO 26-10 09:21:16,156 (Log4JLogger.java:info:94) -initializing Seam
      INFO 26-10 09:21:16,343 (Log4JLogger.java:info:94) -Component: org.jboss.seam.core.init, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Init
      INFO 26-10 09:21:16,734 (Log4JLogger.java:info:94) -Component: org.jboss.seam.core.pages, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Pages
      INFO 26-10 09:21:16,765 (Log4JLogger.java:info:94) -Component: events, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Events
      INFO 26-10 09:21:16,812 (Log4JLogger.java:info:94) -Component: org.jboss.seam.core.manager, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.core.Manager
      INFO 26-10 09:21:16,890 (Log4JLogger.java:info:94) -Component: switcher, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.Switcher
      INFO 26-10 09:21:16,937 (Log4JLogger.java:info:94) -Component: redirect, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Redirect
      INFO 26-10 09:21:16,953 (Log4JLogger.java:info:94) -Component: httpError, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.HttpError
      INFO 26-10 09:21:16,984 (Log4JLogger.java:info:94) -Component: userPrincipal, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.UserPrincipal
      INFO 26-10 09:21:17,015 (Log4JLogger.java:info:94) -Component: isUserInRole, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.IsUserInRole
      INFO 26-10 09:21:17,031 (Log4JLogger.java:info:94) -Component: conversation, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Conversation
      INFO 26-10 09:21:17,093 (Log4JLogger.java:info:94) -Component: conversationList, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationList
      INFO 26-10 09:21:17,109 (Log4JLogger.java:info:94) -Component: conversationStack, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationStack
      INFO 26-10 09:21:17,125 (Log4JLogger.java:info:94) -Component: facesContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesContext
      INFO 26-10 09:21:17,140 (Log4JLogger.java:info:94) -Component: pageContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.PageContext
      INFO 26-10 09:21:17,203 (Log4JLogger.java:info:94) -Component: eventContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.EventContext
      INFO 26-10 09:21:17,218 (Log4JLogger.java:info:94) -Component: sessionContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.SessionContext
      INFO 26-10 09:21:17,234 (Log4JLogger.java:info:94) -Component: statelessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.StatelessContext
      INFO 26-10 09:21:17,234 (Log4JLogger.java:info:94) -Component: applicationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ApplicationContext
      INFO 26-10 09:21:17,250 (Log4JLogger.java:info:94) -Component: conversationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationContext
      INFO 26-10 09:21:17,265 (Log4JLogger.java:info:94) -Component: businessProcessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.BusinessProcessContext
      INFO 26-10 09:21:17,281 (Log4JLogger.java:info:94) -Component: locale, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Locale
      INFO 26-10 09:21:17,296 (Log4JLogger.java:info:94) -Component: messages, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.Messages
      INFO 26-10 09:21:17,312 (Log4JLogger.java:info:94) -Component: interpolator, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Interpolator
      INFO 26-10 09:21:17,328 (Log4JLogger.java:info:94) -Component: facesMessages, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesMessages
      INFO 26-10 09:21:17,359 (Log4JLogger.java:info:94) -Component: resourceBundle, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.ResourceBundle
      INFO 26-10 09:21:17,375 (Log4JLogger.java:info:94) -Component: localeSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.LocaleSelector
      INFO 26-10 09:21:17,406 (Log4JLogger.java:info:94) -Component: uiComponent, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.UiComponent
      INFO 26-10 09:21:17,406 (Log4JLogger.java:info:94) -Component: org.jboss.seam.remoting.messaging.subscriptionRegistry, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.remoting.messaging.SubscriptionRegistry
      INFO 26-10 09:21:17,687 (Log4JLogger.java:info:94) -Component: pojoCache, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.PojoCache
      INFO 26-10 09:21:17,937 (Log4JLogger.java:info:94) -done initializing Seam
      FAILED: testInsertProfilo
      java.lang.AssertionError
       at it.publisys.dap.test.TestManagerProfilo$1.updateModelValues(TestManagerProfilo.java:26)
       at org.jboss.seam.mock.SeamTest$Script.run(SeamTest.java:237)
       at it.publisys.dap.test.TestManagerProfilo.testInsertProfilo(TestManagerProfilo.java:49)
      ... Removed 20 stack frames
      
      ===============================================
       it.publisys.dap.test.TestManagerProfilo
       Tests run: 1, Failures: 1, Skips: 0
      ===============================================
      
      
      ===============================================
      DAP
      Total tests run: 1, Failures: 1, Skips: 0
      ===============================================
      

      TestManagerProfilo don't work but when i deploy this application on JBoss it's work fine. I think that the problem is the project configuration or test configuration but i don't find it....

      Thank for your help. I'm a new Seam programmer :-)