diff --git a/parse/build.gradle b/parse/build.gradle index 2cb656e9..aa994ebf 100644 --- a/parse/build.gradle +++ b/parse/build.gradle @@ -18,6 +18,7 @@ android { includeAndroidResources = true all { + jvmArgs '--add-opens=java.base/java.io=ALL-UNNAMED' // Configure JaCoCo options jacoco { includeNoLocationClasses = true diff --git a/parse/src/main/java/com/parse/ParseUriHttpBody.java b/parse/src/main/java/com/parse/ParseUriHttpBody.java index c6ab7748..9dbb1ec6 100644 --- a/parse/src/main/java/com/parse/ParseUriHttpBody.java +++ b/parse/src/main/java/com/parse/ParseUriHttpBody.java @@ -37,7 +37,8 @@ private static long getUriLength(Uri uri) { long length = -1; try (Cursor cursor = - getApplicationContext() + ParsePlugins.get() + .applicationContext() .getContentResolver() .query(uri, null, null, null, null, null)) { if (cursor != null && cursor.moveToFirst()) { diff --git a/parse/src/test/java/com/parse/ParseFileControllerTest.java b/parse/src/test/java/com/parse/ParseFileControllerTest.java index 7bc9c829..3e462aae 100644 --- a/parse/src/test/java/com/parse/ParseFileControllerTest.java +++ b/parse/src/test/java/com/parse/ParseFileControllerTest.java @@ -20,7 +20,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.content.Context; import android.net.Uri; +import androidx.test.platform.app.InstrumentationRegistry; import com.parse.boltsinternal.Task; import com.parse.http.ParseHttpRequest; import com.parse.http.ParseHttpResponse; @@ -42,7 +44,7 @@ // For org.json @RunWith(RobolectricTestRunner.class) -public class ParseFileControllerTest { +public class ParseFileControllerTest extends ResetPluginsParseTest { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -216,6 +218,10 @@ public void testSaveAsyncSuccessWithUri() throws Exception { when(restClient.execute(any(ParseHttpRequest.class))).thenReturn(mockResponse); File root = temporaryFolder.getRoot(); + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); + ParsePlugins plugins = mock(ParsePlugins.class); + when(plugins.applicationContext()).thenReturn(context); + ParsePlugins.set(plugins); ParseFileController controller = new ParseFileController(restClient, root); File file = new File(root, "test");