Examples of MockResponse


Examples of com.squareup.okhttp.mockwebserver.MockResponse

   }
  
   private static final Map<String, String> metadata = ImmutableMap.of("ApiName", "swift", "ApiVersion", "v1.1");

   public static MockResponse objectResponse() {
      return new MockResponse() //
            .addHeader("Last-Modified", "Fri, 12 Jun 2010 13:40:18 GMT") //
            .addHeader("ETag", "8a964ee2a5e88be344f36c22562a6486") //
            // TODO: MWS doesn't allow you to return content length w/o content
            // on HEAD!
            .setBody("ABCD".getBytes(US_ASCII)) //
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {

   /** upper-cases first char, and lower-cases rest!! **/
   public void getKnowingServerMessesWithMetadataKeyCaseFormat() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(accountResponse() //
            // note silly casing
            .addHeader("X-Account-Meta-Apiname", "swift") //
            .addHeader("X-Account-Meta-Apiversion", "v1.1")));

View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

      }
   }

   public void updateMetadata() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(accountResponse() //
            .addHeader("X-Account-Meta-ApiName", "swift") //
            .addHeader("X-Account-Meta-ApiVersion", "v1.1")));

      try {
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

      }
   }

   public void updateTemporaryUrlKey() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(accountResponse()));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.accountApiInRegion("DFW").updateTemporaryUrlKey("foobar"));
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

      }
   }

   public void deleteMetadata() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(accountResponse()));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.accountApiInRegion("DFW").deleteMetadata(metadata));
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

   }

   private static final Map<String, String> metadata = ImmutableMap.of("ApiName", "swift", "ApiVersion", "v1.1");

   public static MockResponse accountResponse() {
      return new MockResponse() //
            .addHeader("X-Account-Container-Count", "3") //
            .addHeader("X-Account-Object-Count", "42") //
            .addHeader("X-Account-Bytes-Used", "323479");
   }
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

      TemporaryUrlSigner.checkApiEvery(null, 10000);
   }

   public void whenAccountApiHasKey() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(accountResponse().addHeader("X-Account-Meta-Temp-URL-Key", "mykey")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         String signature = TemporaryUrlSigner.checkApiEvery(api.accountApiInRegion("DFW"), 10000)
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

   }

   @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = ".*returned a null temporaryUrlKey!")
   public void whenAccountApiDoesntHaveKey() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(accountResponse()));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         TemporaryUrlSigner.checkApiEvery(api.accountApiInRegion("DFW"), 10000)
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

@Test
public class StaticLargeObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {

   public void replaceManifest() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().addHeader(HttpHeaders.ETAG, "\"abcd\"")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertEquals(
               api.staticLargeObjectApiInRegionForContainer("DFW", "myContainer").replaceManifest(
View Full Code Here

Examples of com.squareup.okhttp.mockwebserver.MockResponse

      }
   }

   public void delete() throws Exception {
      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         api.staticLargeObjectApiInRegionForContainer("DFW", "myContainer").delete("myObject");
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.