X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=LogParser%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fxacml%2Fparser%2FParseLogTest.java;h=09ffa42546aaf5884865d66de395c46ea0e74e1b;hb=c423723456ffcdedb46e06054954b49129eedcbb;hp=62af131a8182d7bac9245b2ae727948ec1f1c631;hpb=f36850d62ae77760daef9972a3c31042ad19480d;p=policy%2Fengine.git 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(); @@ -141,6 +153,56 @@ public class ParseLogTest { logger.debug("testGetPropertiesValue: exit"); } + @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() { @@ -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