Package com.google.mockwebserver

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


      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

            .contentDisposition("inline; filename=foo.mp4")
            .contentType(MediaType.MP4_VIDEO.toString())
            .build()), "fff");
      } finally {

         RecordedRequest initiate = server.takeRequest();
         assertEquals(initiate.getRequestLine(), "POST /container/foo?uploads HTTP/1.1");
         assertEquals(initiate.getHeader("Content-Length"), "0");
         assertEquals(initiate.getHeader(HttpHeaders.CONTENT_TYPE), MediaType.MP4_VIDEO.toString());
         assertEquals(initiate.getHeader(HttpHeaders.CONTENT_DISPOSITION), "inline; filename=foo.mp4");
View Full Code Here

         assertEquals(initiate.getRequestLine(), "POST /container/foo?uploads HTTP/1.1");
         assertEquals(initiate.getHeader("Content-Length"), "0");
         assertEquals(initiate.getHeader(HttpHeaders.CONTENT_TYPE), MediaType.MP4_VIDEO.toString());
         assertEquals(initiate.getHeader(HttpHeaders.CONTENT_DISPOSITION), "inline; filename=foo.mp4");

         RecordedRequest part1 = server.takeRequest();
         assertEquals(part1.getRequestLine(), "PUT /container/foo?partNumber=1&uploadId=upload-id HTTP/1.1");
         assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part1.getBody()), "01234567");

         RecordedRequest part2 = server.takeRequest();
View Full Code Here

         RecordedRequest part1 = server.takeRequest();
         assertEquals(part1.getRequestLine(), "PUT /container/foo?partNumber=1&uploadId=upload-id HTTP/1.1");
         assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part1.getBody()), "01234567");

         RecordedRequest part2 = server.takeRequest();
         assertEquals(part2.getRequestLine(), "PUT /container/foo?partNumber=2&uploadId=upload-id HTTP/1.1");
         assertEquals(part2.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part2.getBody()), "89abcdef");

         RecordedRequest manifest = server.takeRequest();
View Full Code Here

         RecordedRequest part2 = server.takeRequest();
         assertEquals(part2.getRequestLine(), "PUT /container/foo?partNumber=2&uploadId=upload-id HTTP/1.1");
         assertEquals(part2.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part2.getBody()), "89abcdef");

         RecordedRequest manifest = server.takeRequest();
         assertEquals(manifest.getRequestLine(), "POST /container/foo?uploadId=upload-id HTTP/1.1");
         assertEquals(manifest.getHeader("Content-Length"), "161");
         assertEquals(
               new String(manifest.getBody()),
               "<CompleteMultipartUpload><Part><PartNumber>1</PartNumber><ETag>a00</ETag></Part><Part><PartNumber>2</PartNumber><ETag>b00</ETag></Part></CompleteMultipartUpload>");
View Full Code Here

      try {
         assertEquals(api.execute("container", new BlobBuilderImpl().name("foo").payload(bytes).build()), "fff");
      } finally {

         RecordedRequest initiate = server.takeRequest();
         assertEquals(initiate.getRequestLine(), "POST /container/foo?uploads HTTP/1.1");
         assertEquals(initiate.getHeader("Content-Length"), "0");

         RecordedRequest part1 = server.takeRequest();
         assertEquals(part1.getRequestLine(), "PUT /container/foo?partNumber=1&uploadId=upload-id HTTP/1.1");
View Full Code Here

         RecordedRequest initiate = server.takeRequest();
         assertEquals(initiate.getRequestLine(), "POST /container/foo?uploads HTTP/1.1");
         assertEquals(initiate.getHeader("Content-Length"), "0");

         RecordedRequest part1 = server.takeRequest();
         assertEquals(part1.getRequestLine(), "PUT /container/foo?partNumber=1&uploadId=upload-id HTTP/1.1");
         assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part1.getBody()), "01234567");

         RecordedRequest abort = server.takeRequest();
View Full Code Here

         RecordedRequest part1 = server.takeRequest();
         assertEquals(part1.getRequestLine(), "PUT /container/foo?partNumber=1&uploadId=upload-id HTTP/1.1");
         assertEquals(part1.getHeader("Content-Length"), String.valueOf(partSize));
         assertEquals(new String(part1.getBody()), "01234567");

         RecordedRequest abort = server.takeRequest();
         assertEquals(abort.getRequestLine(), "DELETE /container/foo?uploadId=upload-id HTTP/1.1");

         server.shutdown();
      }
   }
View Full Code Here

      TestInterface api = Feign.create(TestInterface.class, "http://" + client, new TestInterface.Module(), new RibbonModule());

      api.getWithQueryParameters(queryStringValue);

      final String recordedRequestLine = server.takeRequest().getRequestLine();

      assertEquals(recordedRequestLine, expectedRequestLine);
    } finally {
      server.shutdown();
      getConfigInstance().clearProperty(serverListKey);
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.