Package org.jclouds.http

Examples of org.jclouds.http.HttpRequest$ConcreteBuilder


      assertEquals(Strings2.toStringAndClose(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").getAsStream("fcc451d0-f6e4-4824-ad8f-70ec12326d07")),
               "foo");
   }

   public void testGetAsStreamWhenReponseIs404IsNull() throws Exception {
      HttpRequest get = HttpRequest.builder().method("GET")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images/fcc451d0-f6e4-4824-ad8f-70ec12326d07")
            .addHeader("X-Auth-Token", authToken).build();


      HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
View Full Code Here


      assertNull(apiWhenNoExist.getImageApiForZone("az-1.region-a.geo-1").getAsStream("fcc451d0-f6e4-4824-ad8f-70ec12326d07"));
   }

   public void testCreateWhenResponseIs2xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("POST")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images")
            .addHeader("x-image-meta-name", "test")
            .addHeader("Accept", MediaType.APPLICATION_JSON)
            .addHeader("X-Auth-Token", authToken)
            .payload(payloadFromStringWithContentType("somedata", MediaType.APPLICATION_OCTET_STREAM)).build();
View Full Code Here

            new ParseImageDetailsTest().expected());
   }

   @Test(expectedExceptions = AuthorizationException.class)
   public void testCreateWhenResponseIs4xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("POST")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images")
            .addHeader("x-image-meta-name", "test")
            .addHeader("Accept", MediaType.APPLICATION_JSON)
            .addHeader("X-Auth-Token", authToken)
            .payload(payloadFromStringWithContentType("somedata", MediaType.APPLICATION_OCTET_STREAM)).build();
View Full Code Here

      apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").create("test", new StringPayload("somedata"));
   }

   public void testReserveWhenResponseIs2xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("POST")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images")
            .addHeader("x-image-meta-name", "test")
            .addHeader("Accept", MediaType.APPLICATION_JSON)
            .addHeader("X-Auth-Token", authToken).build();
View Full Code Here

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").reserve("test"), new ParseImageDetailsTest().expected());
   }

   @Test(expectedExceptions = AuthorizationException.class)
   public void testReserveWhenResponseIs4xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("POST")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images")
            .addHeader("x-image-meta-name", "test")
            .addHeader("Accept", MediaType.APPLICATION_JSON)
            .addHeader("X-Auth-Token", authToken).build();
View Full Code Here

      apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").reserve("test");
   }
  
   public void testUpdateMetadataWhenResponseIs2xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("PUT")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images/fcc451d0-f6e4-4824-ad8f-70ec12326d07")
            .headers(
                  ImmutableMultimap.<String, String>builder()
                        .put("Accept", MediaType.APPLICATION_JSON)
                        .put("X-Image-Meta-Name", "newname")
View Full Code Here

               new ParseImageDetailsTest().expected());
   }

   @Test(expectedExceptions = ResourceNotFoundException.class)
   public void testUpdateMetadataWhenResponseIs4xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("PUT")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images/fcc451d0-f6e4-4824-ad8f-70ec12326d07")
            .headers(
                  ImmutableMultimap.<String, String>builder()
                        .put("Accept", MediaType.APPLICATION_JSON)
                        .put("X-Image-Meta-Name", "newname")
View Full Code Here

                  UpdateImageOptions.Builder.name("newname"),
                  UpdateImageOptions.Builder.isPublic(true));
   }

   public void testUpdateImageWhenResponseIs2xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("PUT")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images/fcc451d0-f6e4-4824-ad8f-70ec12326d07")
            .addHeader("Accept", MediaType.APPLICATION_JSON)
            .addHeader("X-Auth-Token", authToken)
            .payload(payloadFromStringWithContentType("somenewdata", MediaType.APPLICATION_OCTET_STREAM))
            .build();
View Full Code Here

      assertEquals(apiWhenExist.getImageApiForZone("az-1.region-a.geo-1").upload("fcc451d0-f6e4-4824-ad8f-70ec12326d07",
            new StringPayload("somenewdata")), new ParseImageDetailsTest().expected());
   }

   public void testUpdateNameAndImageWhenResponseIs2xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("PUT")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images/fcc451d0-f6e4-4824-ad8f-70ec12326d07")
            .headers(
                  ImmutableMultimap.<String, String>builder()
                        .put("Accept", MediaType.APPLICATION_JSON)
                        .put("X-Image-Meta-Name", "anothernewname")
View Full Code Here

            new StringPayload("somenewdata"), UpdateImageOptions.Builder.name("anothernewname")), new ParseImageDetailsTest().expected());
   }

   @Test(expectedExceptions = AuthorizationException.class)
   public void testUpdateNameAndImageWhenResponseIs4xx() throws Exception {
      HttpRequest get = HttpRequest.builder().method("PUT")
            .endpoint("https://glance.jclouds.org:9292/v1.0/images/fcc451d0-f6e4-4824-ad8f-70ec12326d07")
            .headers(
                  ImmutableMultimap.<String, String>builder()
                        .put("Accept", MediaType.APPLICATION_JSON)
                        .put("X-Image-Meta-Name", "anothernewname")
View Full Code Here

TOP

Related Classes of org.jclouds.http.HttpRequest$ConcreteBuilder

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.