Package com.squareup.okhttp.mockwebserver

Examples of com.squareup.okhttp.mockwebserver.MockResponse


         files.add(content, "/file" + i);
      }
      byte[] tarGz = ByteStreams.toByteArray(files.as(TarGzExporter.class).exportAsInputStream());

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ExtractArchiveResponse response = api.bulkApiInRegion("DFW").extractArchive("myContainer",
               newByteArrayPayload(tarGz), "tar.gz");
View Full Code Here


         + "  {\"name\":\"test_container_2\", \"count\":1, \"bytes\":17}\n" //
         + "]";

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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ImmutableList<Container> containers = api.containerApiInRegion("DFW").listFirstPage().toList();
         assertEquals(containers, ImmutableList.of(//
View Full Code Here

      }
   }

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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ImmutableList<Container> containers = api.containerApiInRegion("DFW").listAt("test").toList();
         assertEquals(containers, ImmutableList.of(//
View Full Code Here

      }
   }

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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.containerApiInRegion("DFW").createIfAbsent("myContainer", CreateContainerOptions.NONE));
View Full Code Here

      }
   }

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

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

      }
   }

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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertFalse(api.containerApiInRegion("DFW").createIfAbsent("myContainer", CreateContainerOptions.NONE));
View Full Code Here

   }

   /** 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(containerResponse() //
            // note silly casing
            .addHeader("X-Container-Meta-Apiname", "swift") //
            .addHeader("X-Container-Meta-Apiversion", "v1.1")));

View Full Code Here

      }
   }

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

      try {
View Full Code Here

      }
   }

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

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

      }
   }

   public void deleteIfEmpty() 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");
         assertTrue(api.containerApiInRegion("DFW").deleteIfEmpty("myContainer"));
View Full Code Here

TOP

Related Classes of com.squareup.okhttp.mockwebserver.MockResponse

Copyright © 2018 www.massapicom. 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.