Package org.jclouds.io

Examples of org.jclouds.io.Payload.release()


      Payload payload = createMock(Payload.class);

      expect(response.getStatusCode()).andReturn(200).atLeastOnce();
      expect(response.getPayload()).andReturn(payload).atLeastOnce();
      expect(payload.getInput()).andReturn(Strings2.toInputStream("hello"));
      payload.release();

      replay(payload);
      replay(response);

      assertEquals(function.apply(response), "hello");
View Full Code Here


         Payload payload = newFilePayload(f);
         byte[] digest = digester.digest();
         payload.getContentMetadata().setContentMD5(digest);
         Multimap<String, String> headers = client.postPayloadAndReturnHeaders("", payload);
         assertEquals(headers.get("x-Content-MD5"), ImmutableList.of(base64().encode(digest)));
         payload.release();
      } finally {
         if (f != null && f.exists())
            f.delete();
      }
   }
View Full Code Here

   public void testPostContentDisposition() {
      Payload payload = newStringPayload("foo");
      payload.getContentMetadata().setContentDisposition("attachment; filename=photo.jpg");
      Multimap<String, String> headers = client.postPayloadAndReturnHeaders("", payload);
      assertEquals(headers.get("x-Content-Disposition"), ImmutableList.of("attachment; filename=photo.jpg"));
      payload.release();
   }

   @Test(invocationCount = 5, timeOut = 5000)
   public void testPostContentEncoding() {
      Payload payload = newStringPayload("foo");
View Full Code Here

   public void testPostContentEncoding() {
      Payload payload = newStringPayload("foo");
      payload.getContentMetadata().setContentEncoding("gzip");
      Multimap<String, String> headers = client.postPayloadAndReturnHeaders("", payload);
      assertEquals(headers.get("x-Content-Encoding"), ImmutableList.of("gzip"));
      payload.release();
   }

   @Test(invocationCount = 5, timeOut = 5000)
   public void testPostContentLanguage() {
      Payload payload = newStringPayload("foo");
View Full Code Here

   public void testPostContentLanguage() {
      Payload payload = newStringPayload("foo");
      payload.getContentMetadata().setContentLanguage("mi, en");
      Multimap<String, String> headers = client.postPayloadAndReturnHeaders("", payload);
      assertEquals(headers.get("x-Content-Language"), ImmutableList.of("mi, en"));
      payload.release();
   }

   @Test(invocationCount = 5, timeOut = 5000)
   public void testPut() {
      assertEquals(client.upload("", "foo").trim(), "fooPUT");
View Full Code Here

      expect(response.getStatusCode()).andReturn(200).atLeastOnce();
      expect(response.getFirstHeaderOrNull(CONTENT_TYPE)).andReturn("text/uri-list");
      expect(response.getPayload()).andReturn(payload).atLeastOnce();
      expect(payload.getInput()).andReturn(null);
      payload.release();

      replay(payload);
      replay(response);
      try {
         function.apply(response);
View Full Code Here

      expect(response.getStatusCode()).andReturn(200).atLeastOnce();
      expect(response.getFirstHeaderOrNull(CONTENT_TYPE)).andReturn("text/uri-list");
      RuntimeException exception = new RuntimeException("bad");
      expect(response.getPayload()).andReturn(payload).atLeastOnce();
      expect(payload.getInput()).andThrow(exception);
      payload.release();

      replay(payload);
      replay(response);
      try {
         function.apply(response);
View Full Code Here

      expect(response.getStatusCode()).andReturn(200).atLeastOnce();
      expect(response.getFirstHeaderOrNull(CONTENT_TYPE)).andReturn("text/uri-list");
      expect(response.getPayload()).andReturn(payload).atLeastOnce();
      expect(payload.getInput()).andReturn(toInputStream("http://locahost")).atLeastOnce();
      payload.release();

      replay(payload);
      replay(response);
      assertEquals(function.apply(response), URI.create("http://locahost"));
View Full Code Here

      expect(response.getStatusCode()).andReturn(200).atLeastOnce();
      expect(response.getFirstHeaderOrNull(CONTENT_TYPE)).andReturn("text/plain");
      expect(response.getFirstHeaderOrNull(LOCATION)).andReturn("http://locahost");
      expect(response.getPayload()).andReturn(payload).atLeastOnce();
      payload.release();

      replay(payload);
      replay(response);
      assertEquals(function.apply(response), URI.create("http://locahost"));
      verify(response);
View Full Code Here

      expect(response.getStatusCode()).andReturn(200).atLeastOnce();
      expect(response.getFirstHeaderOrNull(CONTENT_TYPE)).andReturn("text/plain");
      expect(response.getFirstHeaderOrNull(LOCATION)).andReturn(null);
      expect(response.getFirstHeaderOrNull("location")).andReturn("http://locahost");
      expect(response.getPayload()).andReturn(payload).atLeastOnce();
      payload.release();

      replay(payload);
      replay(response);
      assertEquals(function.apply(response), URI.create("http://locahost"));
      verify(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.