8 Replies Latest reply on Nov 24, 2007 2:56 PM by pmuir

    How to invoking methods with parameters with Seam test?

    paradigmza

      Hi, I have looked through the seam examples can can't find out how to invoke a method with parameters with Seam test.

      This is the method I want to test

      @Stateless
      @Name("dbi")
      @AutoCreate
      public class DBI_EJB_Impl implements DBI {
      
       @In
       EntityManager entityManager;
      
      
       public void create(DataObject daoObject){
       entityManager.persist(daoObject);
       } ..


      Now how do I actually call the create method and pass it the DataObject?

      This is what I have so far
      public class DBI_EJB_ImplTest extends DBUnitSeamTest {
      
       public DBI_EJB_ImplTest() {
       super("java:/SomeDatasource");
       }
      
      @Test
       public void testCreate() throws Exception {
       new ComponentTest() {
       @Override
       protected void testComponents() throws Exception {
       Employee employee = new Employee();
       employee.setFirstName("abcdefghijklmnop");
       employee.setLastName("burns");
      
       //invokeMethod("#{dbi.create()}");
       //How do I call this the method and pass in the employee?
       }
      
       }.run();
      
      


      I am sure the solution is simple... I just can't find it.

      Thanks.

        • 1. Re: How to invoking methods with parameters with Seam test?
          paradigmza

          Hmm, looks like there is a Major problem with Seam 2 and Embedded Jboss.... so going to write normal Junit tests for now.

          • 2. Re: How to invoking methods with parameters with Seam test?
            pmuir

             

            @Test
            public void testCreate() throws Exception {
             new ComponentTest() {
             @Override
             protected void testComponents() throws Exception {
             Employee employee = new Employee();
             employee.setFirstName("abcdefghijklmnop");
             employee.setLastName("burns");
             ( (DBI) getInstance("dbi") ).create(employee);
             }
            
             }.run();
            }


            Not a problem with Seam ;)

            • 3. Re: How to invoking methods with parameters with Seam test?
              paradigmza

              Thanks... as I thought... very simple :-)

              Is there an eta on when a fix will be commited to Embedded Jboss so that we can run these Seam tests? (These test are extremely useful for me... and I would really like to use them)

              • 4. Re: How to invoking methods with parameters with Seam test?
                pmuir

                What fix?

                • 5. Re: How to invoking methods with parameters with Seam test?
                  paradigmza
                  • 6. Re: How to invoking methods with parameters with Seam test?
                    pmuir

                    We are waiting on the JBoss AS team stabilising JBoss AS trunk before building a new JBoss Embedded.

                    The workaround is just to run the tests using ant :)

                    • 7. Re: How to invoking methods with parameters with Seam test?
                      paradigmza

                      I tried ant and got the same error... (I used the ant file that is automatically created by Eclipse, and just added the testng task... and got the same error.


                      [testng] at org.testng.TestNG.main(TestNG.java:802)
                       [testng] Caused by: java.lang.IllegalStateException: FileHandler@32237804[path= context=file:/D:/Workspace/Eclipse/TheNextStep-ejb/build/classes/ real=file:/D:/Workspace/Eclipse/TheNextStep-ejb/build/classes/] has no parent.
                       [testng] at org.jboss.virtual.VFSUtils.addManifestLocations(VFSUtils.java:116)
                       [testng] at org.jboss.deployers.plugins.structure.DefaultStructureBuilder.processContext(DefaultStructureBuilder.java:131)
                       [testng] at org.jboss.deployers.plugins.structure.DefaultStructureBuilder.populateContext(DefaultStructureBuilder.java:89)
                       [testng] ... 33 more
                       [testng] FAILED CONFIGURATION: @BeforeClass init
                       [testng] org.jboss.deployers.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
                       [testng] *** DEPLOYMENTS IN ERROR: Name -> Error
                       [testng] vfsfile:/D:/Workspace/Eclipse/TheNextStep-ejb/build/classes/ -> java.lang.IllegalStateException: FileHandler@32237804[path= context=file:/D:/Workspace/Eclipse/TheNextStep-ejb/build/classes/ real=file:/D:/Workspace/Eclipse/TheNextStep-ejb/build/classes/] has no parent.
                       [testng] at org.jboss.embedded.DeploymentGroup.checkIncomplete(DeploymentGroup.java:151)
                       [testng] at org.jboss.embedded.DeploymentGroup.process(DeploymentGroup.java:129)
                       [testng] at org.jboss.embedded.Bootstrap.deployResourceBases(Bootstrap.java:307)
                       [testng] at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:14)
                       [testng] at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1006)
                       [testng] at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:931)
                       [testng] at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
                       [testng] ... Removed 22 stack frames
                       [testng] SKIPPED CONFIGURATION: @BeforeMethod begin
                       [testng] SKIPPED CONFIGURATION: @AfterMethod end
                       [testng] SKIPPED CONFIGURATION: @AfterClass cleanup
                       [testng] SKIPPED: test
                       [testng] ===============================================
                       [testng] Ant test
                       [testng] Tests run: 1, Failures: 0, Skips: 1
                       [testng] Configuration Failures: 1, Skips: 3
                       [testng] ===============================================
                       [testng] ===============================================
                       [testng] Ant suite
                       [testng] Total tests run: 1, Failures: 0, Skips: 1
                       [testng] Configuration Failures: 1, Skips: 3
                       [testng] ===============================================


                      • 8. Re: How to invoking methods with parameters with Seam test?
                        pmuir

                        Ok, I spoke to Max and apparently it's not trivial to make JBoss Tools build a correct ant script from a Seam project. I would try to build a custom ant script to do this, based on the test target in the ant script created by seam-gen.