From 81d5df62133aa7bdb9c64b3d227a2838a0a2b83c Mon Sep 17 00:00:00 2001 From: amshegokar Date: Thu, 7 Sep 2017 11:05:47 +0530 Subject: Use Reg Ex Use Reg Ex for Drive letter Issue-ID: POLICY-203 Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf9b Signed-off-by: amshegokar --- LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'LogParser/src/test/java/org/onap') 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 b02a1435d..c12797f28 100644 --- a/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java +++ b/LogParser/src/test/java/org/onap/xacml/parser/ParseLogTest.java @@ -31,6 +31,8 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.Date; import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.junit.After; import org.junit.Before; @@ -57,6 +59,7 @@ public class ParseLogTest { public void setUp() throws Exception { System.setProperty("com.sun.management.jmxremote.port", "9998"); im = Mockito.mock(IntegrityMonitor.class); + String regex = "^\\/[a-zA-Z]\\:\\/"; try { Mockito.doNothing().when(im).startTransaction(); @@ -66,7 +69,10 @@ public class ParseLogTest { Mockito.doNothing().when(im).endTransaction(); ClassLoader classLoader = getClass().getClassLoader(); configFile = classLoader.getResource("test_config.properties").getFile(); - if(configFile.startsWith("/C:/")){ + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(configFile); + + if (matcher.find()) { configFile = configFile.substring(1); } testFile1 = classLoader.getResource("LineTest.txt").getFile(); -- cgit 1.2.3-korg