Skip to content

Commit 9c8e265

Browse files
Kyle Madsenkmadsen
authored andcommitted
Fix tests running locally
1 parent 9cae544 commit 9c8e265

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

services-turf/src/test/java/com/mapbox/turf/TestUtils.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
import java.io.ByteArrayOutputStream;
99
import java.io.File;
1010
import java.io.IOException;
11-
import java.io.InputStream;
1211
import java.io.ObjectInputStream;
1312
import java.io.ObjectOutputStream;
1413
import java.io.Serializable;
1514
import java.net.URL;
15+
import java.nio.file.Files;
16+
import java.nio.file.Paths;
1617
import java.util.ArrayList;
1718
import java.util.List;
18-
import java.util.Scanner;
1919

2020
import static java.nio.charset.StandardCharsets.UTF_8;
2121
import static org.junit.Assert.assertThat;
2222
import static org.junit.Assert.assertTrue;
23+
import static org.junit.Assert.fail;
2324

2425
public class TestUtils {
2526

@@ -32,10 +33,14 @@ public void compareJson(String expectedJson, String actualJson) {
3233
}
3334

3435
protected String loadJsonFixture(String filename) {
35-
ClassLoader classLoader = getClass().getClassLoader();
36-
InputStream inputStream = classLoader.getResourceAsStream(filename);
37-
Scanner scanner = new Scanner(inputStream, UTF_8.name()).useDelimiter("\\A");
38-
return scanner.hasNext() ? scanner.next() : "";
36+
try {
37+
String filepath = "src/test/resources/" + filename;
38+
byte[] encoded = Files.readAllBytes(Paths.get(filepath));
39+
return new String(encoded, UTF_8);
40+
} catch (IOException e) {
41+
fail("Unable to load " + filename);
42+
return "";
43+
}
3944
}
4045

4146
public static <T extends Serializable> byte[] serialize(T obj)

0 commit comments

Comments
 (0)