3 Replies Latest reply on Nov 18, 2011 12:10 PM by rzvikas

    Fundamental question about Arquillian

    vicky.sharma
      emI've recently started learning about Arquillian. Was following the Geting started tutorial, learned about "Container Varieties" that talks about Remote, Embedded and Managed containers.I'm bit confused about how Arqillian treats these different varieties.
      My question is: The Getting started tutorial first example (that has TemparatureConverter) uses JBoss AS 6 as Remote container.  What i understood is that my main application archive that contains the TemparatureConverter bean will be deployed in JBoss AS 6 (that is running in its own VM) and my Test class will run in a separate VM.
      I added some log messages to TemparatureConverter.java i.e. Bean class:

       

      public double convertToCelsius(double f) {

              System.out.println("@@@@@@@@@@Inside container: convertToCelsius");

              return ((f - 32) * 5 / 9);

          }

       

          public double convertToFarenheit(double c) {

              System.out.println("@@@@@@@@@@Inside container: convertToFarenheit");       

              return ((c * 9 / 5) + 32);

          }

       

      I also added some log messages to my Test class:

       

      @Test

          public void testConvertToCelsius() {

              System.out.println("@@@@@@@@@Inside Junit client");

              Assert.assertEquals(converter.convertToCelsius(32d), 0d);

              Assert.assertEquals(converter.convertToCelsius(212d), 100d);

          }

       

      Now I started JBoss AS and run the test cases through command line by typing: mvn test -Pjbossas-remote-6

       

      I was thinking that log messages that I added in Bean class will be printed on JBoss console, and the log messages that I added in my Test class will be printed on Maven console window, because these two things are running in separate VM.

       

      However that did not happen, and I saw all the log messages are getting printed on JBoss AS console.

       

      That means, my Test cases are running inside JBoss AS container along with the Bean class.

       

      If this is true, then where is remoteness here? I mean, both the test case and bean are running inside same JVM. This is similar to "embedded container" behaviour, isn't?

       

      I'm referring this explanation:

       

      a remote container resides in a separate JVM from the test runner; Arquillian binds to the container to deploy and undeploy the test archive and invokes tests via a remote protocol (typically HTTP)

       

      But in this case, it appears Arquillian is placing my Test cases along with Bean class in same JVM.

       

      Let me know, if my question is not clear?

        • 1. Re: Fundamental question about Arquillian
          aslak

          That is the basic concept of Testing IN Container. Your tests are running inside the container so it has acces to all the same resources your Application code has.

           

          The Remote part of a Container is just where the Container is. The Container is in a Remote JVM as appose to a Embedded Contrainer which will run in the same JVM. A Remote Container can be any where, local machine, a remote server etc. Embedded can only be on your local machine in the same JVM.

           

          If you want to test the remoteness of _your_ application, then Arquillian has a runmode call "as client". If you're on Alpha5, you can trigger a "as client" runmode by setting @Deployment.testable=false. Then your deployment is deployed to the Container, it being embedded or remote, but your TestCase will run in your local jvm. This way you can test e.g. Servlet/WebPages using HTMLUnit or Remote EJB calls etc..

          • 2. Re: Fundamental question about Arquillian
            vicky.sharma

            Yes. This clears things a lot. Thanks.

            • 3. Re: Fundamental question about Arquillian
              rzvikas

              hi guys THanks for nice explanation, I am facing an issue here..  I want my test to run in container JVM so that my test have acccess to injected resources like EJB etc... My log messages in my test are thowing at my local JVM console and my deployed bean method message on container JVM..

               

               

              What do I need to change to make my test run in the container JVM so that I do not get null for the deployed resources...