Skip to content

Commit 367863c

Browse files
Sebastian WendorfSebastian Wendorf
authored andcommitted
Made java integration tests Windows-compatible
1 parent cd15de9 commit 367863c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

java/src/test/java/org/jqassistant/plugin/typescript/TestUtils.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.net.URISyntaxException;
6+
import java.net.URL;
57
import java.nio.file.Files;
68
import java.nio.file.Path;
79
import 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

Comments
 (0)