You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/12/26 14:18:53 UTC
[commons-codec] branch master updated (ac7a700 -> 6471942)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git.
from ac7a700 Prepare for next release.
new 251d41c Better param name.
new 6471942 Sort members.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/commons/codec/digest/DigestUtils.java | 12 ++---
.../codec/digest/MessageDigestAlgorithmsTest.java | 58 +++++++++++-----------
2 files changed, 35 insertions(+), 35 deletions(-)
[commons-codec] 02/02: Sort members.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
commit 6471942097893c67004e4990d77002a9071a7f84
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 26 09:04:24 2019 -0500
Sort members.
---
.../codec/digest/MessageDigestAlgorithmsTest.java | 58 +++++++++++-----------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java b/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java
index d0bb626..f1b7295 100644
--- a/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java
@@ -44,20 +44,6 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class MessageDigestAlgorithmsTest {
- @Parameters(name = "{0}")
- public static Object[] data() {
- return MessageDigestAlgorithms.values();
- }
-
- private static boolean contains(final String key) {
- for(final String s : MessageDigestAlgorithms.values()) {
- if (s.equals(key)) {
- return true;
- }
- }
- return false;
- }
-
@BeforeClass
public static void checkValues() throws Exception {
final Field [] fields = MessageDigestAlgorithms.class.getDeclaredFields();
@@ -87,6 +73,20 @@ public class MessageDigestAlgorithmsTest {
}
}
+ private static boolean contains(final String key) {
+ for(final String s : MessageDigestAlgorithms.values()) {
+ if (s.equals(key)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Parameters(name = "{0}")
+ public static Object[] data() {
+ return MessageDigestAlgorithms.values();
+ }
+
private DigestUtilsTest digestUtilsTest;
private final String messageDigestAlgorithm;
@@ -157,6 +157,21 @@ public class MessageDigestAlgorithmsTest {
}
@Test
+ public void testDigestInputStream() throws IOException {
+ Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
+ Assert.assertArrayEquals(digestTestData(),
+ DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), new ByteArrayInputStream(getTestData())));
+ Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),new ByteArrayInputStream(getTestData())));
+ }
+
+ @Test
+ public void testGetMessageDigest() {
+ Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
+ final MessageDigest messageDigest = DigestUtils.getDigest(messageDigestAlgorithm);
+ Assert.assertEquals(messageDigestAlgorithm, messageDigest.getAlgorithm());
+ }
+
+ @Test
public void testNonBlockingDigestRandomAccessFile() throws IOException {
Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
@@ -175,19 +190,4 @@ public class MessageDigestAlgorithmsTest {
);
}
- @Test
- public void testDigestInputStream() throws IOException {
- Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
- Assert.assertArrayEquals(digestTestData(),
- DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), new ByteArrayInputStream(getTestData())));
- Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),new ByteArrayInputStream(getTestData())));
- }
-
- @Test
- public void testGetMessageDigest() {
- Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
- final MessageDigest messageDigest = DigestUtils.getDigest(messageDigestAlgorithm);
- Assert.assertEquals(messageDigestAlgorithm, messageDigest.getAlgorithm());
- }
-
}
[commons-codec] 01/02: Better param name.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
commit 251d41c38fe917c9ee371f581ecf9ec651c6384e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 26 08:53:31 2019 -0500
Better param name.
---
.../java/org/apache/commons/codec/digest/DigestUtils.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index c1a3507..da921d3 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -1217,8 +1217,8 @@ public class DigestUtils {
* @since 1.11
*/
public static MessageDigest updateDigest(final MessageDigest digest, final File data) throws IOException {
- try (final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(data))) {
- return updateDigest(digest, stream);
+ try (final BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(data))) {
+ return updateDigest(digest, inputStream);
}
}
@@ -1248,20 +1248,20 @@ public class DigestUtils {
*
* @param digest
* The MessageDigest to use (e.g. MD5)
- * @param data
+ * @param inputStream
* Data to digest
* @return the digest
* @throws IOException
* On error reading from the stream
* @since 1.8
*/
- public static MessageDigest updateDigest(final MessageDigest digest, final InputStream data) throws IOException {
+ public static MessageDigest updateDigest(final MessageDigest digest, final InputStream inputStream) throws IOException {
final byte[] buffer = new byte[STREAM_BUFFER_LENGTH];
- int read = data.read(buffer, 0, STREAM_BUFFER_LENGTH);
+ int read = inputStream.read(buffer, 0, STREAM_BUFFER_LENGTH);
while (read > -1) {
digest.update(buffer, 0, read);
- read = data.read(buffer, 0, STREAM_BUFFER_LENGTH);
+ read = inputStream.read(buffer, 0, STREAM_BUFFER_LENGTH);
}
return digest;