summaryrefslogtreecommitdiffstats
path: root/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java')
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java b/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
index 92dd297..f79564d 100644
--- a/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
+++ b/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
@@ -57,4 +57,59 @@ public class JU_Hash {
}
}
+ @Test
+ public void test1() throws CadiException {
+ String init = "m8234337@csp.att.com:kumquat8rie@#Tomatos3";
+ String hashed = Hash.toHex(init.getBytes());
+ System.out.println(hashed);
+ byte[] ba = Hash.fromHex(hashed);
+ String recon = new String(ba);
+ System.out.println(recon);
+ Assert.assertEquals(init, recon);
+
+ init =hashed.substring(1);
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+
+ init = hashed.replace('1', '~');
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+ }
+
+
+ @Test
+ public void test2() throws CadiException {
+ String init = "m823475@csp.att.com:kumquat8rie@#Tomatos3";
+ String hashed = Hash.toHex(init.getBytes());
+ System.out.println(hashed);
+ byte[] ba = Hash.fromHex(hashed);
+ String recon = new String(ba);
+ System.out.println(recon);
+ Assert.assertEquals(init, recon);
+
+ init =hashed.substring(1);
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+
+ init = hashed.replace('1', '~');
+ try {
+ hashed = Hash.fromHex(init).toString();
+ Assert.fail("Should have thrown Exception");
+ } catch (CadiException e) {
+
+ }
+ }
+
}