Examples of ImageApi


Examples of org.jclouds.digitalocean.features.ImageApi

   public void testAccessDenied() throws Exception {
      MockWebServer server = mockWebServer();
      server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json")));

      DigitalOceanApi api = api(server.getUrl("/"));
      ImageApi imageApi = api.getImageApi();

      try {
         imageApi.list();
         fail("Request should have failed");
      } catch (Exception ex) {
         assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException");
         assertEquals(ex.getMessage(), ACCESS_DENIED);
      } finally {
View Full Code Here

Examples of org.jclouds.digitalocean.features.ImageApi

   public void testNotFound() throws Exception {
      MockWebServer server = mockWebServer();
      server.enqueue(new MockResponse().setBody(payloadFromResource("/not-found.json")));

      DigitalOceanApi api = api(server.getUrl("/"));
      ImageApi imageApi = api.getImageApi();

      try {
         imageApi.list();
         fail("Request should have failed");
      } catch (Exception ex) {
         assertTrue(ex instanceof ResourceNotFoundException, "Exception should be a ResourceNotFoundException");
         assertEquals(ex.getMessage(), NOT_FOUND);
      } finally {
View Full Code Here

Examples of org.jclouds.digitalocean.features.ImageApi

      server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));
      // Response to be sent for the retried request
      server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));

      DigitalOceanApi api = api(server.getUrl("/"));
      ImageApi imageApi = api.getImageApi();

      try {
         imageApi.list();
         fail("Request should have failed after retrying");
      } catch (Exception ex) {
         assertTrue(ex instanceof HttpResponseException, "Exception should be an HttpResponseException");
         HttpResponseException exception = HttpResponseException.class.cast(ex);
         assertEquals(exception.getResponse().getStatusCode(), 500);
View Full Code Here

Examples of org.jclouds.digitalocean.features.ImageApi

   public void testAccessDenied() throws Exception {
      MockWebServer server = mockWebServer();
      server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json")));

      DigitalOceanApi api = api(server.getUrl("/"));
      ImageApi imageApi = api.getImageApi();

      try {
         imageApi.list();
         fail("Request should have failed");
      } catch (Exception ex) {
         assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException");
         assertEquals(ex.getMessage(), ACCESS_DENIED);
      } finally {
View Full Code Here

Examples of org.jclouds.digitalocean.features.ImageApi

   public void testNotFound() throws Exception {
      MockWebServer server = mockWebServer();
      server.enqueue(new MockResponse().setBody(payloadFromResource("/not-found.json")));

      DigitalOceanApi api = api(server.getUrl("/"));
      ImageApi imageApi = api.getImageApi();

      try {
         imageApi.list();
         fail("Request should have failed");
      } catch (Exception ex) {
         assertTrue(ex instanceof ResourceNotFoundException, "Exception should be a ResourceNotFoundException");
         assertEquals(ex.getMessage(), NOT_FOUND);
      } finally {
View Full Code Here

Examples of org.jclouds.digitalocean.features.ImageApi

      server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));
      // Response to be sent for the retried request
      server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));

      DigitalOceanApi api = api(server.getUrl("/"));
      ImageApi imageApi = api.getImageApi();

      try {
         imageApi.list();
         fail("Request should have failed after retrying");
      } catch (Exception ex) {
         assertTrue(ex instanceof HttpResponseException, "Exception should be an HttpResponseException");
         HttpResponseException exception = HttpResponseException.class.cast(ex);
         assertEquals(exception.getResponse().getStatusCode(), 500);
View Full Code Here

Examples of org.jclouds.googlecomputeengine.features.ImageApi

              .addHeader("Authorization", "Bearer " + TOKEN).build();

      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResource("/image_list_single_page.json")).build();

      ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
              TOKEN_RESPONSE, list, operationResponse).getImageApiForProject("myproject");

      PagedIterable<Image> images = imageApi.list();

      // expect one page
      assertSame(images.size(), 1);
      // with three images
      assertSame(images.concat().size(), 3);
View Full Code Here

Examples of org.jclouds.googlecomputeengine.features.ImageApi

      HttpResponse list3Response = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResource("/image_list_single_page.json")).build();


      ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
              TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response)
              .getImageApiForProject("myproject");

      PagedIterable<Image> images = imageApi.list(new ListOptions.Builder().maxResults(3));

      int imageCounter = 0;
      for (IterableWithMarker<Image> page : images) {
         for (Image image : page) {
            imageCounter++;
View Full Code Here

Examples of org.jclouds.googlecomputeengine.features.ImageApi

              .addHeader("Authorization", "Bearer " + TOKEN).build();

      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResource("/image_list_single_page.json")).build();

      ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
              TOKEN_RESPONSE, list, operationResponse).getImageApiForProject("myproject");

      PagedIterable<Image> images = imageApi.list();

      // expect one page
      assertSame(images.size(), 1);
      // with three images
      assertSame(images.concat().size(), 3);
View Full Code Here

Examples of org.jclouds.googlecomputeengine.features.ImageApi

      HttpResponse list3Response = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResource("/image_list_single_page.json")).build();


      ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
              TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response)
              .getImageApiForProject("myproject");

      PagedIterable<Image> images = imageApi.list(new ListOptions.Builder().maxResults(3));

      int imageCounter = 0;
      for (IterableWithMarker<Image> page : images) {
         for (Image image : page) {
            imageCounter++;
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.