[GitHub] [commons-codec] aherbert commented on a change in pull request #31: Added non-blocking File digest methods
aherbert commented on a change in pull request #31: Added non-blocking File digest methods URL: https://github.com/apache/commons-codec/pull/31#discussion_r353159063 ## File path: src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java ## @@ -63,23 +67,37 @@ File getTestFile() { return testFile; } +RandomAccessFile getTestRandomAccessFile() { +return testRandomAccessFileWrapper; +} + @Before public void setUp() throws Exception { new Random().nextBytes(testData); testFile = File.createTempFile(DigestUtilsTest.class.getName(), ".dat"); try (final FileOutputStream fos = new FileOutputStream(testFile)) { fos.write(testData); } + +testRandomAccessFile = File.createTempFile(DigestUtilsTest.class.getName(), ".dat"); +try (final FileOutputStream fos = new FileOutputStream(testRandomAccessFile)) { +fos.write(testData); +} +testRandomAccessFileWrapper = new RandomAccessFile(testRandomAccessFile, "rw"); } @After public void tearDown() { if (!testFile.delete()) { testFile.deleteOnExit(); } + +if (!testRandomAccessFile.delete()) { +testRandomAccessFile.deleteOnExit(); +} } -@Test(expected=IllegalArgumentException.class) +@Test(expected = IllegalArgumentException.class) Review comment: You have reformatted whitespace for the rest of this class. It makes it hard to see that you have not actually changed anything below this line other than whitespace. Can you unformat please. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [commons-codec] aherbert commented on a change in pull request #31: Added non-blocking File digest methods
aherbert commented on a change in pull request #31: Added non-blocking File digest methods URL: https://github.com/apache/commons-codec/pull/31#discussion_r353160091 ## File path: src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java ## @@ -151,6 +156,25 @@ public void testDigestFile() throws IOException { Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),getTestFile())); } +@Test +public void testNonBlockingDigestRandomAccessFile() throws IOException { +Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); + +final byte[] expected = digestTestData(); + +Assert.assertArrayEquals(expected, Review comment: In keeping with the rest of the class can you reformat the assertions to a single line. The 5 lines per assertion are very explicit. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [commons-codec] aherbert commented on a change in pull request #31: Added non-blocking File digest methods
aherbert commented on a change in pull request #31: Added non-blocking File digest methods URL: https://github.com/apache/commons-codec/pull/31#discussion_r353158195 ## File path: src/main/java/org/apache/commons/codec/digest/DigestUtils.java ## @@ -99,6 +101,20 @@ return updateDigest(messageDigest, data).digest(); } +/** + * Reads through a RandomAccessFile using non-blocking-io (NIO) and returns the digest for the data Review comment: First line of javadoc should end with a period. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [commons-codec] aherbert commented on a change in pull request #31: Added non-blocking File digest methods
aherbert commented on a change in pull request #31: Added non-blocking File digest methods URL: https://github.com/apache/commons-codec/pull/31#discussion_r353158280 ## File path: src/main/java/org/apache/commons/codec/digest/DigestUtils.java ## @@ -1207,6 +1223,29 @@ public static MessageDigest updateDigest(final MessageDigest digest, final File } } +/** + * Reads through a RandomAccessFile and updates the digest for the data + * using non-blocking-io (NIO) Review comment: First line of javadoc should end with a period. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [commons-codec] aherbert commented on a change in pull request #31: Added non-blocking File digest methods
aherbert commented on a change in pull request #31: Added non-blocking File digest methods URL: https://github.com/apache/commons-codec/pull/31#discussion_r352272387 ## File path: src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java ## @@ -146,6 +151,22 @@ public void testDigestFile() throws IOException { Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),getTestFile())); } +@Test +public void testNonBlockingDigestRandomAccessFile() throws IOException { +Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); +Assert.assertArrayEquals(digestTestData(), + DigestUtils.nonblockingDigest(DigestUtils.getDigest(messageDigestAlgorithm), getTestRandomAccessFile())); +Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),getTestFile())); Review comment: This should call `nonblockingDigest` with `getTestRandomAccessFile()` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services