Package org.jclouds.http

Examples of org.jclouds.http.HttpRequest$ConcreteBuilder


   }

   @Test
   void shouldGenerateTheCorrectStringToSignAndSignatureWithNoBody() {

      HttpRequest request = HttpRequest.builder().method(HttpMethod.DELETE).endpoint("http://localhost/" + PATH)
            .build();

      request = signing_obj.filter(request);
      Multimap<String, String> headersWithoutContentLength = LinkedHashMultimap.create(request.getHeaders());
      assertEqualsNoOrder(headersWithoutContentLength.entries().toArray(), EXPECTED_SIGN_RESULT_EMPTY.entries()
            .toArray());
   }
View Full Code Here


   @Test
   void shouldNotChokeWhenSigningARequestForAResourceWithALongName() {
      StringBuilder path = new StringBuilder("nodes/");
      for (int i = 0; i < 100; i++)
         path.append('A');
      HttpRequest request = HttpRequest.builder().method(HttpMethod.PUT)
            .endpoint("http://localhost/" + path.toString()).payload(BODY).build();

      signing_obj.filter(request);
   }
View Full Code Here

   @Test
   void shouldReplacePercentage3FWithQuestionMarkAtUrl() {
      StringBuilder path = new StringBuilder("nodes/");
      path.append("test/cookbooks/myCookBook%3Fnum_versions=5");
      HttpRequest request = HttpRequest.builder().method(HttpMethod.GET)
            .endpoint("http://localhost/" + path.toString()).payload(BODY).build();
      request = signing_obj.filter(request);
      assertTrue(request.getRequestLine().contains("?num_versions=5"));
   }
View Full Code Here

   BindChecksumsToJsonPayload binder = injector.getInstance(BindChecksumsToJsonPayload.class);

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testMustBeIterable() {
      HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
      binder.bindToRequest(request, new File("foo"));
   }
View Full Code Here

      HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
      binder.bindToRequest(request, new File("foo"));
   }

   public void testCorrect() {
      HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
      binder.bindToRequest(request,
            ImmutableSet.of(asList(base16().lowerCase().decode("abddef")), asList(base16().lowerCase().decode("1234"))));
      assertEquals(request.getPayload().getRawContent(), "{\"checksums\":{\"abddef\":null,\"1234\":null}}");
   }
View Full Code Here

      assertEquals(request.getPayload().getRawContent(), "{\"checksums\":{\"abddef\":null,\"1234\":null}}");
   }

   @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
   public void testNullIsBad() {
      HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
      binder.bindToRequest(request, null);
   }
View Full Code Here

   private BindGroupToUpdateRequestJsonPayload binder = injector.getInstance(BindGroupToUpdateRequestJsonPayload.class);

   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullInput() {
      HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, null);
   }
View Full Code Here

      binder.bindToRequest(request, null);
   }

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInvalidTypeInput() {
      HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }
View Full Code Here

      HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }

   public void testBindOnlyName() throws IOException {
      HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
      HttpRequest newRequest = binder.bindToRequest(request, Group.builder("foo").build());

      String payload = Strings2.toStringAndClose(newRequest.getPayload().getInput());
      assertEquals(payload, "{\"groupname\":\"foo\",\"actors\":{\"clients\":[],\"groups\":[],\"users\":[]}}");
   }
View Full Code Here

   }

   public void testBindNameAndLists() throws IOException {
      Group group = Group.builder("foo").client("nacx-validator").group("admins").user("nacx").build();

      HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
      HttpRequest newRequest = binder.bindToRequest(request, group);

      String payload = Strings2.toStringAndClose(newRequest.getPayload().getInput());
      assertEquals(payload,
            "{\"groupname\":\"foo\",\"actors\":{\"clients\":[\"nacx-validator\"],\"groups\":[\"admins\"],\"users\":[\"nacx\"]}}");
   }
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.