Package org.jclouds.digitalocean.features

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


   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

      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

   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

   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

      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

TOP

Related Classes of org.jclouds.digitalocean.features.ImageApi

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.