diff --git a/src/test/java/org/dataone/hashstore/filehashstore/FileHashStoreInterfaceTest.java b/src/test/java/org/dataone/hashstore/filehashstore/FileHashStoreInterfaceTest.java index 32cc50d3..f0d28fe7 100644 --- a/src/test/java/org/dataone/hashstore/filehashstore/FileHashStoreInterfaceTest.java +++ b/src/test/java/org/dataone/hashstore/filehashstore/FileHashStoreInterfaceTest.java @@ -380,7 +380,8 @@ public void storeObject_incorrectChecksumValue() { } /** - * Verify exception contains hexDigests when NonMatchingChecksumException is thrown + * Verify exception contains hexDigests when NonMatchingChecksumException is thrown, and that + * an additional algorithm included is also found. */ @Test public void storeObject_nonMatchingChecksumException_hexDigestsIncluded() throws Exception { @@ -393,7 +394,7 @@ public void storeObject_nonMatchingChecksumException_hexDigestsIncluded() throws try (InputStream dataStream = Files.newInputStream(testDataFile)) { try { - fileHashStore.storeObject(dataStream, pid, null, checksumIncorrect, "SHA-256", -1); + fileHashStore.storeObject(dataStream, pid, "SHA-512/224", checksumIncorrect, "SHA-256", -1); } catch (NonMatchingChecksumException nmce) { Map hexDigestsRetrieved = nmce.getHexDigests(); diff --git a/src/test/java/org/dataone/hashstore/hashstoreconverter/FileHashStoreLinksTest.java b/src/test/java/org/dataone/hashstore/hashstoreconverter/FileHashStoreLinksTest.java index 94f9b1f4..7e6aa7fe 100644 --- a/src/test/java/org/dataone/hashstore/hashstoreconverter/FileHashStoreLinksTest.java +++ b/src/test/java/org/dataone/hashstore/hashstoreconverter/FileHashStoreLinksTest.java @@ -193,6 +193,40 @@ public void storeHardLink_nonMatchingChecksum() { } } + /** + * Check hexDigests included when nonMatchingChecksumException is thrown when storing a hard + * link and that an algorithm that is not part of the default list is generated & included. + */ + @Test + public void storeHardLink_nonMatchingChecksum_hexDigestsIncluded() throws Exception { + for (String pid : testData.pidList) { + String pidFormatted = pid.replace("/", "_"); + Path testDataFile = testData.getTestFile(pidFormatted); + assertTrue(Files.exists(testDataFile)); + + try { + fileHashStoreLinks.storeHardLink(testDataFile, pid, "badchecksum", "SHA-512/224"); + + } catch (NonMatchingChecksumException nmce) { + Map hexDigestsRetrieved = nmce.getHexDigests(); + + String md5 = testData.pidData.get(pid).get("md5"); + String sha1 = testData.pidData.get(pid).get("sha1"); + String sha256 = testData.pidData.get(pid).get("sha256"); + String sha384 = testData.pidData.get(pid).get("sha384"); + String sha512 = testData.pidData.get(pid).get("sha512"); + String sha512_224 = testData.pidData.get(pid).get("sha512-224"); + assertEquals(md5, hexDigestsRetrieved.get("MD5")); + assertEquals(sha1, hexDigestsRetrieved.get("SHA-1")); + assertEquals(sha256, hexDigestsRetrieved.get("SHA-256")); + assertEquals(sha384, hexDigestsRetrieved.get("SHA-384")); + assertEquals(sha512, hexDigestsRetrieved.get("SHA-512")); + assertEquals(sha512_224, hexDigestsRetrieved.get("SHA-512/224")); + } + } + + } + /** * Confirm that generateChecksums calculates checksums as expected */