Package org.jclouds.io

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


        GetOptions getOptionsRangeTail = new GetOptions();
        getOptionsRangeTail.tail(3);
        Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail);
        payload = blobRangeTail.getPayload();
        try {
            assertEquals(input.substring(5), Strings2.toStringAndClose(payload.openStream()));
        } finally {
            Closeables2.closeQuietly(payload);
        }

        GetOptions getOptionsFragment = new GetOptions();
View Full Code Here


        GetOptions getOptionsFragment = new GetOptions();
        getOptionsFragment.range(4, 6);
        Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment);
        payload = blobFragment.getPayload();
        try {
            assertEquals(input.substring(4, 7), Strings2.toStringAndClose(payload.openStream()));
        } finally {
            Closeables2.closeQuietly(payload);
        }
    }
View Full Code Here

      File outputFile = getFileForBlobKey(containerName, blobKey);
      Path outputPath = outputFile.toPath();
      HashingInputStream his = null;
      try {
         Files.createParentDirs(outputFile);
         his = new HashingInputStream(Hashing.md5(), payload.openStream());
         outputFile.delete();
         Files.asByteSink(outputFile).writeFrom(his);
         HashCode actualHashCode = his.hash();
         HashCode expectedHashCode = payload.getContentMetadata().getContentMD5AsHashCode();
         if (expectedHashCode != null && !actualHashCode.equals(expectedHashCode)) {
View Full Code Here

                 "3 parts (2 objects + 1 manifest) were expected.");

         // download and check if correct
         Blob read = blobStore.getBlob(containerName, objectName);
         Payload readPayload = read.getPayload();
         assertTrue(Arrays.equals(inputSource.read(), ByteStreams2.toByteArrayAndClose(readPayload.openStream())));
      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here

      File payloadFile = File.createTempFile("testPutFileParallel", "png");
      createTestInput(32 * 1024).copyTo(Files.asByteSink(payloadFile));
     
      final Payload testPayload = Payloads.newFilePayload(payloadFile);
      final HashCode md5 = hashAndClose(testPayload.openStream(), md5());
      testPayload.getContentMetadata().setContentType("image/png");
     
      final AtomicInteger blobCount = new AtomicInteger();
      final String container = getContainerName();
      try {
View Full Code Here

      SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
      try {
         client.connect();
         Payload etcPasswd = client.get("/etc/jclouds.txt");
         String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.openStream());
         assertEquals("rackspace", etcPasswdContents.trim());
      } finally {
         if (client != null)
            client.disconnect();
      }
View Full Code Here

         Payload payload = object.getPayload();
         assertEquals(payload.getContentMetadata().getContentLength(), Long.valueOf(4));
         assertEquals(payload.getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         assertEquals(payload.getContentMetadata().getExpires(), dates.rfc822DateParse("Wed, 23 Jul 2014 14:00:00 GMT"));

         assertEquals(toStringAndClose(payload.openStream()), "ABCD");

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         RecordedRequest get = server.takeRequest();
         assertEquals(get.getRequestLine(),
View Full Code Here

            if (response.getStatusCode() != 200) {
               fail("Signed GET expected to return 200 but returned "
                     + response.getStatusCode());
            }
            Payload payload = response.getPayload();
            assertEquals(ByteStreams2.toByteArrayAndClose(payload.openStream()), input.read(),
                  "Data with signed GET not identical to what was put");
         } catch (Exception e) {
            fail("Failed signed GET test: " + e);
         }
      }
View Full Code Here

      temp = File.createTempFile("foo", "bar");
      try {
         SshClient client = setupClient();
         client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
         Payload input = client.get(temp.getAbsolutePath());
         String contents = Strings2.toStringAndClose(input.openStream());
         assertEquals(contents, "rabbit");
      } finally {
         temp.delete();
      }
   }
View Full Code Here

      }
   }

   public void testGetEtcPassword() throws IOException {
      Payload input = setupClient().get("/etc/passwd");
      String contents = Strings2.toStringAndClose(input.openStream());
      assert contents.indexOf("root") >= 0 : "no root in " + contents;
   }

   public void testExecHostname() throws IOException, InterruptedException {
      SshClient client = setupClient();
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.