Package com.google.mockwebserver

Examples of com.google.mockwebserver.MockWebServer.takeRequest()


         RecordedRequest authRequest = server.takeRequest();
         assertEquals(authRequest.getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(new String(authRequest.getBody()), authRequestBody);
         assertEquals(authRequest.getHeader("Content-Length"), String.valueOf(authRequestBody.length()));

         RecordedRequest part1 = server.takeRequest();
         assertEquals(part1.getRequestLine(), "PUT /container/foo/1 HTTP/1.1");
         assertEquals(part1.getHeader("X-Auth-Token"), token);
         assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part1.getBody()), "01234567");
View Full Code Here


         assertEquals(part1.getRequestLine(), "PUT /container/foo/1 HTTP/1.1");
         assertEquals(part1.getHeader("X-Auth-Token"), token);
         assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part1.getBody()), "01234567");

         RecordedRequest part2 = server.takeRequest();
         assertEquals(part2.getRequestLine(), "PUT /container/foo/2 HTTP/1.1");
         assertEquals(part2.getHeader("X-Auth-Token"), token);
         assertEquals(part2.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part2.getBody()), "89abcdef");
View Full Code Here

         assertEquals(part2.getRequestLine(), "PUT /container/foo/2 HTTP/1.1");
         assertEquals(part2.getHeader("X-Auth-Token"), token);
         assertEquals(part2.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part2.getBody()), "89abcdef");

         RecordedRequest manifest = server.takeRequest();
         assertEquals(manifest.getRequestLine(), "PUT /container/foo HTTP/1.1");
         assertEquals(manifest.getHeader("X-Auth-Token"), token);
         assertEquals(manifest.getHeader("Content-Length"), "0");

         server.shutdown();
View Full Code Here

      nada.getMetadata().setKey("object");
      nada.setPayload(new byte[] {});

      assertEquals(client.putObject("bucket", nada), "ABCDEF");

      RecordedRequest request = server.takeRequest();
      assertEquals(request.getRequestLine(), "PUT /bucket/object HTTP/1.1");
      assertEquals(request.getHeaders(CONTENT_LENGTH), ImmutableList.of("0"));
      // will fail unless -Dsun.net.http.allowRestrictedHeaders=true is set
      assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));
      server.shutdown();
View Full Code Here

      fileInDir.getMetadata().setKey("someDir/fileName");
      fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });

      assertEquals(client.putObject("bucket", fileInDir), "ABCDEF");

      RecordedRequest request = server.takeRequest();
      assertEquals(request.getRequestLine(), "PUT /bucket/someDir/fileName HTTP/1.1");
      // will fail unless -Dsun.net.http.allowRestrictedHeaders=true is set
      assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));

      server.shutdown();
View Full Code Here

      Response response = api.codecPost("request data");
      assertEquals(Util.toString(response.body().asReader()), "response data");
    } finally {
      server.shutdown();
      assertEquals(server.getRequestCount(), 1);
      assertEquals(server.takeRequest().getUtf8Body(), "request data");
    }
  }

  @Test public void testOverrideEncoder() throws Exception {
    MockWebServer server = new MockWebServer();
View Full Code Here

      TestInterface api = Feign.builder().encoder(encoder).target(TestInterface.class, url);
      api.encodedPost(Arrays.asList("This", "is", "my", "request"));
    } finally {
      server.shutdown();
      assertEquals(server.getRequestCount(), 1);
      assertEquals(server.takeRequest().getUtf8Body(), "[This, is, my, request]");
    }
  }

  @Test public void testOverrideDecoder() throws Exception {
    MockWebServer server = new MockWebServer();
View Full Code Here

      Response response = api.codecPost("request data");
      assertEquals(Util.toString(response.body().asReader()), "response data");
    } finally {
      server.shutdown();
      assertEquals(server.getRequestCount(), 1);
      RecordedRequest request = server.takeRequest();
      assertEquals(request.getUtf8Body(), "request data");
      assertEquals(request.getHeader("Content-Type"), "text/plain");
    }
  }
View Full Code Here

      assertEquals(Util.toString(response.body().asReader()), "response data");
      assertEquals(callCount.get(), 1);
    } finally {
      server.shutdown();
      assertEquals(server.getRequestCount(), 1);
      RecordedRequest request = server.takeRequest();
      assertEquals(request.getUtf8Body(), "request data");
    }
  }
}
View Full Code Here

      assertEquals(messages.size(), expectedMessages.size());
      for (int i = 0; i < messages.size(); i++) {
        assertTrue(messages.get(i).matches(expectedMessages.get(i)), messages.get(i));
      }

      assertEquals(new String(server.takeRequest().getBody(), UTF_8),
          "{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
    } finally {
      server.shutdown();
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.