22
33import java .io .File ;
44import java .io .IOException ;
5+ import java .net .URISyntaxException ;
6+ import java .net .URL ;
57import java .nio .file .Files ;
68import java .nio .file .Path ;
79import java .nio .file .Paths ;
@@ -11,7 +13,13 @@ public class TestUtils {
1113 private final String scanResourcePath ;
1214
1315 public TestUtils () {
14- scanResourcePath = TestUtils .class .getResource ("/" ).getPath ();
16+ String path = "" ;
17+ try {
18+ path = new File (TestUtils .class .getResource ("." ).toURI ()).toPath ().toString ().replaceAll ("\\ \\ " , "/" );
19+ } catch (URISyntaxException e ) {
20+ throw new RuntimeException (e );
21+ }
22+ scanResourcePath = path ;
1523 }
1624
1725 /**
@@ -21,11 +29,12 @@ public TestUtils() {
2129 */
2230 public File getReportJson (String fileName ) {
2331 try {
24- Path inputPath = Paths .get (TestUtils .class .getResource ("/" + fileName + ".json" ).getPath ());
32+ URL resourceUrl = TestUtils .class .getResource ("/" + fileName + ".json" );
33+ Path inputPath = new File (resourceUrl .toURI ()).toPath ();
2534 String content = new String (Files .readAllBytes (inputPath ));
2635 content = content .replaceAll ("/java/src/test/resources/" , scanResourcePath );
2736 Files .write (Paths .get (scanResourcePath + fileName + ".tmp.json" ), content .getBytes ());
28- } catch (IOException e ) {
37+ } catch (IOException | URISyntaxException e ) {
2938 e .printStackTrace ();
3039 }
3140 return new File (scanResourcePath + fileName + ".tmp.json" );
0 commit comments