1 Reply Latest reply on Apr 27, 2015 3:54 AM by lfryc

    Filter test using arquillian-warp

    kaaruna

      Hello

       

      I am new to the Arquillian product. I have a requirement to test a filter. I wrote a test (using TomEE embedded container)  to use Warp.initiate(new Activity(....)).inspect(new Inspection() ...)

      which uses @BeforeServlet and @AfterServlet.

       

      But, I am facing issues with the deployment itself.

      The test fails with

      java.io.EOFException

        at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2328)

        at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2797)

        at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:802)

        at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)

        at org.jboss.arquillian.warp.impl.client.commandBus.CommandBusOnClient.execute(CommandBusOnClient.java:223)

        at org.jboss.arquillian.warp.impl.client.commandBus.CommandBusOnClient.access$000(CommandBusOnClient.java:65)

        at org.jboss.arquillian.warp.impl.client.commandBus.CommandBusOnClient$1.run(CommandBusOnClient.java:112)

        at java.util.TimerThread.mainLoop(Timer.java:555)

        at java.util.TimerThread.run(Timer.java:505)

       

      The timer task runs execute without a requestPayload causing this exception to be thrown. Please help me resolve this, I'm stuck at this point.

      My test case :

       

       

      @WarpTest

      @RunAsClient

      public class TestDisabledRulesTest extends Arquillian {

       

      @Drone

          WebDriver browser;

       

          @ArquillianResource

          URL contextPath;

       

          @Deployment

          public static WebArchive createDeployment() {

       

          WebArchive war = ShrinkWrap.create(WebArchive.class, "waf-test.war").

              addClasses(SimpleServlet.class, WAFFilter.class, ChainedFilter.class, RuleSetProducer.class)

              .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

              System.out.println(war.toString(true));

              return war;

          }

       

          @Test

          public void test() {

       

              Warp.initiate(new Activity() {

                      public void perform() {

                      String url = contextPath.toExternalForm() + "/SimpleServlet";

                      browser.navigate().to(url);

                      }

                  }).inspect(new Inspection() {

                      private static final long serialVersionUID = 1L;

       

                      @ArquillianResource

                      HttpServletRequest request;

       

                      @ArquillianResource

                      HttpServletResponse response;

       

                      @BeforeServlet

                      public void beforeServlet() {

       

                          System.out.println("Before Servlet!");

       

                      }

       

                      @AfterServlet

                      public void afterServlet() {

       

                          System.out.println("After Servlet!");

                      }

                  });

          }

       

      }