Package com.google.common.hash

Examples of com.google.common.hash.HashCode


      try {
         String contentDisposition = null;
         String contentEncoding = null;
         String contentLanguage = null;
         String contentType = null;
         HashCode hashCode = null;
         Date expires = null;
         ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder();

         if (getFileStore(file.toPath()).supportsFileAttributeView(UserDefinedFileAttributeView.class)) {
            UserDefinedFileAttributeView view = getFileAttributeView(path, UserDefinedFileAttributeView.class);
View Full Code Here


      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)) {
            throw new IOException("MD5 hash code mismatch, actual: " + actualHashCode +
                  " expected: " + expectedHashCode);
         }
         payload.getContentMetadata().setContentMD5(actualHashCode);
View Full Code Here

   }

   @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreateDirectory" })
   public void testListOptions() throws Exception {
      String data = "here is my data!";
      HashCode hashCode = Hashing.md5().hashString(data, UTF_8);
      createOrReplaceObject("object2", data, hashCode, "meta-value1");
      createOrReplaceObject("object3", data, hashCode, "meta-value1");
      createOrReplaceObject("object4", data, hashCode, "meta-value1");
      BoundedSet<? extends DirectoryEntry> r2 = getApi().listDirectory(privateDirectory, ListOptions.Builder.limit(1));
      assertEquals(r2.size(), 1);
View Full Code Here

      assertEquals(request.getFilters().size(), 0);
   }

   public void testSignPutBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
            NoSuchMethodException, IOException {
      HashCode hashCode = HashCode.fromBytes(new byte[16]);
      Blob blob = blobFactory.create(null);
      blob.getMetadata().setName("name");
      blob.setPayload("");
      blob.getPayload().getContentMetadata().setContentLength(2l);
      blob.getPayload().getContentMetadata().setContentMD5(hashCode.asBytes());
      blob.getPayload().getContentMetadata().setContentType("text/plain");
      blob.getPayload().getContentMetadata().setExpires(new Date(1000));
     
      HttpRequest request = signer.signPutBlob("container", blob);

      assertRequestLineEquals(request,
               "POST https://accesspoint.atmosonline.com/rest/namespace/container/name HTTP/1.1");
      assertNonPayloadHeadersEqual(
               request,
               "Accept: */*\n" +
               "Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
               "Expect: 100-continue\n" +
               "x-emc-signature: OlAHsoIDCsO5YmqjRxOIM5sp3r0=\n" +
               "x-emc-uid: identity\n" +
               "x-emc-wschecksum: MD5/0/00000000000000000000000000000000\n");

      assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, hashCode.asBytes(), new Date(1000));

      assertEquals(request.getFilters().size(), 0);
   }
View Full Code Here

      http.getPayload().getContentMetadata().setContentEncoding("encoding");
      http.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);

      MutableObjectMetadata response = parser.apply(http);

      HashCode hashCode = HashCode.fromBytes(new byte[16]);
      MutableObjectMetadataImpl expects = new MutableObjectMetadataImpl();
      expects.setCacheControl("cacheControl");
      expects.getContentMetadata().setContentDisposition("contentDisposition");
      expects.getContentMetadata().setContentEncoding("encoding");
      expects.getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);
View Full Code Here

      http.getPayload().getContentMetadata().setContentEncoding("encoding");
      http.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);

      MutableObjectMetadata response = parser.apply(http);

      HashCode hashCode = HashCode.fromBytes(new byte[16]);
      MutableObjectMetadataImpl expects = new MutableObjectMetadataImpl();
      expects.setCacheControl("cacheControl");
      expects.getContentMetadata().setContentDisposition("contentDisposition");
      expects.getContentMetadata().setContentEncoding("encoding");
      expects.getContentMetadata().setContentMD5(hashCode);
View Full Code Here

               contentLength);
      } else {
         builder.replaceHeader(TRANSFER_ENCODING, "chunked").build();
      }

      HashCode md5 = payload.getContentMetadata().getContentMD5AsHashCode();
      if (md5 != null) {
         // Swift will validate the md5, if placed as an ETag header
         builder.replaceHeader(ETAG, base16().lowerCase().encode(md5.asBytes()));
      }

      Date expires = payload.getContentMetadata().getExpires();
      if (expires != null) {
         builder.addHeader(OBJECT_DELETE_AT,
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

   }

   @Test(groups = { "integration", "live" })
   public void testPutCorrectContentMD5() throws InterruptedException, IOException {
      byte[] payload = createTestInput(1024).read();
      HashCode contentMD5 = md5().hashBytes(payload);
      putBlobWithMd5(payload, contentMD5);
   }
View Full Code Here

   }

   @Test(groups = { "integration", "live" })
   public void testPutIncorrectContentMD5() throws InterruptedException, IOException {
      byte[] payload = createTestInput(1024).read();
      HashCode contentMD5 = md5().hashBytes(new byte[0]);
      try {
         putBlobWithMd5(payload, contentMD5);
         fail();
      } catch (HttpResponseException hre) {
         if (hre.getResponse().getStatusCode() != getIncorrectContentMD5StatusCode()) {
View Full Code Here

TOP

Related Classes of com.google.common.hash.HashCode

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.