summaryrefslogtreecommitdiffstats
path: root/LogParser/src/test/java/org
diff options
context:
space:
mode:
authorramverma <ramkrishna.verma@gmail.com>2018-02-19 17:12:19 +0000
committerramverma <ram.krishna.verma@ericsson.com>2018-02-20 17:03:53 +0000
commitc423723456ffcdedb46e06054954b49129eedcbb (patch)
tree6f5afbf5ae8d036140032562c181a7930e71c1b2 /LogParser/src/test/java/org
parentf36850d62ae77760daef9972a3c31042ad19480d (diff)
Add Junit to policy/engine LogParser
Junits to improve the coverage of LogParser to 55% Change-Id: Icddecd7a2904d5a679910f7d5fcac891b3698c66 Issue-ID: POLICY-599 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'LogParser/src/test/java/org')
-rw-r--r--LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java71
1 files changed, 71 insertions, 0 deletions
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 62af131a8..09ffa4254 100644
--- a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
+++ b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java
@@ -52,6 +52,8 @@ public class ParseLogTest {
private static Logger logger = FlexLogger.getLogger(ParseLogTest.class);
private Properties config = new Properties();
private String configFile;
+ private String configFileDebug;
+ private String configFileError;
private String testFile1;
private String testFile2;
private IntegrityMonitor im;
@@ -70,12 +72,22 @@ public class ParseLogTest {
Mockito.doNothing().when(im).endTransaction();
ClassLoader classLoader = getClass().getClassLoader();
configFile = classLoader.getResource("test_config.properties").getFile();
+ configFileDebug = classLoader.getResource("test_config_debug.properties").getFile();
+ configFileError = classLoader.getResource("test_config_error.properties").getFile();
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(configFile);
+ Matcher matcherDebug = pattern.matcher(configFileDebug);
+ Matcher matcherError = pattern.matcher(configFileError);
if (matcher.find()) {
configFile = configFile.substring(1);
}
+ if (matcherDebug.find()) {
+ configFileDebug = configFileDebug.substring(1);
+ }
+ if (matcherError.find()) {
+ configFileError = configFileError.substring(1);
+ }
testFile1 = classLoader.getResource("LineTest.txt").getFile();
testFile2 = classLoader.getResource("LineTest2.txt").getFile();
@@ -142,6 +154,56 @@ public class ParseLogTest {
}
@Test
+ public void testGetPropertiesValue_1() {
+
+ logger.debug("testGetPropertiesValue: enter");
+
+ config = new Properties();
+ config.put("RESOURCE_NAME", "logparser_pap01");
+ config.put("JDBC_DRIVER", "org.mariadb.jdbc.Driver");
+ config.put("JDBC_URL", "jdbc:mariadb://localhost:3306/");
+ config.put("JDBC_USER", "root");
+ config.put("JDBC_PASSWORD", "password");
+ config.put("JMX_URL", "service:jmx:rmi:///jndi/rmi://localhost:9998/jmxrmi");
+ config.put("SERVER", "password");
+ config.put("JDBC_PASSWORD", "https://localhost:9091/pap/");
+ config.put("LOGTYPE", "PAP");
+ config.put("LOGPATH", "C:\\Workspaces\\HealthCheck\\debug\\pap-rest.log");
+ config.put("PARSERLOGPATH", "IntegrityMonitor.log");
+
+ final Properties returnConfig = ParseLog.getPropertiesValue(configFileDebug);
+ logger.debug("testGetPropertiesValue: returnConfig: " + returnConfig);
+ assertEquals(config.get("RESOURCE_NAME"), returnConfig.get("RESOURCE_NAME"));
+
+ logger.debug("testGetPropertiesValue_1: exit");
+ }
+
+ @Test
+ public void testGetPropertiesValue_2() {
+
+ logger.debug("testGetPropertiesValue: enter");
+
+ config = new Properties();
+ config.put("RESOURCE_NAME", "logparser_pap01");
+ config.put("JDBC_DRIVER", "org.mariadb.jdbc.Driver");
+ config.put("JDBC_URL", "jdbc:mariadb://localhost:3306/");
+ config.put("JDBC_USER", "root");
+ config.put("JDBC_PASSWORD", "password");
+ config.put("JMX_URL", "service:jmx:rmi:///jndi/rmi://localhost:9998/jmxrmi");
+ config.put("SERVER", "password");
+ config.put("JDBC_PASSWORD", "https://localhost:9091/pap/");
+ config.put("LOGTYPE", "PAP");
+ config.put("LOGPATH", "C:\\Workspaces\\HealthCheck\\error\\pap-rest.log");
+ config.put("PARSERLOGPATH", "IntegrityMonitor.log");
+
+ final Properties returnConfig = ParseLog.getPropertiesValue(configFileError);
+ logger.debug("testGetPropertiesValue: returnConfig: " + returnConfig);
+ assertEquals(config.get("RESOURCE_NAME"), returnConfig.get("RESOURCE_NAME"));
+
+ logger.debug("testGetPropertiesValue_2: exit");
+ }
+
+ @Test
public void testGetPropertiesFail() {
logger.debug("testGetPropertiesFail: enter");
@@ -497,4 +559,13 @@ public class ParseLogTest {
logger.debug("testProcess: exit");
}
+
+ @Test
+ public void testMain() {
+ try {
+ ParseLog.main(new String[] {});
+ } catch (final Exception e) {
+ logger.debug("exception occured while executing the test: exit");
+ }
+ }
} \ No newline at end of file