summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-02-27 19:58:51 +0000
committerGerrit Code Review <gerrit@onap.org>2018-02-27 19:58:51 +0000
commit0b437d897ed2f18df6d89987056faa945531c033 (patch)
tree6584713692d546641938b215e3e18ff8be18a7ff
parent005ae324e9b123ecf7d5fbcc9f6a6e6b1cf44040 (diff)
parentd4d97233bf8aae575241080909370f81f68b6e82 (diff)
Merge "Add Junit to policy/engine LogParser package"
-rw-r--r--LogParser/pom.xml14
-rw-r--r--LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java33
-rw-r--r--LogParser/src/test/resources/test_config_debug.properties2
-rw-r--r--LogParser/src/test/resources/test_config_error.properties2
4 files changed, 49 insertions, 2 deletions
diff --git a/LogParser/pom.xml b/LogParser/pom.xml
index 8bf50b083..0bd21a8de 100644
--- a/LogParser/pom.xml
+++ b/LogParser/pom.xml
@@ -130,7 +130,19 @@
<artifactId>cadi-aaf</artifactId>
</exclusion>
</exclusions>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.7.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>1.7.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
index 09ffa4254..91de46440 100644
--- a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
+++ b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
@@ -37,6 +37,7 @@ import java.util.regex.Pattern;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.policy.common.im.AdministrativeStateException;
import org.onap.policy.common.im.IntegrityMonitor;
@@ -45,8 +46,12 @@ import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.xacml.parser.LogEntryObject.LOGTYPE;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
-
+@PrepareForTest({ParseLogTest.class, IntegrityMonitor.class})
+@RunWith(PowerMockRunner.class)
public class ParseLogTest {
private static Logger logger = FlexLogger.getLogger(ParseLogTest.class);
@@ -568,4 +573,30 @@ public class ParseLogTest {
logger.debug("exception occured while executing the test: exit");
}
}
+
+ @Test
+ public void testMainDebug() {
+ try {
+ final Properties returnConfig = ParseLog.getPropertiesValue(configFileDebug);
+ PowerMockito.mockStatic(IntegrityMonitor.class);
+ Mockito.when(IntegrityMonitor.getInstance("test", returnConfig)).thenReturn(im);
+ ParseLog.main(new String[] {});
+ Thread.sleep(30000);
+ } catch (final Exception e) {
+ logger.debug("exception occured while executing the test: exit");
+ }
+ }
+
+ @Test
+ public void testMainError() {
+ try {
+ final Properties returnConfig = ParseLog.getPropertiesValue(configFileError);
+ PowerMockito.mockStatic(IntegrityMonitor.class);
+ Mockito.when(IntegrityMonitor.getInstance("test", returnConfig)).thenReturn(im);
+ ParseLog.main(new String[] {});
+ Thread.sleep(30000);
+ } catch (final Exception e) {
+ logger.debug("exception occured while executing the test: exit");
+ }
+ }
} \ No newline at end of file
diff --git a/LogParser/src/test/resources/test_config_debug.properties b/LogParser/src/test/resources/test_config_debug.properties
index 66b417339..3e9d614fe 100644
--- a/LogParser/src/test/resources/test_config_debug.properties
+++ b/LogParser/src/test/resources/test_config_debug.properties
@@ -29,3 +29,5 @@ SERVER=https://localhost:9091/pap/
LOGTYPE=PAP
LOGPATH=/Workspaces/HealthCheck/debug/pap-rest.log
PARSERLOGPATH=IntegrityMonitor.log
+CHECK_INTERVAL=600000
+TIME_FRAME=5 \ No newline at end of file
diff --git a/LogParser/src/test/resources/test_config_error.properties b/LogParser/src/test/resources/test_config_error.properties
index 3c5c07019..2348493b5 100644
--- a/LogParser/src/test/resources/test_config_error.properties
+++ b/LogParser/src/test/resources/test_config_error.properties
@@ -29,3 +29,5 @@ SERVER=https://localhost:9091/pap/
LOGTYPE=PAP
LOGPATH=/Workspaces/HealthCheck/error/pap-rest.log
PARSERLOGPATH=IntegrityMonitor.log
+CHECK_INTERVAL=600000
+TIME_FRAME=five \ No newline at end of file