1 Reply Latest reply on Dec 4, 2015 11:32 AM by Luciano Molinari

    Starting container in new Thread (manual mode)

    naviator Newbie

      Hey,

       

      I was toying around with Arq+JUnit and manual starting of containers. I need to start container in a new Thread. Actual code:

       

      @RunWith(Arquillian.class)
      public class StartInThreadTest {
      
              @ArquillianResource
              ContainerController controller;
      
                @Deployment(testable = true)
                public static JavaArchive deploy() {
                          return ShrinkWrap.create(JavaArchive.class);
                }
      
                @Test
                public void startWithoutThread() {
                      // runs OK
                          controller.start("server1");
                          controller.stop("server1");
                }
      
              @Test
                public void startInThread() throws InterruptedException {
                          Thread thr = new Thread(new ContainerRunnable(controller));
                          thr.start(); //throws an exception
                          thr.join(30000);
                }
      }
      
      class ContainerRunnable implements Runnable {
      
                private ContainerController controller;
      
                public ContainerRunnable(ContainerController controller) {
                          this.controller = controller;
                }
      
             @Override
                public void run() {
                          controller.start("server1");
                }
      }
      

       

      However, this throws exception:

      Exception in thread "Thread-5" java.lang.IllegalArgumentException: No deployment scenario in context
                at org.jboss.arquillian.container.test.impl.client.container.ClientContainerController.start(ClientContainerController.java:68)
      

       

      Possibly related - when trying to run an Arquillian test with @Test(timeout=SOMEINT), it fails immediatelly:

      @RunWith(Arquillian.class)
      public class SomeTest {
      
        @Deployment
                public static JavaArchive deploy() {
                          return ShrinkWrap.create(JavaArchive.class);
                }
      
                @Test(timeout = 30000)
                public void anyTest() throws InterruptedException {
                          Thread.sleep(4000); // represents arbitrary code
                }
      }
      

       

      Is there some restriction concerning Arq and threads?