Package com.google.mockwebserver

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


    MockWebServer server1 = new MockWebServer();
    server1.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server1.play();
    MockWebServer server2 = new MockWebServer();
    server2.enqueue(new MockResponse().setBody("success!".getBytes(UTF_8)));
    server2.play();

    getConfigInstance().setProperty(serverListKey, hostAndPort(server1.getUrl("")) + "," + hostAndPort(server2.getUrl("")));

    try {
      LoadBalancingTarget<TestInterface> target = LoadBalancingTarget.create(TestInterface.class, "http://" + name);
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

   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

   @Test(expectedExceptions = JobStillRunningException.class, expectedExceptionsMessageRegExp = "This session already has a job running")
   public void test200OnFailureThrowsExceptionWithoutRetryWhenJobRunning() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(running));
      server.play();

      DynECTApi api = mockDynectApi(server.getUrl("/").toString());

      try {
         api.getZoneApi().list();
View Full Code Here

   public void test200OnFailureThrowsExceptionWithoutRetryWhenOperationBlocked() throws IOException,
         InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(taskBlocking));
      server.play();

      DynECTApi api = mockDynectApi(server.getUrl("/").toString());

      try {
         api.getZoneApi().list();
View Full Code Here

   @Test(expectedExceptions = TargetExistsException.class, expectedExceptionsMessageRegExp = "Name already exists")
   public void test200OnFailureThrowsExceptionWithoutRetryOnNameExists() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
      server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(targetExists));
      server.play();

      DynECTApi api = mockDynectApi(server.getUrl("/").toString());

      try {
         api.getZoneApi().list();
View Full Code Here

   String versionXML = "<SupportedVersions><VersionInfo><Version>0.8b-ext2.8</Version><LoginUrl>URLv0.8/login</LoginUrl></VersionInfo></SupportedVersions>";

   @Test
   public void testLoginSetsContentLength() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.play();
      server.setDispatcher(replaceURLWithLocalhostPort(server.getPort()));
      server.enqueue(new MockResponse().setResponseCode(200).setBody(versionXML));
      server.enqueue(new MockResponse().setResponseCode(200)
                                       .addHeader("x-vcloud-authorization", "cookie")
                                       .setBody("<OrgList />"));
View Full Code Here

      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

   public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().addHeader(ETAG, "ABCDEF"));
      // hangs on Java 7 without this additional response ?!?
      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

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.