From b5985fb5667b3ee9b6a4a0675fb57f55e7a288b7 Mon Sep 17 00:00:00 2001 From: sg481n Date: Sun, 1 Oct 2017 21:06:52 +0000 Subject: Improve code coverage for aaf cadi modules Updated few testcases. Issue-ID: AAF-79 Change-Id: If0760b6f3e74d52fa5132224bf1e6f5e3099f0e4 Signed-off-by: sg481n --- .../test/java/org/onap/aaf/cadi/test/JU_Hash.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'core/src/test/java/org/onap/aaf/cadi/test/JU_Hash.java') 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) { + + } + } + } -- cgit 1.2.3-korg