3 Replies Latest reply on Apr 24, 2015 8:12 AM by Thomas Peeters

    Running arquillian tests on remote JBoss server

    andrei groza Newbie

      Hello to all,

       

      I am currently working at a java based project. We use arquillian for testing the functionalities.

      I want to run the arquillian tests on a remote JBoss server, but I got to following error:

       

      java.lang.IllegalStateException: Error launching test com.uniqagroup.udt.model.CopyOfTestEntities public void com.uniqagroup.udt.model.CopyOfTestEntities.testEntities()

          at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:126)

          at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)

          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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)

          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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)

          at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)

          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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

          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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

          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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

          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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

          at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)

          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

          at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

          at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

          at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Caused by: java.lang.IllegalStateException: Error launching request at http://0.0.0.0:8080/udt_resource_test/ArquillianServletRunner?outputMode=serializedObject&className=com.uniqagroup.udt.model.CopyOfTestEntities&methodName=testEntities. No result returned

          at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:162)

          at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:122)

          ... 75 more

       

       

       

      The following configuration is done:

       

      1. arquillian.xml

      <arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="

              http://jboss.org/schema/arquillian

              http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

       

          <engine>

              <property name="deploymentExportPath">target/deployments</property>

          </engine>

          <defaultProtocol type="Servlet 3.0" />

          <extension qualifier="jacoco">

              <!-- <property name="excludes">*.*</property> -->

              <property name="includes">com.uniqagroup.udt.*</property>

          </extension>

         

          <container qualifier="jboss7" default="true">

              <configuration>

                  <property name="managementAddress">***</property>

                  <property name="managementPort">9999</property>

                  <property name="username">***</property>

                  <property name="password">***</property>

              </configuration>

          </container>

      </arquillian>

       

      2. Testing class looks like this:

      package com.uniqagroup.udt.model;

       

      import java.sql.Time;

      import java.util.ArrayList;

      import java.util.Arrays;

      import java.util.Calendar;

      import java.util.Date;

      import java.util.List;

       

      import javax.inject.Inject;

      import javax.persistence.EntityManager;

      import javax.persistence.PersistenceContext;

      import javax.transaction.UserTransaction;

       

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.Archive;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.junit.After;

      import org.junit.Assert;

      import org.junit.Before;

      import org.junit.Test;

      import org.junit.runner.RunWith;

       

      import com.uniqagroup.udt.DBUtils;

       

      @RunWith(Arquillian.class)

      public class CopyOfTestEntities {

       

          private static final String[] APPLICATION_NAMES = { "uniqa-udt-test1", "uniqa-udt-test2", "uniqa-udt-test3" };

       

          private static final String[] PLATFORMS = { "JBOSS", "DMS", "SQL" };

       

          private static final String[] ENVS = { "TRAINING", "LOAD", "TRANSFER", "TEST", "MAINTENACE", "PRODUCTION" };

       

          private static Time DEPL_START_TIME;

       

          private static Date EXEC_FINISH_DATE;

       

          private static Date EXEC_START_DATE;

       

          private static Date DEPL_SCHEDULED_DATE;

       

          private static Date APROVED_AT_DATE;

       

          static {

              Calendar calendar = Calendar.getInstance();

              APROVED_AT_DATE = calendar.getTime();

              calendar.set(calendar.get(Calendar.YEAR) + 1, 1, 1, 15, 0);

              DEPL_SCHEDULED_DATE = calendar.getTime();

              calendar.set(1970, 0, 1, 15, 0, 0);

              DEPL_START_TIME = new Time(calendar.getTimeInMillis());

              calendar.set(2013, 1, 1, 15, 0, 0);

              EXEC_START_DATE = calendar.getTime();

              calendar.set(2013, 2, 1, 15, 0, 0);

              EXEC_FINISH_DATE = calendar.getTime();

          }

       

          @Test

          public void testHello() {

              System.out.println("hello");

          }

       

          @org.jboss.arquillian.container.test.api.Deployment

          public static Archive<?> createDeployment() {

              WebArchive war = ShrinkWrap.create(WebArchive.class, "udt_resource_test.war").addPackage(Application.class.getPackage())

                      .addClass(DBUtils.class).addAsResource("test-persistence.xml", "META-INF/persistence.xml")

                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml").addAsWebInfResource("jbossas-ds.xml", "jbossas-ds.xml")

                      .addAsWebInfResource("jboss-web-ds.xml", "jboss-web.xml");

              return war;

          }

       

          @PersistenceContext(unitName = "udt_test")

          EntityManager em;

       

          @Inject

          UserTransaction utx;

       

          @Before

          public void preparePersistenceTest() throws Exception {

              clearData();

              insertData();

              startTransaction();

          }

       

          @Test

          public void testEntities() {

              assertPlatforms();

          }

       

          private void assertPlatforms() {

              List<Platform> platforms = em.createQuery("select p from t_platform p", Platform.class).getResultList();

              Assert.assertEquals(PLATFORMS.length, platforms.size());

              for (Platform platform : platforms) {

                  Assert.assertTrue(Arrays.asList(PLATFORMS).contains(platform.getName()));

                  List<String> envNames = new ArrayList<String>();

                  for (Environment env : platform.getEnvironments()) {

                      envNames.add(env.getName());

                  }

                  Assert.assertEquals(Arrays.asList(ENVS), envNames);

              }

          }

       

          private void startTransaction() throws Exception {

              utx.begin();

              em.joinTransaction();

          }

       

          @After

          public void commitTransaction() throws Exception {

              utx.commit();

          }

       

          private void clearData() throws Exception {

              utx.begin();

              em.joinTransaction();

              DBUtils.cleanUp(em);

              utx.commit();

          }

       

          private void insertData() throws Exception {

              insertPlatforms();

              em.clear();

          }

       

          private void insertPlatforms() throws Exception {

              utx.begin();

              populatePlatformsAndEnvironments();

              utx.commit();

          }

       

          private void populatePlatformsAndEnvironments() {

              int i = 0;

              List<Environment> envs = new ArrayList<Environment>();

              for (String name : ENVS) {

                  i++;

                  Environment env = new Environment();

                  env.setName(name);

                  env.setOrder(i);

                  em.persist(env);

                  envs.add(env);

              }

              for (String name : PLATFORMS) {

                  Platform platform = new Platform();

                  platform.setName(name);

                  platform.getEnvironments().addAll(envs);

                  em.persist(platform);

              }

       

          }

       

      }

       

      3. pom.xml (relevant part)

      <dependency>

                  <groupId>org.jboss.arquillian.junit</groupId>

                  <artifactId>arquillian-junit-container</artifactId>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.arquillian.protocol</groupId>

                  <artifactId>arquillian-protocol-servlet</artifactId>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.as</groupId>

                  <artifactId>jboss-as-arquillian-container-remote</artifactId>

                  <version>7.1.3.Final</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.arquillian.extension</groupId>

                  <artifactId>arquillian-jacoco</artifactId>

                  <version>1.0.0.Alpha5</version>

                  <scope>test</scope>

              </dependency>

       

      The following technologies are used:

      JBoss EAP 6.0.1, arquillian-bom 1.0.3.Final.

       

      When I run on my local JBoss server, the war is deployed on the server and the tests run ok. The problem occurs only when I try to reach a remote server.

       

      I don't know which could be the problem:

      -the 0.0.0.0 IP

      -a misconfiguration from client side

      -a misconfiguration in server side

       

      I am stuck at this point for 3 days, please help me if you have an idea about this issue.

       

      Thank you.

        • 1. Re: Running arquillian tests on remote JBoss server
          Aslak Knutsen Master

          The info used to create the URL it can't find is coming from the Container itself.

           

          The client side only defines where to find the ManagementAddress/Port, the rest should be picked up via the server mgm apis.

           

          If you can't change the server configuration, you could configure the Protocol specifically to override what comes from the server.

           

          
          <?xml version="1.0" encoding="UTF-8"?>
          <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian
                                   http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
          
          
              <defaultProtocol type="Servlet 3.0"/>
          
          
              <container qualifier="JBoss" default="true">
                  <protocol type="Servlet 3.0">
                      <property name="host">xxx</property>
                  </protocol>
              </container>
          </arquillian>
          
          
          
          • 2. Re: Running arquillian tests on remote JBoss server
            andrei groza Newbie

            I have tried this configuration too, still the same result. Do you have another idea?

            • 3. Re: Running arquillian tests on remote JBoss server
              Thomas Peeters Newbie
              <defaultProtocol type="Servlet 3.0">
                 <property name="host">xxx</property>
              </defaultProtocol>
              

               

              Outside of the 'container' definion, but of course inside the 'arquillian' block.

              This worked for me.  FYI