summaryrefslogtreecommitdiffstats
path: root/auth/auth-core/src/test
diff options
context:
space:
mode:
authorJonathan Gathman <jonathan.gathman@att.com>2018-04-12 12:52:05 +0000
committerGerrit Code Review <gerrit@onap.org>2018-04-12 12:52:05 +0000
commitdcfee329193f2324196f5a1bda18a2d30f1277a4 (patch)
tree5597286fb87c8230ef5d36f4d2c5fb867b8e6721 /auth/auth-core/src/test
parent23a1c2ebc86885d2b62dc5b8afc842a3e730fdae (diff)
parent9b0ed8da9474c99c13fbdff62894c09311cf9036 (diff)
Merge "Improve JUnit test coverage"
Diffstat (limited to 'auth/auth-core/src/test')
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java85
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