6 Replies Latest reply on May 13, 2008 10:23 AM by bard123

    Problem with testNG

    bard123

      Hi,


      I work with JBoss-seam-2.0.1.GA, JBoss-4.2.0.GA and ant1.7, I want to do unit tests, so I use testNG. I therefore create file Test.xml in my folder test of my project, and I create class test to test methods.


      I do


      ant test



      under a console windows, so is working well, here's what I see:



      BUILD SUCCESSFUL
      Total time: 4 seconds





      But when I look at the test report here the mistake that I have:



      @BeforeClass init : 
      
      java.lang.NoClassDefFoundError: org/jboss/beans/metadata/spi/BeanMetaData
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:164)
           at org.jboss.seam.mock.BaseSeamTest.embeddedJBossAvailable(BaseSeamTest.java:1051)
           at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1039)
           at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:935)
           at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
           at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
      ... Removed 22 stack frames
      
      



      But I don't know what is the problem ?


      Thank you

        • 1. Re: Problem with testNG
          bard123

          I have always the problem


          Please HELP !


          thank you

          • 2. Re: Problem with testNG
            zergspirit

            Is that the full stack trace?

            • 3. Re: Problem with testNG
              bard123

              The full stack trace of the test.html of my project :


              java.lang.NoClassDefFoundError: org/jboss/beans/metadata/spi/BeanMetaData
                   at java.lang.Class.forName0(Native Method)
                   at java.lang.Class.forName(Class.java:164)
                   at org.jboss.seam.mock.BaseSeamTest.embeddedJBossAvailable(BaseSeamTest.java:1051)
                   at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1039)
                   at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:935)
                   at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
                   at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:585)
                   at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
                   at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:394)
                   at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
                   at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:79)
                   at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:165)
                   at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:103)
                   at org.testng.TestRunner.runWorkers(TestRunner.java:678)
                   at org.testng.TestRunner.privateRun(TestRunner.java:624)
                   at org.testng.TestRunner.run(TestRunner.java:495)
                   at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
                   at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
                   at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
                   at org.testng.SuiteRunner.run(SuiteRunner.java:190)
                   at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
                   at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
                   at org.testng.TestNG.run(TestNG.java:699)
                   at org.testng.TestNG.privateMain(TestNG.java:824)
                   at org.testng.TestNG.main(TestNG.java:802)
              
              



              And I don't know why ?

              • 4. Re: Problem with testNG
                bard123

                Hi,


                I changed version jboss and jboss seam, I now works with JBoss-4.2.2.GA and JBoss-seam-2.0.1.CR1, but the test does not work better. Here is the mistake that I have now:



                @BeforeClass init :
                java.lang.NoClassDefFoundError: EDU/oswego/cs/dl/util/concurrent/ConcurrentReaderHashMap
                     at org.jboss.util.collection.CollectionsFactory.createConcurrentReaderMap(CollectionsFactory.java:73)
                     at org.jboss.kernel.plugins.event.AbstractEventEmitter.<init>(AbstractEventEmitter.java:60)
                     at org.jboss.kernel.plugins.AbstractKernelObject.<init>(AbstractKernelObject.java:47)
                     at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.<init>(AbstractBootstrap.java:51)
                     at org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap.<init>(BasicBootstrap.java:58)
                     at org.jboss.embedded.Bootstrap.createKernel(Bootstrap.java:122)
                     at org.jboss.seam.mock.embedded.BootstrapWrapper.getInstance(BootstrapWrapper.java:19)
                     at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:11)
                     at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1005)
                     at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:929)
                     at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
                



                     
                I no longer know what to do!


                If I watched the version of java that I use, and when I do java -version I have this:



                java version "1.5.0_09"
                Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
                Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode)




                Help !

                • 5. Re: Problem with testNG
                  pmuir

                  I suggest you start with a seam-gen'd project. I can assure that Seam tests work ootb with that setup.

                  • 6. Re: Problem with testNG
                    bard123

                         
                    Hi,


                    I finally managed to run test for it, I changed version of seam and application server JBoss, now, I work with jboss-seam-2.0.2.CR1 and JBoss-4.2.2.GA.


                    By cons, I would like to know how we can test methods with parameters.
                    My test works with a method like this:


                    public void test(){
                         TypeDocument t = new TypeDocument();
                         t.setNom("testType");
                         em.persist(t);
                    }
                    




                    Here is my test:


                    public class ListeTypeTagTest extends SeamTest{
                         
                         @Test
                         public void testListeTypeTagComponent() throws Exception{
                    
                              new ComponentTest() {
                    
                                   protected void testComponents() throws Exception
                                   {
                                        
                                        
                                        invokeMethod("#{gestionDeDocument.test}");
                                   }
                    
                              }.run();
                    
                         }
                    
                    }
                    





                    But if I have a method like this:


                    public void creerTypeTag(String item, String gestion){
                              try{
                                   if(gestion.equals("type")){
                                        if(!item.equals("")){
                                             TypeDocument type = new TypeDocument();
                                             type.setNom(item);
                                             type.setCommentaire("");
                                             em.persist(type);
                                        }
                                   }
                                   if(gestion.equals("tag")){
                                        if(!item.equals("")){
                                             Tag tag = new Tag();
                                             tag.setNom(item);
                                             tag.setCommentaire("");
                                             em.persist(tag);
                                        }
                                   }
                                   em.flush();
                              }catch(Exception e){
                                   e.printStackTrace();
                              }
                         }





                    And the parameters : item et gestion, I want to retrieve via a form, then do a test like this:



                    public class ListeTypeTagTest extends SeamTest{
                         
                         @Test
                         public void testListeTypeTagComponent() throws Exception{
                    
                              new ComponentTest() {
                    
                                   protected void testComponents() throws Exception
                                   {
                    
                                        setValue("#{gestionDeDocument.item}","typeTest");
                                        setValue("#{gestionDeDocument.gestion}","type");
                    invokeMethod("#gestionDeDocument.creerTypeTag(gestionDeDocument.item, gestionDeDocument.gestion)");
                                   }
                    
                              }.run();
                    
                         }
                    
                    }





                    it does not work.
                    Could you tell me why ?


                    Thank you