diff options
author | Jorge Hernandez <jh1730@att.com> | 2018-02-20 18:04:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-02-20 18:04:49 +0000 |
commit | 61e228f56bc39ce291ed8dc7a3401bee7a47e95d (patch) | |
tree | 6366f92aed70b5846c610a46bb1dd6d31f479303 | |
parent | 0b9d8588100599d591c27f390c40fcb592a02159 (diff) | |
parent | c423723456ffcdedb46e06054954b49129eedcbb (diff) |
Merge "Add Junit to policy/engine LogParser"
3 files changed, 133 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 diff --git a/LogParser/src/test/resources/test_config_debug.properties b/LogParser/src/test/resources/test_config_debug.properties new file mode 100644 index 000000000..66b417339 --- /dev/null +++ b/LogParser/src/test/resources/test_config_debug.properties @@ -0,0 +1,31 @@ +### +# ============LICENSE_START======================================================= +# LogParser +# ================================================================================ +# Copyright (C) 2018 Ericsson. 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========================================================= +### + + +RESOURCE_NAME=logparser_pap01 +JDBC_DRIVER=org.mariadb.jdbc.Driver +JDBC_URL=jdbc:mariadb://localhost:3306/ +JDBC_USER=root +JDBC_PASSWORD=password +jmx_url=service:jmx:rmi:///jndi/rmi://localhost:9996/jmxrmi +SERVER=https://localhost:9091/pap/ +LOGTYPE=PAP +LOGPATH=/Workspaces/HealthCheck/debug/pap-rest.log +PARSERLOGPATH=IntegrityMonitor.log diff --git a/LogParser/src/test/resources/test_config_error.properties b/LogParser/src/test/resources/test_config_error.properties new file mode 100644 index 000000000..3c5c07019 --- /dev/null +++ b/LogParser/src/test/resources/test_config_error.properties @@ -0,0 +1,31 @@ +### +# ============LICENSE_START======================================================= +# LogParser +# ================================================================================ +# Copyright (C) 2018 Ericsson. 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========================================================= +### + + +RESOURCE_NAME=logparser_pap01 +JDBC_DRIVER=org.mariadb.jdbc.Driver +JDBC_URL=jdbc:mariadb://localhost:3306/ +JDBC_USER=root +JDBC_PASSWORD=password +jmx_url=service:jmx:rmi:///jndi/rmi://localhost:9996/jmxrmi +SERVER=https://localhost:9091/pap/ +LOGTYPE=PAP +LOGPATH=/Workspaces/HealthCheck/error/pap-rest.log +PARSERLOGPATH=IntegrityMonitor.log |