From 7e547eaa55920dfbc9691eab33bb728395b50cf2 Mon Sep 17 00:00:00 2001 From: Ravindra Bakkamanthala Date: Mon, 15 May 2017 12:53:18 -0400 Subject: Policy TestSuite Enabled Change-Id: I9f98c7dcdcf98713d73544956d873a84fc82adf7 Signed-off-by: Ravindra Bakkamanthala --- LogParser/parserlog.properties | 6 ++-- LogParser/pom.xml | 14 +++++++- .../org/openecomp/xacml/parser/ParseLogTest.java | 42 +++++++--------------- 3 files changed, 29 insertions(+), 33 deletions(-) (limited to 'LogParser') diff --git a/LogParser/parserlog.properties b/LogParser/parserlog.properties index 8b0ac753f..caac6c378 100644 --- a/LogParser/parserlog.properties +++ b/LogParser/parserlog.properties @@ -21,15 +21,15 @@ #Health Check Values RESOURCE_NAME=logparser_pap01 javax.persistence.jdbc.driver=com.mysql.jdbc.Driver -javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/xacml +javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/ecomp_sdk javax.persistence.jdbc.user=policy_user -javax.persistence.jdbc.password=password +javax.persistence.jdbc.password=policy_user #Log Parser application values JDBC_DRIVER=com.mysql.jdbc.Driver JDBC_URL=jdbc:mysql://localhost:3306/log JDBC_USER=policy_user -JDBC_PASSWORD=password +JDBC_PASSWORD=policy_user SERVER=https://localhost:9091/pap/ LOGTYPE=PAP LOGPATH=C:\\Workspaces\\HealthCheck\\pap-rest.log diff --git a/LogParser/pom.xml b/LogParser/pom.xml index e7659796b..20e06045a 100644 --- a/LogParser/pom.xml +++ b/LogParser/pom.xml @@ -50,6 +50,12 @@ org.openecomp.policy.common integrity-monitor ${common-modules.version} + + + org.powermock + powermock-api-mockito + + log4j @@ -75,7 +81,13 @@ org.mockito mockito-core - 1.9.5 + 2.7.22 + + + + org.mockito + mockito-all + 1.10.19 diff --git a/LogParser/src/test/java/org/openecomp/xacml/parser/ParseLogTest.java b/LogParser/src/test/java/org/openecomp/xacml/parser/ParseLogTest.java index dd4007735..621f39742 100644 --- a/LogParser/src/test/java/org/openecomp/xacml/parser/ParseLogTest.java +++ b/LogParser/src/test/java/org/openecomp/xacml/parser/ParseLogTest.java @@ -20,39 +20,31 @@ package org.openecomp.xacml.parser; -/*import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.text.SimpleDateFormat; -import java.util.Collections; import java.util.Date; import java.util.Properties; -import org.openecomp.policy.common.im.AdministrativeStateException; -import org.openecomp.policy.common.im.IntegrityMonitor; -import org.openecomp.policy.common.im.StandbyStatusException; - import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import org.openecomp.xacml.parser.LogEntryObject; -import org.openecomp.xacml.parser.ParseLog; +import org.openecomp.policy.common.im.AdministrativeStateException; +import org.openecomp.policy.common.im.IntegrityMonitor; +import org.openecomp.policy.common.im.StandbyStatusException; import org.openecomp.xacml.parser.LogEntryObject.LOGTYPE; public class ParseLogTest { - private ParseLog logParser = new ParseLog(); private Properties config = new Properties(); private String configFile = "test_config.properties"; - private static Properties myProp; - private static Properties systemProps; - private static String resourceName; private IntegrityMonitor im; @@ -61,9 +53,6 @@ public class ParseLogTest { System.setProperty("com.sun.management.jmxremote.port", "9998"); im = Mockito.mock(IntegrityMonitor.class); - // Need PowerMockito for mocking static method getInstance(...) - // PowerMockito.mockStatic(IntegrityMonitor.class); - try { Mockito.doNothing().when(im).startTransaction(); } catch (StandbyStatusException | AdministrativeStateException e) { @@ -77,23 +66,21 @@ public class ParseLogTest { public void tearDown() { File file = new File("nonExistFile.txt"); file.delete(); -// systemProps.remove("com.sun.management.jmxremote.port"); } - @Test + //@Test public void testMain() { try { - - logParser.main(null); + ParseLog.main(null); } catch (Exception e) { - //fail(); + fail(); } } @Test public void testCountLines() throws IOException { String fileName = "LineTest.txt"; - int returnValue = logParser.countLines(fileName); + int returnValue = ParseLog.countLines(fileName); assertEquals(9, returnValue); } @@ -120,7 +107,7 @@ public class ParseLogTest { config.put("LOGPATH", "C:\\Workspaces\\HealthCheck\\pap-rest.log"); config.put("PARSERLOGPATH", "IntegrityMonitor.log"); - Properties returnConfig = logParser.getPropertiesValue(configFile); + Properties returnConfig = ParseLog.getPropertiesValue(configFile); assertEquals(config.get("RESOURCE_NAME"), returnConfig.get("RESOURCE_NAME")); @@ -137,8 +124,8 @@ public class ParseLogTest { public void testParseDate(){ String line = "2016-02-23 08:07:30"; Date returnValue = ParseLog.parseDate(line, "yyyy-MM-dd HH:mm:ss", false); - - assertEquals("Tue Feb 23 08:07:30 CST 2016", returnValue.toString()); + line = returnValue.toString().substring(0, returnValue.toString().lastIndexOf(":30")+3); + assertEquals("Tue Feb 23 08:07:30", line); } @Test @@ -343,14 +330,12 @@ public class ParseLogTest { @Test public void testPullOutLogValuesNull(){ // Open the file - FileInputStream fstream; LogEntryObject retrunObject = ParseLog.pullOutLogValues("", "Console"); assertEquals(null, retrunObject); } @Test public void testLogEntryObject(){ - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); // Open the file @@ -379,5 +364,4 @@ public class ParseLogTest { Mockito.doNothing().when(im).endTransaction(); ParseLog.process(line, "pap"); } -} -*/ \ No newline at end of file +} \ No newline at end of file -- cgit 1.2.3-korg