Examples of HttpCommand


Examples of org.jclouds.http.HttpCommand

      IMocksControl control = createControl();
      EC2Client client = control.createMock(EC2Client.class);
      AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
      AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class);
      AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
      expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn(
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   @Test
   public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() {
      IMocksControl control = createControl();
      EC2Client client = control.createMock(EC2Client.class);
      AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
      HttpCommand command = control.createMock(HttpCommand.class);
      HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
               command, null);

      expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
      expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      invokeHttpMethod.apply(get);
   }

   public void testMethodWithNoTimeoutCallGetDirectly() throws Exception {
      expect(config.getTimeoutNanos(get)).andReturn(Optional.<Long> absent());
      expect(http.invoke(new HttpCommand(getRequest))).andReturn(response);
      replay(http, timeLimiter, fallback, config, future);
      invokeHttpMethod.apply(get);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   private HttpResponse fallbackResponse = HttpResponse.builder().statusCode(200).payload("bar").build();

   public void testDirectCallRunsFallbackCreateOrPropagate() throws Exception {
      IllegalStateException exception = new IllegalStateException();
      expect(config.getTimeoutNanos(get)).andReturn(Optional.<Long> absent());
      expect(http.invoke(new HttpCommand(getRequest))).andThrow(exception);
      expect(fallback.createOrPropagate(exception)).andReturn(fallbackResponse);
      replay(http, timeLimiter, fallback, config, future);
      assertEquals(invokeHttpMethod.apply(get), fallbackResponse);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      invokeHttpMethod.apply(get);
   }

   public void testMethodWithNoTimeoutCallGetDirectly() throws Exception {
      expect(config.getTimeoutNanos(asyncGet)).andReturn(Optional.<Long> absent());
      expect(http.invoke(new HttpCommand(getRequest))).andReturn(response);
      replay(http, timeLimiter, fallback, config, future);
      invokeHttpMethod.apply(get);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      replay(http, timeLimiter, fallback, config, future);
      invokeHttpMethod.apply(get);
   }

   public void testAsyncMethodSubmitsRequest() throws Exception {
      expect(http.submit(new HttpCommand(getRequest))).andReturn(future);
      future.addListener(anyObject(Runnable.class), eq(userThreads));
      replay(http, timeLimiter, fallback, config, future);
      invokeHttpMethod.apply(asyncGet);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   private HttpResponse fallbackResponse = HttpResponse.builder().statusCode(200).payload("bar").build();

   public void testDirectCallRunsFallbackCreateOrPropagate() throws Exception {
      IllegalStateException exception = new IllegalStateException();
      expect(config.getTimeoutNanos(asyncGet)).andReturn(Optional.<Long> absent());
      expect(http.invoke(new HttpCommand(getRequest))).andThrow(exception);
      expect(fallback.createOrPropagate(exception)).andReturn(fallbackResponse);
      replay(http, timeLimiter, fallback, config, future);
      assertEquals(invokeHttpMethod.apply(get), fallbackResponse);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   }

   @SuppressWarnings("unchecked")
   public void testSubmitRunsFallbackCreateOnGet() throws Exception {
      IllegalStateException exception = new IllegalStateException();
      expect(http.submit(new HttpCommand(getRequest))).andReturn(
            Futures.<HttpResponse> immediateFailedFuture(exception));
      expect(fallback.create(exception)).andReturn(Futures.<HttpResponse> immediateFuture(fallbackResponse));
      // not using the field, as you can see above we are making an immediate
      // failed future instead.
      future = createMock(ListenableFuture.class);
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
                                String content, Class<? extends Exception> expected) {

      GoogleComputeEngineErrorHandler function = new GoogleComputeEngineErrorHandler();

      HttpCommand command = createMock(HttpCommand.class);
      HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
      HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
      response.getPayload().getContentMetadata().setContentType(contentType);

      expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
      command.setException(classEq(expected));

      replay(command);

      function.handleError(command, response);
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
                                String content, Class<? extends Exception> expected) {

      OAuthErrorHandler function = new OAuthErrorHandler();

      HttpCommand command = createMock(HttpCommand.class);
      HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
      HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
      response.getPayload().getContentMetadata().setContentType(contentType);

      expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
      command.setException(classEq(expected));

      replay(command);

      function.handleError(command, response);
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.