diff options
author | 2018-04-06 09:57:16 -0500 | |
---|---|---|
committer | 2018-04-10 10:49:25 -0500 | |
commit | 9b0ed8da9474c99c13fbdff62894c09311cf9036 (patch) | |
tree | 5e63ccd07951ddcc3333130560e32b9ef973c6e0 /auth/auth-core/src/test/java | |
parent | 1b6fe335be7f1dfbf83e87db016506c3a4f7c413 (diff) |
Improve JUnit test coverage
* Fixed a typo in DenialOfServiceTaf
* Added a JUnit for DenialOfServiceTaf
* Cleaned up JU_Cached, JU_AuthzEnv (WIP)
Issue-ID: AAF-128
Change-Id: I76ace8aff3f72538f40068f6cc9c80f24aee7403
Signed-off-by: IanHowell <ian.howell@att.com>
Increase coverage in cadi/client and cadi/core
Get coverage for Holder, NulTaf, and NullTafResp to 100%
Issue-ID: AAF-128
Change-Id: Ica83c29311801d499f922ccb4c33fb7f4e58f686
Signed-off-by: IanHowell <ian.howell@att.com>
Improve coverage of the Tafs
Issue-ID: AAF-128
Change-Id: I07f9ebee0a64c598047e74801a266898107783f7
Signed-off-by: IanHowell <ian.howell@att.com>
Improve test coverage of XReader
Issue-ID: AAF-128
Change-Id: I9b369b803743166027170b4a8ca50bd337e45b7b
Signed-off-by: IanHowell <ian.howell@att.com>
Improve coverage of GreatCircle
Issue-ID: AAF-128
Change-Id: Id5e41a481db1106d050fb216664c1aa1e07cef2a
Signed-off-by: IanHowell <ian.howell@att.com>
Suppress test output
Issue-ID: AAF-128
Change-Id: I7a7afe7617c81403d27baf89353f175d9cead165
Signed-off-by: IanHowell <ian.howell@att.com>
Move JU_DNSLocator to the correct package
Change-Id: Ic8feddf7444afcaaaa252a40d340116597533f46
Signed-off-by: IanHowell <ian.howell@att.com>
Diffstat (limited to 'auth/auth-core/src/test/java')
-rw-r--r-- | auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java | 85 |
1 files changed, 47 insertions, 38 deletions
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java index 6413b099..8630aadf 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java @@ -21,87 +21,97 @@ ******************************************************************************/ package org.onap.aaf.auth.env.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.*; import static org.mockito.Mockito.mock; +import org.junit.*; import java.io.IOException; import java.io.InputStream; +import java.io.PrintStream; +import java.io.ByteArrayOutputStream; import java.util.Properties; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; import org.onap.aaf.auth.env.AuthzEnv; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.PropAccess; -import org.powermock.modules.junit4.PowerMockRunner; +import org.onap.aaf.cadi.config.Config; -import junit.framework.Assert; - -@RunWith(PowerMockRunner.class) public class JU_AuthzEnv { - private static final org.onap.aaf.cadi.Access.Level DEBUG = null; + AuthzEnv authzEnv; - enum Level {DEBUG, INFO, AUDIT, INIT, WARN, ERROR}; + + ByteArrayOutputStream outStream; + ByteArrayOutputStream errStream; @Before - public void setUp(){ - PropAccess access = null; - Properties props = null; + public void setUp() { + outStream = new ByteArrayOutputStream(); + errStream = new ByteArrayOutputStream(); + + System.setOut(new PrintStream(outStream)); + System.setErr(new PrintStream(errStream)); + authzEnv = new AuthzEnv(); + } + + @After + public void tearDown() { + System.setOut(System.out); + System.setErr(System.err); + } + + @Test + @SuppressWarnings("unused") + public void testConstructors() { AuthzEnv authzEnv1 = new AuthzEnv("Test"); - AuthzEnv authzEnv2 = new AuthzEnv(props); - AuthzEnv authzEnv3 = new AuthzEnv(access); + AuthzEnv authzEnv2 = new AuthzEnv((PropAccess)null); + AuthzEnv authzEnv3 = new AuthzEnv((Properties)null); } @Test public void testTransRate() { - Long Result = authzEnv.transRate(); - assertNotNull(Result); + Long Result = authzEnv.transRate(); + assertNotNull(Result); } @Test public void checkNewTransNoAvg() { - - Assert.assertNotNull(authzEnv.newTransNoAvg()); + assertNotNull(authzEnv.newTransNoAvg()); } @Test public void checkNewTrans() { - Assert.assertNotNull(authzEnv.newTrans()); + assertNotNull(authzEnv.newTrans()); } @Test public void checkPropAccess() { - Assert.assertNotNull(authzEnv.access()); + assertNotNull(authzEnv.access()); } @Test public void checkgetProperties() { //TODO:[GABE]No setter for this, add? - Assert.assertNotNull(authzEnv.getProperties()); - Assert.assertNotNull(authzEnv.getProperties("test")); + assertNotNull(authzEnv.getProperties()); + assertNotNull(authzEnv.getProperties("test")); } @Test public void checkPropertyGetters(){ authzEnv.setProperty("key","value"); - Assert.assertEquals(authzEnv.getProperty("key"), "value"); - Assert.assertEquals(authzEnv.getProperty("key","value"), "value"); + assertEquals(authzEnv.getProperty("key"), "value"); + assertEquals(authzEnv.getProperty("key","value"), "value"); } @Test public void checkPropertySetters(){ - Assert.assertEquals(authzEnv.getProperty("key","value"), authzEnv.setProperty("key","value")); + assertEquals(authzEnv.getProperty("key","value"), authzEnv.setProperty("key","value")); } -// @Test(expected = IOException.class) //TODO: AAF-111 make fail not happen -// public void testDecryptException() throws IOException{ -// String encrypted = "enc:"; -// authzEnv.setProperty(Config.CADI_KEYFILE, "test");//TODO: Figure out setter for this -// authzEnv.decrypt(encrypted, true); -// authzEnv.decrypt("", false); //TODO: AAF-111 fail without logging a fail -// } + @Test(expected = IOException.class) + public void testDecryptException() throws IOException{ + authzEnv.setProperty(Config.CADI_KEYFILE, "test/keyfile"); + authzEnv.decrypt(null, false); + } @Test public void testDecrypt() throws IOException{ @@ -114,7 +124,7 @@ public class JU_AuthzEnv { public void testClassLoader() { ClassLoader cLoad = mock(ClassLoader.class); cLoad = authzEnv.classLoader(); - Assert.assertNotNull(cLoad); + assertNotNull(cLoad); } @Test @@ -149,10 +159,9 @@ public class JU_AuthzEnv { Access.Level lvl = Access.Level.DEBUG; Access.Level lvl1 = Access.Level.AUDIT; boolean test = authzEnv.willLog(lvl); - Assert.assertFalse(test); + assertFalse(test); test = authzEnv.willLog(lvl1); - Assert.assertTrue(test); - + assertTrue(test); } @Test |