6 Replies Latest reply on Sep 14, 2010 11:00 AM by aslak

    Playing With Arquillian Results

    andygibson

      I've been having a play with Arquillian for the last few days and thought I'd report back. I might have found some issues but I don't know how many are user error. Example configuration was pretty much taken from the docs.

       

      1. Getting build versions that work together correctly is a bit of a hurdle - doubly so when you aren't sure if everything is configured right in the first place.
      2. Getting the maven dependencies right can be a problem. The scaterring of Java EE 6 poms makes it a rather hodge podge affair since the java-ee bom seems to incompatible with Arquillian. I usually have to add the server runtime in eclipse to help out in the IDE. (This in turn causes odd errors in the eclipse plugins about being able to launch javaw.exe when I try and run the tests)
      3. So far I have only got Glassfish and JBoss embedded working fully with a database and running tests within CDI conversations.

       

      For JBoss Remote/Managed and Glassfish remote, I get the same error (so I wonder if it is a setup issue). I use the same conversation context management technique defined in http://ctpjava.blogspot.com/2010/08/test-drive-with-arquillian-and-cdi-part.html .Basically, using a junit @Rule to start and end the conversation if needed.  The conversation context creating code is also used in Seam 3 in a few places.

       

      When I try to fetch the conversation context like so :

       

      {code}conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();{code}

       

      I get a "Singleton is not set" error in the call to Container.instance() which in turn calls instance.get(). If I have a test that doesn't start/end the conversation and just uses request scoped CDI injection then everything is fine. Interestingly, now I'm starting to get it on the Glassfish embedded tests as well. It will probably go away if I twiddle with things enough.

       

      I do have a stand alone project to demonstrate this stuff if you think it is more than a config issue.

       

      Indcidentally, I think the first instinct is to go and try an embedded server for that "one click and you're running" isolated feel, however, it is slow and you lose that "one click and you're done" feel. I started with the embedded version but I would much rather have my remote server working because it is just much faster. While Glassfish typically starts in a second, the embdded server takes longer. It's almost like waiting for development server re-start (which is what it is really!), which is why I think remote testing will be more popular.

       

      Overall though, I love it, I think with this and JSFUnit you can have end to end testing of your java EE apps. Imagine being able to get a bug report and reproducing the whole thing in a test case (JSF presentation layer and all). Awesome.

       

      Cheers,

       

      Andy Gibson

        • 1. Re: Playing With Arquillian Results
          aslak

          If you can share the project that demonstrates the issues, I can have a look at it. A bit easier to see what is going on..

          • 2. Re: Playing With Arquillian Results
            andygibson

            Hey Aslak,

            I should have just attached it in the first place since you can add attachments to posts. You can get it from :

             

            http://www.andygibson.net/arqdemoapp.zip

             

            Its a bit rough around the edges, but its a simple case and it compiles. There is a jndi.properties in there, but it is renamed at the moment so it doesn't interfere with the Glassfish tests.

             

            Also, I fixed the issues I started getting with Glassfish embedded by just deleting the instanceRoot I was re-using. It must have gotten into a funky state.

             

            Cheers,

             

            Andy

            • 3. Re: Playing With Arquillian Results
              aslak

              The problem is that the @Rule is executed on both 'sides', both on the Client and Container side. This works fine with Embedded Containers because then the execution only has one side and is in the same vm, but with remote it is not.

               

              https://jira.jboss.org/browse/ARQ-286

              • 4. Re: Playing With Arquillian Results
                andygibson

                Hmmm, thanks Aslak for resolving that, Is there are document somewhere that describes the structure of how Arquillian works? My understanding was that everything was just shipped off to the server, executed and some result returned (and there was no client side).

                 

                So as a fix, don't use a @Rule and start and end conversations yourself manually?

                 

                That probably means that all the different configurations will work since it mostly worked without the conversation start/start which is causing a problem,

                 

                Thanks Again,

                 

                Cheers,

                 

                Andy

                • 5. Re: Playing With Arquillian Results
                  andygibson

                  Just to give you an update, I removed the @Rule stuff and start/ended the context manually and it works fine, I got the glassfish /jboss remote containers working with my simple test project with converstional scoped beans.

                   

                  Cheers,

                   

                  Andy

                  • 6. Re: Playing With Arquillian Results
                    aslak

                    There is a 'client' side in the sense that JUnit is executed from Eclipse/Maven etc, and when we hook into the JUnit lifecycle we reroute some of the calls over to the 'server' side to be executed there. Not all possible routes in JUnit are currently being rerouted.

                     

                    This gives you a somewhat picture of what is going on:  http://docs.jboss.org/arquillian/reference/latest/en-US/html_single/#extend