0 Replies Latest reply on Jun 16, 2008 4:02 PM by Michel Jazz

    TestNG problems : initCredentialsFromCookie

    Michel Jazz Newbie

      Hi everybody,


      I just want to try to test my session ejb. I create a Seam project, and then create an action :



      import javax.ejb.Stateless;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.faces.FacesMessages;
      
      @Stateless
      @Name("createProject")
      public class CreateProjectBean implements CreateProject {
              
          @Logger private Log log;
              
          @In FacesMessages facesMessages;
          
          public void createProject()
          {
              //implement your business logic here
              log.info("createProject.createProject() action called");
              facesMessages.add("createProject");
          }
          
          //add additional action methods
          
      }



      This has generated the test class :



      import org.testng.annotations.Test;
      import org.jboss.seam.mock.SeamTest;
      
      public class CreateProjectTest extends SeamTest {
      
           @Test
           public void test() throws Exception {
                new FacesRequest() {
                     @Override
                     protected void invokeApplication() {
                          //call action methods here
                          invokeMethod("#{createProject.createProject}");
                     }
                }.run();
           }
      }



      After the deployment, everythings ok on :
      http://localhost:8080/mnaproject/createProject.seam. But when i launch the test, i have this error :



      FAILED CONFIGURATION: @BeforeMethod begin
      java.lang.IllegalArgumentException: Could not invoke method by reflection: FacesSecurityEvents.initCredentialsFromCookie(org.jboss.seam.security.Identity) with parameters: (org.jboss.seam.Component) on: org.jboss.seam.security.FacesSecurityEvents
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:31)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
           at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
           at org.jboss.seam.Component.newInstance(Component.java:1969)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.Lifecycle.beginSession(Lifecycle.java:187)
           at org.jboss.seam.contexts.ServletLifecycle.beginSession(ServletLifecycle.java:124)
           at org.jboss.seam.mock.BaseSeamTest.begin(BaseSeamTest.java:920)
           at org.jboss.seam.mock.SeamTest.begin(SeamTest.java:28)
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           ... 34 more
      ... Removed 28 stack frames
      SKIPPED CONFIGURATION: @AfterMethod end
      SKIPPED CONFIGURATION: @AfterClass cleanup
      SKIPPED: test
      
      ===============================================
          CreateProject Test
          Tests run: 1, Failures: 0, Skips: 1
          Configuration Failures: 1, Skips: 2
      ===============================================
      
      
      ===============================================
      CreateProject Tests
      Total tests run: 1, Failures: 0, Skips: 1
      Configuration Failures: 1, Skips: 2
      ===============================================
      


      I used Seam version 2.1.0.A1 and the JBossTools version 2.1.1 for Eclipse.JBoss is JBoss AS 4.2.2.GA.


      Any ideas ??