public void testWrite_putByteArrayAtPos() throws Exception { byte[] buf = new byte[] {'y', 'a', 'm', 's'}; HashingOutputStream out = new HashingOutputStream(hashFunction, buffer); out.write(buf, 0, 3); verify(hashFunction).newHasher(); verify(hasher).putBytes(buf, 0, 3); verifyNoMoreInteractions(hashFunction, hasher); }
public void testWrite_putSingleByte() throws Exception { int b = 'q'; HashingOutputStream out = new HashingOutputStream(hashFunction, buffer); out.write(b); verify(hashFunction).newHasher(); verify(hasher).putByte((byte) b); verifyNoMoreInteractions(hashFunction, hasher); }
public void testWrite_putByteArray() throws Exception { byte[] buf = new byte[] {'y', 'a', 'm', 's'}; HashingOutputStream out = new HashingOutputStream(hashFunction, buffer); out.write(buf); verify(hashFunction).newHasher(); verify(hasher).putBytes(buf, 0, buf.length); verifyNoMoreInteractions(hashFunction, hasher); }
public void testHash_hashesCorrectly() throws Exception { byte[] buf = new byte[] {'y', 'a', 'm', 's'}; HashCode expectedHash = Hashing.md5().hashBytes(buf); HashingOutputStream out = new HashingOutputStream(Hashing.md5(), buffer); out.write(buf); assertEquals(expectedHash, out.hash()); }
public void testChecksForNull() throws Exception { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods( new HashingOutputStream(Hashing.md5(), new ByteArrayOutputStream())); tester.testAllPublicStaticMethods(HashingOutputStream.class); tester.testAllPublicConstructors(HashingOutputStream.class); } }
DigestOutputStream md5DigestOutputStream = new DigestOutputStream( nullOutputStream, MessageDigest.getInstance("MD5")); HashingOutputStream crc32cHashingOutputStream = new HashingOutputStream(Hashing.crc32c(), md5DigestOutputStream); ObjectsDownloadExample.downloadToOutputStream(storage, settings.getBucket(),
public void testWrite_putSingleByte() throws Exception { int b = 'q'; HashingOutputStream out = new HashingOutputStream(hashFunction, buffer); out.write(b); verify(hashFunction).newHasher(); verify(hasher).putByte((byte) b); verifyNoMoreInteractions(hashFunction, hasher); }
public void testWrite_putByteArray() throws Exception { byte[] buf = new byte[] {'y', 'a', 'm', 's'}; HashingOutputStream out = new HashingOutputStream(hashFunction, buffer); out.write(buf); verify(hashFunction).newHasher(); verify(hasher).putBytes(buf, 0, buf.length); verifyNoMoreInteractions(hashFunction, hasher); }
public void testWrite_putByteArrayAtPos() throws Exception { byte[] buf = new byte[] {'y', 'a', 'm', 's'}; HashingOutputStream out = new HashingOutputStream(hashFunction, buffer); out.write(buf, 0, 3); verify(hashFunction).newHasher(); verify(hasher).putBytes(buf, 0, 3); verifyNoMoreInteractions(hashFunction, hasher); }
public void testHash_hashesCorrectly() throws Exception { byte[] buf = new byte[] {'y', 'a', 'm', 's'}; HashCode expectedHash = Hashing.md5().hashBytes(buf); HashingOutputStream out = new HashingOutputStream(Hashing.md5(), buffer); out.write(buf); assertEquals(expectedHash, out.hash()); }
OutputStream os = outputStream; for (HashType hashType : HashType.values()) { os = new HashingOutputStream(hashType.getHashAlgorithm().function(), os); hashingStreams.put(hashType.getHashAlgorithm(), (HashingOutputStream) os);
public void testChecksForNull() throws Exception { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods( new HashingOutputStream(Hashing.md5(), new ByteArrayOutputStream())); tester.testAllPublicStaticMethods(HashingOutputStream.class); tester.testAllPublicConstructors(HashingOutputStream.class); } }
final HashingOutputStream hos = new HashingOutputStream(Hashing.md5(), cos); representation.writeTo(hos); hos.close();