4 Replies Latest reply on Nov 12, 2007 8:37 AM by Dmitriy Lapko

    Running SeamTest-based tests inside an applicatoin server

    Dmitriy Lapko Newbie

      Is there any way to run integrational seam-tests inside application server? Something that should tell SeamTest not to start a new environment but use existing and just simulate JSF lifecycle?

        • 1. Re: Running SeamTest-based tests inside an applicatoin serve
          Pete Muir Master

          Override the startJBossEmbededdedIfNecessary method with an empty body.

          • 2. Re: Running SeamTest-based tests inside an applicatoin serve
            Dmitriy Lapko Newbie

            Thank you for answer, I tried to override it and the test started, but it breaks the application.

            I get

            WARNING: No active application scope
            java.lang.IllegalStateException: No active application scope
             at org.jboss.seam.core.Init.instance(Init.java:75)
            


            after its work.

            And before test there is warning:

            "There should only be one Seam phase listener per application"


            So the problem is in method BaseSeamTest.init:

            public void init() throws Exception
             {
             startJbossEmbeddedIfNecessary(); // We should skip it
            
             application = new SeamApplication( new MockApplication() ); // reuse here existsing application
             phases = new SeamPhaseListener(); // reuse existing phase listener
            
             servletContext = new MockServletContext(); // reuse context
             initServletContext( servletContext.getInitParameters() ); // don't initialize it
            
            // And more and more...
            
             ServletLifecycle.beginApplication(servletContext);
             new Initialization(servletContext).create().init();
             ( (Init) servletContext.getAttribute( Seam.getComponentName(Init.class) ) ).setDebug(false);
             conversationViewRootAttributes = new HashMap<String, Map>();
             seamFilter = createSeamFilter();
            
             for (ELResolver elResolver : getELResolvers())
             {
             application.addELResolver(elResolver);
             }
            
             }


            I mean, it looks like there should be done a lot of things to use tests in working application for testing deployment and web server compatibility.

            Am I right or there is more simple way?

            • 3. Re: Running SeamTest-based tests inside an applicatoin serve
              Pete Muir Master

              So you'll need to override init() :) Let us know how you get on. This could be of interest to others. You might also want to look at something like Selenium for testing inside an app server.

              • 4. Re: Running SeamTest-based tests inside an applicatoin serve
                Dmitriy Lapko Newbie

                Yes, I managed to run SeamTests inside application server. I create TestNG instance, set the list of tests and call method run with overwritten empty startJBossEmbededdedIfNecessary(because I'm using Tomcat). And to omit previous posted error I just start TestNG in a new Thread, so all Seam's ThreadLocal variables are new and are not overwritten by newly started Seam Framework instance. Works pretty good :)

                Results of tests I show dynamically on a page by a:poll tag. Clients are impressed :)