summaryrefslogtreecommitdiffstats
path: root/core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
diff options
context:
space:
mode:
authorsg481n <sg481n@att.com>2017-10-01 21:06:52 +0000
committersg481n <sg481n@att.com>2017-10-01 22:07:06 +0000
commitb5985fb5667b3ee9b6a4a0675fb57f55e7a288b7 (patch)
tree451b6146944e489348a922d552f150ff91e85480 /core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java
parent7bc6ef245901a83da234c7765d76a7f7eb34540a (diff)
Improve code coverage for aaf cadi modules
Updated few testcases. Issue-ID: AAF-79 Change-Id: If0760b6f3e74d52fa5132224bf1e6f5e3099f0e4 Signed-off-by: sg481n <sg481n@att.com>
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) {
+
+ }
+ }
+
}