Increase code coverage for auth misc
[aaf/authz.git] / misc / env / src / test / java / org / onap / aaf / misc / env / impl / JU_Log4JLogTargetTest.java
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 (file)
index 0000000..e3f5492
--- /dev/null
@@ -0,0 +1,62 @@
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.env.impl;\r
+\r
+import static org.junit.Assert.assertFalse;\r
+import static org.powermock.api.mockito.PowerMockito.when;\r
+\r
+import org.apache.log4j.Level;\r
+import org.apache.log4j.Logger;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aaf.misc.env.APIException;\r
+import org.powermock.api.mockito.PowerMockito;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest({ Log4JLogTarget.class, Logger.class })\r
+public class JU_Log4JLogTargetTest {\r
+\r
+       @Mock\r
+       Logger log;\r
+\r
+       @Before\r
+       public void setup() {\r
+               MockitoAnnotations.initMocks(this);\r
+               PowerMockito.mockStatic(Logger.class);\r
+               when(Logger.getLogger("Info")).thenReturn(log);\r
+               when(log.isEnabledFor(Level.DEBUG)).thenReturn(false);\r
+       }\r
+\r
+       @Test\r
+       public void test() throws APIException {\r
+               Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);\r
+               Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);\r
+\r
+               assertFalse(target1.isLoggable());\r
+\r
+       }\r
+}
\ No newline at end of file