X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Ftest%2FJU_Hash.java;h=f79564d649c3e8de55cc2f954c0732a4dc6f95b4;hb=b5985fb5667b3ee9b6a4a0675fb57f55e7a288b7;hp=92dd2970dc3af45def66ac26408011c37da8787e;hpb=7bc6ef245901a83da234c7765d76a7f7eb34540a;p=aaf%2Fcadi.git 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) { + + } + } + }