1 2 Previous Next 17 Replies Latest reply on Jun 3, 2010 3:57 AM by venkat akkineni

    SeamTest help

    venkat akkineni Newbie

      Hello


                 I am unable to run a very basic seam test on registration. Here is a list of things I have done. We are using Maven as a build tool.


      Added richfaces-impl to dependencies
      Inlcuded jboss mojo plugin to the plugins.


           public void updateModalValues(){
                      Person person = (Person) Component.getInstance("person");
           }
      
      




      null
      java.lang.NullPointerException
              at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:492)
              at be.oniryx.lean.session.RegisterActionTest.testRegister(RegisterActionTest.java:27)
      


      Could some body help me out with this.


      Thanks in advance
      Venkat

        • 1. Re: SeamTest help
          venkat akkineni Newbie


          Since I haven't received a reply about the question, I want to divert the conversation a bit.


          I have come across Arquillian. It is a very neat tool. Some blog posts say JSF testing is not possible with Arquillian. To what extent is this true?


          Also We are building our application against JBoss 4.2.3. Aquillian website shows support only for version 5.1 and 6.0 . Has anybody tried using arquillian with jboss 4.2.3?


          Has any one tried testing seam based applications with Arquillian. If so what are the things I should be prepared for.


          Venkat

          • 2. Re: SeamTest help
            Nikolay Elenkov Master

            Getting SeamTest to work is generally a bitch, because of the whole classloading mess. Using Maven complicates things a bit,
            because it may change classloading order. Those issues have been fixed in recent version, so it should work. Compare the
            Ant files Seam comes with or a seamgen project with your project and try to match the jar order. Once the embedded container
            starts up, all other errors are probably on your side. Btw, you have not provided enough information to get help.


            As for Arquillian. Would it be possible to test Seam 2 projects with Arquillian? If it is easier than SeamTest/jboss embedded,
            I would definitely like to use it, since it looks like we will be using Seam 2 for at least a while (it is hard to sell
            alpha-level software for your next project and a version of JBoss supporting JEE 6 is yet to be released, let alone supported
            by RedHat.)


            • 3. Re: SeamTest help
              elfuhrer Novice

              Another approach is to use OpenEjb for test units, I gave up on testing withing JBoss Embedded ages ago, bootstraping OpenEjb is much easier and quicker to do and has no classloading issues as far as I recall

              • 4. Re: SeamTest help
                venkat akkineni Newbie

                Hi


                Thanks for your replies. I have completely lost track of the post. I was successful creating a bootstrap setup using cargo plugin for maven. Then I wrote a test and ended up with nullpointerexception again. So I asked my pal google for help and he brought me here. I most definitely am lost in a maze with try to setup integration tests with seam.


                I hope to get the tests running (fingers crossed). Any clues as to why I am not able to run seam tests even after bootstrapping jboss?



                I have seen a post on developing integration tests for seam with jboss and openejb. But, I wanted to test my persistence first.


                About Arquillian, I did post a help question on their forum and unfortunately they don't support with jboss 4.2.3 or seam. So there goes another option.


                My Link


                Thanks in advance.
                Venkat Akkineni

                • 5. Re: SeamTest help
                  venkat akkineni Newbie

                  venkat akkineni wrote on May 23, 2010 12:38:


                  Hi

                  Thanks for your replies. I have completely lost track of the post. I was successful creating a bootstrap setup using cargo plugin for maven. Then I wrote a test and ended up with nullpointerexception again. So I asked my pal google for help and he brought me here. I most definitely am lost in a maze with try to setup integration tests with seam.

                  I hope to get the tests running (fingers crossed). Any clues as to why I am not able to run seam tests even after bootstrapping jboss?


                  I have seen a post on developing integration tests for seam with jboss and openejb. But, I wanted to test my persistence first.

                  About Arquillian, I did post a help question on their forum and unfortunately they don't support with jboss 4.2.3 or seam. So there goes another option.

                  forum post

                  Thanks in advance.
                  Venkat Akkineni


                  Click HELP for text formatting instructions. Then edit this text and check the preview.

                  • 6. Re: SeamTest help
                    venkat akkineni Newbie

                    Please find the stacktrace below...


                    java.lang.NullPointerException
                         at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:492)
                         at be.oniryx.lean.session.RegisterActionTest.testRegister(RegisterActionTest.java:76)
                         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:597)
                         at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
                         at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
                         at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
                         at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
                         at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
                         at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
                         at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
                         at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
                         at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
                         at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
                         at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
                         at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
                         at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
                         at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
                         at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
                         at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
                         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:597)
                         at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
                         at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
                    



                    • 7. Re: SeamTest help
                      Nikolay Elenkov Master

                      What version of Seam are you using? Can you post the source of


                      be.oniryx.lean.session.RegisterActionTest.testRegister(RegisterActionTest.java:76)
                      

                      • 8. Re: SeamTest help
                        venkat akkineni Newbie

                        Nikolay


                               Thanks for your reply. Any help is appreciated.


                        import be.oniryx.lean.entity.Person;
                        import org.jboss.seam.Component;
                        import org.jboss.seam.mock.AbstractSeamTest.FacesRequest;
                        import org.jboss.seam.mock.SeamTest;
                        import org.junit.Test;
                        
                        /**
                         *
                         * @author venkat
                         */
                        public class RegisterActionTest extends SeamTest{
                        
                            /**
                             * Test of register method, of class RegisterAction.
                             */
                            @Test
                            public void testRegister() throws Exception {
                                String run = new FacesRequest("/register.xhtml") {
                        
                                    @Override
                                    protected void updateModelValues() {
                                        Person person = (Person) Component.getInstance("newPerson");
                                        person.setEmail("leanpm@ymail.com");
                                        person.setLogin("leanpmTest");
                                        person.setPassword("leanpmTest");
                                        person.setLastName("Test");
                                        person.setFirstName("leanpm");
                                    }
                        
                                    @Override
                                    protected void invokeApplication() {
                                        String outcome = (String) invokeMethod("#{registerAction.register}");
                                        assert outcome != null && outcome.equals("success");
                                    }
                                }.run();
                            }
                        }



                        • 9. Re: SeamTest help
                          Nikolay Elenkov Master

                          Which is line 76 from the above trace? Is your Person class a component, and where does newPerson come from?
                          Component.getInstance() expects a component name.



                          • 10. Re: SeamTest help
                            venkat akkineni Newbie

                            Line 76 refers to


                            String run = new FacesRequest("/register.xhtml") {



                            The component's name I was trying to instantiate is an entity bean Person and was passing wrong component name all along (newPerson). I tried to build using Person as the component name but ended up with the same result.


                            I can't understand what's causing the problem.


                            Venkat



                            • 11. Re: SeamTest help
                              Nikolay Elenkov Master

                              You should really tell us what version of Seam you are using. There is an NPE inside of SeamTest, so this might be still a configuration issue.
                              Your best bet is to attach the debugger and find out where exactly it fails.


                              HTH

                              • 12. Re: SeamTest help
                                venkat akkineni Newbie

                                sorry about that Nikolay. I am using seam 2.1.0.

                                • 13. Re: SeamTest help
                                  venkat akkineni Newbie

                                  Hi


                                       After hours of work and weeks of procrastination I was finally able to configure maven, cargo, jboss 4.2.3. I am now stuck because of dependency errors.


                                  I was able to realize that it is being caused by RichFaces. I've tried adding RichFaces as a dependency in integration tests module, but that didn't do any good. RichFaces is being used by WAR module of the application.


                                  Has anyone faced similar problems? Please let me know if the information is not enough. Also please visit LeanPM.


                                  The following are the dependencies I have added.


                                  <dependency>
                                              <groupId>org.richfaces.framework</groupId>
                                              <artifactId>richfaces-api</artifactId>
                                              <version>3.3.1.GA</version>
                                              <type>jar</type>
                                          </dependency>
                                          <dependency>
                                              <groupId>org.richfaces.framework</groupId>
                                              <artifactId>richfaces-impl</artifactId>
                                              <version>3.3.3-FINAL</version>
                                          </dependency>
                                          <dependency>
                                              <groupId>org.richfaces.ui</groupId>
                                              <artifactId>richfaces-ui</artifactId>
                                              <version>3.3.1.GA</version>
                                              <scope>provided</scope>
                                          </dependency>
                                  



                                  The following is the stack trace.


                                  -------------------------------------------------------------------------------
                                  Test set: TestSuite
                                  -------------------------------------------------------------------------------
                                  Tests run: 7, Failures: 1, Errors: 0, Skipped: 6, Time elapsed: 5.839 sec <<< FAILURE!
                                  startSeam(be.oniryx.lean.session.RegisterActionTest)  Time elapsed: 0 sec  <<< FAILURE!
                                  java.lang.RuntimeException: Could not create Component: reportManager
                                       at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1155)
                                       at org.jboss.seam.init.Initialization.installComponents(Initialization.java:1071)
                                       at org.jboss.seam.init.Initialization.init(Initialization.java:720)
                                       at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:920)
                                       at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
                                       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:597)
                                       at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
                                       at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:322)
                                       at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:156)
                                       at org.testng.SuiteRunner.privateRun(SuiteRunner.java:223)
                                       at org.testng.SuiteRunner.run(SuiteRunner.java:145)
                                       at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
                                       at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
                                       at org.testng.TestNG.run(TestNG.java:613)
                                       at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
                                       at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
                                       at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
                                       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:597)
                                       at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
                                       at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
                                  Caused by: java.lang.NoClassDefFoundError: UploadEvent
                                       at java.lang.Class.getDeclaredMethods0(Native Method)
                                       at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
                                       at java.lang.Class.privateGetPublicMethods(Class.java:2547)
                                       at java.lang.Class.getMethods(Class.java:1410)
                                       at org.jboss.seam.Component.hasAnnotation(Component.java:1085)
                                       at org.jboss.seam.Component.<init>(Component.java:218)
                                       at org.jboss.seam.Component.<init>(Component.java:205)
                                       at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1139)
                                       ... 25 more
                                  Caused by: java.lang.ClassNotFoundException: UploadEvent
                                       at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
                                       at java.security.AccessController.doPrivileged(Native Method)
                                       at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                                       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
                                       ... 33 more
                                  Caused by: java.lang.NoClassDefFoundError: UploadEvent
                                       at java.lang.Class.getDeclaredMethods0(Native Method)
                                       at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
                                       at java.lang.Class.privateGetPublicMethods(Class.java:2547)
                                       at java.lang.Class.getMethods(Class.java:1410)
                                       at org.jboss.seam.Component.hasAnnotation(Component.java:1085)
                                       at org.jboss.seam.Component.<init>(Component.java:218)
                                       at org.jboss.seam.Component.<init>(Component.java:205)
                                       at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1139)
                                       ... 25 more
                                  Caused by: java.lang.ClassNotFoundException: UploadEvent
                                       at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
                                       at java.security.AccessController.doPrivileged(Native Method)
                                       at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                                       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
                                       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
                                       ... 33 more
                                  
                                  
                                  



                                  Any help is appreciated.
                                  Thanks
                                  Venkat

                                  • 14. Re: SeamTest help
                                    Nikolay Elenkov Master

                                    venkat akkineni wrote on Jun 02, 2010 21:33:


                                    I was able to realize that it is being caused by RichFaces. I've tried adding RichFaces as a dependency in integration tests module, but that didn't do any good. RichFaces is being used by WAR module of the application.


                                    It's actually easier to do this if the tests live in the web module, since they need web.xml, components.xml, etc (not a separate test module).


                                    Did you try adding the RF jars to your web project with <scope>test</scope>?


                                    1 2 Previous Next