4 Replies Latest reply on Sep 10, 2009 1:46 AM by lucio piccoli

    SeamTest agony

    lucio piccoli Newbie

      hi all,


      i am unable to get a simple seamtest to work.


      i have read chapter 27 of the seam guide.


      1.configured embedded jboss.


      2.write my test to get instance of EJB


      3.execute test using testng in eclipse.


      4.test fails to find any seam component.



      what am i doing incorrect?


      something doesnt look write when End test trace occurs before my test is run.


      the test code come straight from the user guide
      the project was setup from seamgen.
      i havent modified the bootstrap directory.
      the project correctly deploys to jboss4.2.6 and works fine.


      Any help to save my sanity and my meagre pride is appreciated.


      test code
      ------------


      import static org.junit.Assert.assertNotNull;
      import org.jboss.seam.mock.SeamTest;
      import org.testng.annotations.Test;
      
      public class ReferenceBusinessTest  extends SeamTest{
                  
           @Test
           public void testSearch() throws Exception{
                
                new ComponentTest() {
                     @Override
                  protected void testComponents()
                      throws Exception 
                 {             
                            ITPBusiness ref = (ITPBusiness) getInstance("ITPBusiness");
                      assertNotNull( ref );
                  }            
              }.run();
      
           }
      }



      EJB code
      --------------------------


      @Name(value="ITPBusiness")
      @Stateless
      @Local( ITPBusinessLocal.class )
      @Remote( ITPBusinessRemote.class)
      
      public class ITPBusinessImpl implements ITPBusinessLocal{



      the testng trace
      ------------------


      [Invoker 19739141] Invoking com.asteriski.itpflow.business.ReferenceBusinessTest.testSearch
      09:25:40,586 DEBUG [TestLifecycle] >>> Begin test
      09:25:40,591 DEBUG [TestLifecycle] <<< End test
      [Invoker 19739141] Invoking @AfterMethod org.jboss.seam.mock.SeamTest.end()
      09:25:40,592 DEBUG [Lifecycle] End of session, destroying contexts
      09:25:40,592 DEBUG [Lifecycle] destroying conversation contexts: []
      09:25:40,592 DEBUG [Lifecycle] destroying session context
      09:25:40,592 DEBUG [Contexts] destroying: org.jboss.seam.security.credentials
      09:25:40,592 DEBUG [Contexts] destroying: org.jboss.seam.security.ruleBasedPermissionResolver
      09:25:40,592 DEBUG [Contexts] destroying: org.jboss.seam.security.identity
      09:25:40,593 DEBUG [Contexts] destroying: org.jboss.seam.web.session
      09:25:40,593 DEBUG [Contexts] destroying: org.jboss.seam.security.rememberMe
      09:25:40,593 DEBUG [Contexts] destroying: org.jboss.seam.core.conversationEntries
      09:25:40,593 DEBUG [Contexts] destroying: org.jboss.seam.core.events
      [Invoker 19739141] Invoking @AfterClass org.jboss.seam.mock.SeamTest.cleanupClass()
      
      *********** INVOKED METHODS
      
           org.jboss.seam.mock.SeamTest.setupClass() 2288971
                com.asteriski.itpflow.business.ReferenceBusinessTest.testSearch() 2288971
           org.jboss.seam.mock.SeamTest.cleanupClass() 2288971
      
      ***********
      
      Creating C:\src\seamitp\test-output\seamitp\com.asteriski.itpflow.business.ReferenceBusinessTest.html
      Creating C:\src\seamitp\test-output\seamitp\com.asteriski.itpflow.business.ReferenceBusinessTest.xml
      FAILED: testSearch
      java.lang.AssertionError: 
           at org.junit.Assert.fail(Assert.java:91)
           at org.junit.Assert.assertTrue(Assert.java:43)
           at org.junit.Assert.assertNotNull(Assert.java:524)
           at org.junit.Assert.assertNotNull(Assert.java:535)
           at com.asteriski.itpflow.business.ReferenceBusinessTest$1.testComponents(ReferenceBusinessTest.java:23)
           at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
           at com.asteriski.itpflow.business.ReferenceBusinessTest.testSearch(ReferenceBusinessTest.java:25)





        • 1. Re: SeamTest agony
          Jean Luc Apprentice

          sorry for asking the obvious... are there any deployment errors further up in the log, when the embedded container is started?

          • 2. Re: SeamTest agony
            lucio piccoli Newbie

            Jean Luc wrote on Sep 08, 2009 23:04:


            sorry for asking the obvious... are there any deployment errors further up in the log, when the embedded container is started?


            I have set the trace to DEBUG. There is lots trace but nothing to indicated an ERROR or FAILURE.


            Moreover there is also nothing to indicate that my EJB's have been found or deployed.
            Q1.Should there be some sort trace to indicate EJB deployment?
            Q2.Is there some sort of explicit class apth setting that i have missed?


            I dont know how to correct this problem as the docs for embedded JBoss are poor.


            any ideas on something to try as my sanity is slowly slipping away....


            -lp

            • 3. Re: SeamTest agony
              Jean Luc Apprentice

              Yes, you should see something like


              INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=classes,name=FooServiceBean,service=EJB3 with dependencies:
              INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
              INFO  [org.jboss.ejb3.MCKernelAbstraction]      Class:com.company.FooService
              



              for each session bean. I suspect what you suspect as well: your EJBs are not getting deployed. Is it in a separate project perhaps?


              If you're developing on Windows, use FileMon to see if and where your code is getting deployed.

              • 4. Re: SeamTest agony
                lucio piccoli Newbie


                for each session bean. I suspect what you suspect as well: your EJBs are not getting deployed. Is it in a separate project perhaps?

                If you're developing on Windows, use FileMon to see if and where your code is getting deployed.

                ok i found my problem after re-reading the ch 37 of seam testing i need to have my EJB in a folder structure that resembles an ejb.jar.
                my mistake i was expecting embedded jboss to work like openEJB.


                many thanks


                -lp