summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2019-02-26 13:38:25 +0100
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2019-02-26 15:06:21 +0100
commit5e41fd44f2cae99f99d20e0cbf692c03b2bff40f (patch)
treec7c88ba594a01a6d03de4a85536eff8809901bbf
parent19e66c8bfa20a5e14a76fb1e0aaec7d9dcc03196 (diff)
downloadqtlocation-mapboxgl-5e41fd44f2cae99f99d20e0cbf692c03b2bff40f.tar.gz
[android] clear singleton instance of Mapbox after running unit test suite
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java
index 5003793998..415953d747 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk;
import android.content.Context;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -68,6 +69,11 @@ public class MapboxTest {
assertFalse(Mapbox.isAccessTokenValid("blabla"));
}
+ @After
+ public void after() {
+ clearMapboxSingleton();
+ }
+
private void injectMapboxSingleton(String accessToken) {
Mapbox mapbox = new Mapbox(context, accessToken);
try {
@@ -78,4 +84,14 @@ public class MapboxTest {
throw new AssertionError();
}
}
+
+ private void clearMapboxSingleton() {
+ try {
+ Field field = Mapbox.class.getDeclaredField("INSTANCE");
+ field.setAccessible(true);
+ field.set(field, null);
+ } catch (Exception exception) {
+ throw new AssertionError();
+ }
+ }
}