summaryrefslogtreecommitdiffstats
path: root/misc/env
diff options
context:
space:
mode:
authorSai Gandham <sg481n@att.com>2018-05-11 18:28:13 +0000
committerSai Gandham <sg481n@att.com>2018-05-11 18:28:34 +0000
commitd249df5d303d82be6d67340245cae6c2508f6cd6 (patch)
tree5db7ba90e77b82a920d834605d4c1837c4e8504f /misc/env
parentc486733c0160bfb16bb75a008abe4e6a2616cb44 (diff)
Increase code coverage for auth misc
Issue-ID: AAF-129 Change-Id: Ibf8c2895bd19ce6d8aaba07b2d3159f7356a2d66 Signed-off-by: Sai Gandham <sg481n@att.com>
Diffstat (limited to 'misc/env')
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java62
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java56
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java7
3 files changed, 124 insertions, 1 deletions
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
new file mode 100644
index 00000000..e3f54929
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.misc.env.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aaf.misc.env.APIException;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ Log4JLogTarget.class, Logger.class })
+public class JU_Log4JLogTargetTest {
+
+ @Mock
+ Logger log;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(Logger.class);
+ when(Logger.getLogger("Info")).thenReturn(log);
+ when(log.isEnabledFor(Level.DEBUG)).thenReturn(false);
+ }
+
+ @Test
+ public void test() throws APIException {
+ Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);
+ Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);
+
+ assertFalse(target1.isLoggable());
+
+ }
+} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
new file mode 100644
index 00000000..ce2245bf
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
@@ -0,0 +1,56 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.misc.env.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class JU_SplitTest {
+
+ @Test
+ public void testSplit() {
+ String[] splits = Split.split('c', "character c to break string");
+
+ assertEquals(splits.length, 4);
+ assertEquals(splits[0], "");
+ assertEquals(splits[1], "hara");
+ assertEquals(splits[2], "ter ");
+ assertEquals(splits[3], " to break string");
+ }
+
+ @Test
+ public void testSplitTrim() {
+ String[] splits = Split.splitTrim('c', "character c to break string", 5);
+
+ assertEquals(splits.length, 5);
+ assertEquals(splits[0], "");
+ assertEquals(splits[1], "hara");
+ assertEquals(splits[2], "ter");
+ assertEquals(splits[3], "to break string");
+ assertEquals(splits[4], null);
+
+ splits = Split.splitTrim('c', " character ", 1);
+ assertEquals(splits.length, 1);
+ assertEquals(splits[0], "character");
+ }
+}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
index e3f90de1..11f03d52 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
@@ -60,6 +60,8 @@ public class JU_PoolTest {
content = t;
}
});
+ Pool.Pooled<Integer> pooled = new Pool.Pooled<Integer>(new Integer(123), pool, LogTarget.SYSOUT);
+ Pool.Pooled<Integer> pooled1 = new Pool.Pooled<Integer>(new Integer(123), null, LogTarget.SYSOUT);
try {
// pool.drain();
assertEquals("Should return intial value", 0, pool.get().content);
@@ -74,8 +76,11 @@ public class JU_PoolTest {
pool.drain();
assertEquals("Should remove last from pool", 17, pool.get(LogTarget.SYSOUT).content);
+ pool.setMaxRange(10);
+ assertEquals(10, pool.getMaxRange());
+ pooled.toss();
+ pooled1.toss();
} catch (APIException e) {
}
}
-
}