Package com.squareup.okhttp.mockwebserver

Examples of com.squareup.okhttp.mockwebserver.MockWebServer.play()


      AtomicReference<URL> url = setURLReplacingDispatcher(server);
      server.enqueue(new MockResponse().setResponseCode(200).setBody(authResponse));
      server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "a00"));
      server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "b00"));
      server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "fff"));
      server.play();
      url.set(server.getUrl("/"));

      byte[] bytes = "0123456789abcdef".getBytes(Charsets.US_ASCII);
      int partSize = bytes.length / 2;
      SequentialMultipartUploadStrategy api = mockSequentialMultipartUploadStrategy(url.get().toString(), partSize);
View Full Code Here


    * Creates a {@link MockWebServer} that uses the
    * {@link GlobalChecksRequestDispatcher}.
    */
   protected static MockWebServer mockWebServer(MockResponse... responses) throws IOException {
      MockWebServer server = new MockWebServer();
      server.play();
      server.setDispatcher(new GlobalChecksRequestDispatcher());
      for (MockResponse response : responses) {
         server.enqueue(response);
      }
      return server;
View Full Code Here

   /**
    * Creates a {@link MockWebServer} that uses the given {@link Dispatcher}.
    */
   protected static MockWebServer mockWebServer(Dispatcher dispatcher) throws IOException {
      MockWebServer server = new MockWebServer();
      server.play();
      server.setDispatcher(dispatcher);
      return server;
   }

   /**
 
View Full Code Here

      return api(uri, provider, new Properties());
   }

   public static MockWebServer mockOpenStackServer() throws IOException {
      MockWebServer server = new MockWebServer();
      server.play();
      URL url = server.getUrl("");
      server.setDispatcher(getURLReplacingQueueDispatcher(url));
      return server;
   }
View Full Code Here

      server.setDispatcher(new Dispatcher() {
         @Override public MockResponse dispatch(RecordedRequest recordedRequest) {
            return new MockResponse();
         }
      });
      server.play();

      HttpClient client =  api(HttpClient.class, server.getUrl("/").toString());

      // Make a fake payload that has no data, but says there's a lot!
      Payload fakePayload = new StringPayload("");
View Full Code Here

            .buildApi(HPCloudObjectStorageApi.class);
   }

   public static MockWebServer mockWebServer() throws IOException {
      MockWebServer server = new MockWebServer();
      server.play();
      URL url = server.getUrl("");
      server.setDispatcher(getURLReplacingQueueDispatcher(url));
      return server;
   }
View Full Code Here

   }

   public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().addHeader(ETAG, "ABCDEF"));
      server.play();

      S3Client client = getS3Client(server.getUrl("/"));
      S3Object nada = client.newS3Object();
      nada.getMetadata().setKey("object");
      nada.setPayload(new byte[] {});
View Full Code Here

   }

   public void testDirectorySeparator() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
      server.play();

      S3Client client = getS3Client(server.getUrl("/"));
      S3Object fileInDir = client.newS3Object();
      fileInDir.getMetadata().setKey("someDir/fileName");
      fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });
View Full Code Here

   public void testMPUAbortsOnProblem() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(200).setBody("<UploadId>upload-id</UploadId>"));
      server.enqueue(new MockResponse().setResponseCode(400));
      server.enqueue(new MockResponse().setResponseCode(200));
      server.play();

      byte[] bytes = "0123456789abcdef".getBytes(Charsets.US_ASCII);
      int partSize = bytes.length / 2;

      SequentialMultipartUploadStrategy api = mockSequentialMultipartUploadStrategy(server.getUrl("/").toString(),
View Full Code Here

      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(200).setBody("<UploadId>upload-id</UploadId>"));
      server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "a00"));
      server.enqueue(new MockResponse().setResponseCode(200).addHeader("ETag", "b00"));
      server.enqueue(new MockResponse().setResponseCode(200).setBody("<ETag>fff</ETag>"));
      server.play();

      byte[] bytes = "0123456789abcdef".getBytes(Charsets.US_ASCII);
      int partSize = bytes.length / 2;

      SequentialMultipartUploadStrategy api = mockSequentialMultipartUploadStrategy(server.getUrl("/").toString(),
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.