Examples of HttpCommand


Examples of org.jclouds.http.HttpCommand

   public void testQueueDeletedRecentlyRetriesWhen60DoesntTry() {

      SQSErrorRetryHandler retry = new SQSErrorRetryHandler(createMock(AWSUtils.class),
            createMock(BackoffLimitedRetryHandler.class), ImmutableSet.<String> of(), 60, 100);

      HttpCommand command = createHttpCommandForFailureCount(60);

      Stopwatch watch = new Stopwatch().start();
      assertFalse(retry.shouldRetryRequestOnError(command, response, error));
      assertEquals(command.getFailureCount(), 61);
      assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      assertEquals(command.getFailureCount(), 61);
      assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100);
   }
  
   HttpCommand createHttpCommandForFailureCount(final int failureCount) {
      HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build());
      while (command.getFailureCount() != failureCount)
         command.incrementFailureCount();
      return command;
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   }

   @Test
   void testClosesInputStream() throws InterruptedException, IOException, SecurityException, NoSuchMethodException {
      HttpCommand command = createCommand();

      HttpResponse response = HttpResponse.builder().statusCode(400).build();

      InputStream inputStream = new InputStream() {
         boolean isOpen = true;
View Full Code Here

Examples of org.jclouds.http.HttpCommand

  

   private HttpCommand createCommand() throws SecurityException, NoSuchMethodException {
      Invokable<IntegrationTestAsyncClient, String> method = method(IntegrationTestAsyncClient.class, "download", String.class);

      return new HttpCommand(processor.apply(Invocation.create(method, ImmutableList.<Object> of("1"))));
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      return new HttpCommand(processor.apply(Invocation.create(method, ImmutableList.<Object> of("1"))));
   }

   @Test
   void testIncrementsFailureCount() throws InterruptedException, IOException, SecurityException, NoSuchMethodException {
      HttpCommand command = createCommand();
      HttpResponse response = HttpResponse.builder().statusCode(400).build();

      handler.shouldRetryRequest(command, response);
      assertEquals(command.getFailureCount(), 1);

      handler.shouldRetryRequest(command, response);
      assertEquals(command.getFailureCount(), 2);

      handler.shouldRetryRequest(command, response);
      assertEquals(command.getFailureCount(), 3);
   }
View Full Code Here

Examples of org.jclouds.http.HttpCommand

   }

   @Test
   void testDisallowsExcessiveRetries() throws InterruptedException, IOException, SecurityException,
            NoSuchMethodException {
      HttpCommand command = createCommand();
      HttpResponse response = HttpResponse.builder().statusCode(400).build();

      assertEquals(handler.shouldRetryRequest(command, response), true); // Failure 1

      assertEquals(handler.shouldRetryRequest(command, response), true); // Failure 2
View Full Code Here

Examples of org.jclouds.http.HttpCommand

*/
@Test(groups = "unit", testName = "RetryOnRenewTest")
public class RetryOnRenewTest {
   @Test
   public void test401ShouldRetry() {
      HttpCommand command = createMock(HttpCommand.class);
      HttpRequest request = createMock(HttpRequest.class);
      HttpResponse response = createMock(HttpResponse.class);
      @SuppressWarnings("unchecked")
      LoadingCache<Credentials, Access> cache = createMock(LoadingCache.class);
      BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class);

      expect(command.getCurrentRequest()).andReturn(request);

      cache.invalidateAll();
      expectLastCall();

      expect(response.getPayload()).andReturn(Payloads.newStringPayload("")).anyTimes();
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      verify(cache);
   }

   @Test
   public void test401ShouldRetry4Times() {
      HttpCommand command = createMock(HttpCommand.class);
      HttpRequest request = createMock(HttpRequest.class);
      HttpResponse response = createMock(HttpResponse.class);

      @SuppressWarnings("unchecked")
      LoadingCache<Credentials, Access> cache = createMock(LoadingCache.class);
      BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class);

      expect(command.getCurrentRequest()).andReturn(request).anyTimes();
      expect(request.getHeaders()).andStubReturn(null);

      cache.invalidateAll();
      expectLastCall().anyTimes();
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      verify(command, response, cache);
   }

   @Test
   public void test408ShouldRetry() {
      HttpCommand command = createMock(HttpCommand.class);
      HttpResponse response = createMock(HttpResponse.class);
      @SuppressWarnings("unchecked")
      LoadingCache<Credentials, Access> cache = createMock(LoadingCache.class);
      BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class);
View Full Code Here

Examples of org.jclouds.http.HttpCommand

      }
   }

   public static HttpResponseException returnResponseException(int code) {
      HttpResponse response = HttpResponse.builder().statusCode(code).build();
      return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub")
            .build()), 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.