-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed dependency of Turf library on services-core
- Loading branch information
âÂÂosanaâÂÂ
committed
Mar 20, 2019
1 parent
82837f3
commit fea0fc1
Showing
21 changed files
with
296 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
services-geojson/src/test/java/com/mapbox/geojson/TestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.mapbox.geojson; | ||
|
||
import com.google.gson.JsonParser; | ||
|
||
import org.hamcrest.Matchers; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.io.Serializable; | ||
import java.util.Scanner; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.junit.Assert.assertThat; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class TestUtils { | ||
|
||
public static final double DELTA = 1E-10; | ||
public static final String ACCESS_TOKEN = "pk.XXX"; | ||
|
||
public void compareJson(String expectedJson, String actualJson) { | ||
JsonParser parser = new JsonParser(); | ||
assertThat(parser.parse(actualJson), Matchers.equalTo(parser.parse(expectedJson))); | ||
} | ||
|
||
protected String loadJsonFixture(String filename) throws IOException { | ||
ClassLoader classLoader = getClass().getClassLoader(); | ||
InputStream inputStream = classLoader.getResourceAsStream(filename); | ||
Scanner scanner = new Scanner(inputStream, UTF_8.name()).useDelimiter("\\A"); | ||
return scanner.hasNext() ? scanner.next() : ""; | ||
} | ||
|
||
public static <T extends Serializable> byte[] serialize(T obj) | ||
throws IOException { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
ObjectOutputStream oos = new ObjectOutputStream(baos); | ||
oos.writeObject(obj); | ||
oos.close(); | ||
return baos.toByteArray(); | ||
} | ||
|
||
public static <T extends Serializable> T deserialize(byte[] bytes, Class<T> cl) | ||
throws IOException, ClassNotFoundException { | ||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | ||
ObjectInputStream ois = new ObjectInputStream(bais); | ||
Object object = ois.readObject(); | ||
return cl.cast(object); | ||
} | ||
|
||
/** | ||
* Comes from Google Utils Test Case | ||
*/ | ||
public static void expectNearNumber(double expected, double actual, double epsilon) { | ||
assertTrue(String.format("Expected %f to be near %f", actual, expected), | ||
Math.abs(expected - actual) <= epsilon); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.