X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=LogParser%2Fsrc%2Ftest%2Fjava%2Forg%2Fopenecomp%2Fxacml%2Fparser%2FParseLogTest.java;h=621f397429a9b6cba8838a81711b18341a71428b;hp=dd40077351147415c5a1b2fa498f1c9ae159722a;hb=7e547eaa55920dfbc9691eab33bb728395b50cf2;hpb=dda032f8bb161d54eb1f59de2b4a3efb774fc4d1 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