public void assertHasDigest(AssertionInfo info, Path actual, String algorithm, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, algorithm, Digests.fromHex(expected)); } }
public static DigestDiff digestDiff(InputStream stream, MessageDigest messageDigest, byte[] expected) throws IOException { checkNotNull(stream, "The stream should not be null"); checkNotNull(messageDigest, "The digest should not be null"); checkNotNull(expected, "The expected should not be null"); messageDigest.reset(); byte[] buffer = new byte[BUFFER_SIZE]; int len; while ((len = stream.read(buffer)) > 0) { messageDigest.update(buffer, 0, len); } byte[] actualDigest = messageDigest.digest(); String expectedHex = toHex(expected); String actualHex = toHex(actualDigest); return new DigestDiff(actualHex, expectedHex, messageDigest); } }
public void assertHasDigest(AssertionInfo info, Path actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertIsRegularFile(info, actual); assertIsReadable(info, actual); try (InputStream actualStream = nioFilesWrapper.newInputStream(actual)) { DigestDiff diff = Digests.digestDiff(actualStream, digest, expected); if (diff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, diff)); } catch (IOException e) { throw new UncheckedIOException(format("Unable to calculate digest of path:<%s>", actual), e); } }
public void assertHasDigest(AssertionInfo info, File actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertExists(info, actual); assertIsFile(info, actual); assertCanRead(info, actual); try (InputStream actualStream = nioFilesWrapper.newInputStream(actual.toPath())) { DigestDiff digestDiff = digestDiff(actualStream, digest, expected); if (digestDiff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, digestDiff)); } catch (IOException e) { throw new UncheckedIOException(format("Unable to calculate digest of path:<%s>", actual), e); } }
public void assertHasDigest(AssertionInfo info, File actual, String algorithm, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, algorithm, Digests.fromHex(expected)); } }
public void assertHasDigest(AssertionInfo info, InputStream actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertNotNull(info, actual); try { DigestDiff diff = digestDiff(actual, digest, expected); if (diff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, diff)); } catch (IOException e) { String msg = format("Unable to calculate digest of InputStream:%n <%s>", actual); throw new InputStreamsException(msg, e); } }
public static DigestDiff digestDiff(InputStream stream, MessageDigest messageDigest, byte[] expected) throws IOException { checkNotNull(stream, "The stream should not be null"); checkNotNull(messageDigest, "The digest should not be null"); checkNotNull(expected, "The expected should not be null"); messageDigest.reset(); byte[] buffer = new byte[BUFFER_SIZE]; int len; while ((len = stream.read(buffer)) > 0) { messageDigest.update(buffer, 0, len); } byte[] actualDigest = messageDigest.digest(); String expectedHex = toHex(expected); String actualHex = toHex(actualDigest); return new DigestDiff(actualHex, expectedHex, messageDigest); } }
public void assertHasDigest(AssertionInfo info, InputStream actual, String algorithm, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, algorithm, Digests.fromHex(expected)); } }
public void assertHasDigest(AssertionInfo info, File actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertExists(info, actual); assertIsFile(info, actual); assertCanRead(info, actual); try (InputStream actualStream = nioFilesWrapper.newInputStream(actual.toPath())) { DigestDiff digestDiff = digestDiff(actualStream, digest, expected); if (digestDiff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, digestDiff)); } catch (IOException e) { throw new UncheckedIOException(format("Unable to calculate digest of path:<%s>", actual), e); } }
public void assertHasDigest(AssertionInfo info, File actual, MessageDigest digest, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, digest, Digests.fromHex(expected)); }
public void assertHasDigest(AssertionInfo info, Path actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertIsRegularFile(info, actual); assertIsReadable(info, actual); try (InputStream actualStream = nioFilesWrapper.newInputStream(actual)) { DigestDiff diff = Digests.digestDiff(actualStream, digest, expected); if (diff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, diff)); } catch (IOException e) { throw new UncheckedIOException(format("Unable to calculate digest of path:<%s>", actual), e); } }
public void assertHasDigest(AssertionInfo info, InputStream actual, MessageDigest digest, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, digest, Digests.fromHex(expected)); }
public void assertHasDigest(AssertionInfo info, InputStream actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertNotNull(info, actual); try { DigestDiff diff = digestDiff(actual, digest, expected); if (diff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, diff)); } catch (IOException e) { String msg = format("Unable to calculate digest of InputStream:%n <%s>", actual); throw new InputStreamsException(msg, e); } }
public void assertHasDigest(AssertionInfo info, Path actual, MessageDigest digest, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, digest, Digests.fromHex(expected)); }
public void assertHasDigest(AssertionInfo info, InputStream actual, String algorithm, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, algorithm, Digests.fromHex(expected)); } }
public void assertHasDigest(AssertionInfo info, File actual, String algorithm, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, algorithm, Digests.fromHex(expected)); } }
public void assertHasDigest(AssertionInfo info, File actual, MessageDigest digest, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, digest, Digests.fromHex(expected)); }
public void assertHasDigest(AssertionInfo info, Path actual, String algorithm, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, algorithm, Digests.fromHex(expected)); } }
public void assertHasDigest(AssertionInfo info, InputStream actual, MessageDigest digest, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, digest, Digests.fromHex(expected)); }
public void assertHasDigest(AssertionInfo info, Path actual, MessageDigest digest, String expected) { checkNotNull(expected, "The string representation of digest to compare to should not be null"); assertHasDigest(info, actual, digest, Digests.fromHex(expected)); }