0 Replies Latest reply on Aug 3, 2013 10:53 AM by Adrian Cole

    black box testing with mocked backends

    Adrian Cole Newbie

      Hi, all.

       

      I have an application at netflix I'm testing with arquillian using @RunAsClient.  The web app I'm testing makes outgoing calls that correspond with the rest calls I issue via the @ArquillianResource.  What I'd like to do is setup a MockWebServer for each test method, which populates backend http expectations for each testcase.   I suspect there's a better approach, so ideas welcome!

       

      ex.

       

          @ArquillianResource

          protected URL deploymentUrl;


          @Test

          public void getNetworkStatusImpliesBackendCall() throws Exception {

              MockWebServer backend = new MockWebServer();

              backend.enqueue(new MockResponse().setResponseCode(200).setBody(getNeustarNetworkStatusResponse));

              backend.play();

       

              // glitch here.. how do I send this to the web app cleanly..

              // particularly as the object will be different for each test

              backend.getUrl("")

       

       

              try {

                  assertEquals(check(deploymentUrl), NetworkStatus.GOOD);

       

                  assertEquals(new String(server.takeRequest().getBody()), getNeustarNetworkStatus);

              } finally {

                  server.shutdown();

              }

          }