diff --git a/buildSrc/src/main/java/KotlinCompiler.kt b/buildSrc/src/main/java/KotlinCompiler.kt index 51ee96b665a..6296b450446 100644 --- a/buildSrc/src/main/java/KotlinCompiler.kt +++ b/buildSrc/src/main/java/KotlinCompiler.kt @@ -27,7 +27,6 @@ object KotlinCompiler { "feature-session", "feature-sitepermissions", "feature-tabs", - "lib-fetch-okhttp", "samples-toolbar", "service-glean", "support-test", diff --git a/components/lib/fetch-okhttp/build.gradle b/components/lib/fetch-okhttp/build.gradle index 605fc9aad1d..b3935653ddc 100644 --- a/components/lib/fetch-okhttp/build.gradle +++ b/components/lib/fetch-okhttp/build.gradle @@ -30,6 +30,8 @@ dependencies { implementation project(':concept-fetch') + testImplementation project(':support-test') + testImplementation Dependencies.testing_junit testImplementation Dependencies.testing_robolectric testImplementation Dependencies.testing_mockito diff --git a/components/lib/fetch-okhttp/src/main/java/mozilla/components/lib/fetch/okhttp/OkHttpClient.kt b/components/lib/fetch-okhttp/src/main/java/mozilla/components/lib/fetch/okhttp/OkHttpClient.kt index 48cf9cf2d82..1b0ab9bbd7c 100644 --- a/components/lib/fetch-okhttp/src/main/java/mozilla/components/lib/fetch/okhttp/OkHttpClient.kt +++ b/components/lib/fetch-okhttp/src/main/java/mozilla/components/lib/fetch/okhttp/OkHttpClient.kt @@ -58,7 +58,7 @@ class OkHttpClient( } } -private fun okhttp3.OkHttpClient.rebuildFor(request: Request, context: Context?): okhttp3.OkHttpClient { +private fun OkHttpClient.rebuildFor(request: Request, context: Context?): OkHttpClient { @Suppress("ComplexCondition") if (request.connectTimeout != null || request.readTimeout != null || @@ -105,11 +105,9 @@ private fun createRequestBuilderWithBody(request: Request): RequestBuilder { RequestBody.create(null, body.useStream { it.readBytes() }) } - val requestBuilder = RequestBuilder() + return RequestBuilder() .url(request.url) .method(request.method.name, requestBody) - - return requestBuilder } private fun RequestBuilder.addHeadersFrom(request: Request, defaultHeaders: Headers) { diff --git a/components/lib/fetch-okhttp/src/test/java/mozilla/components/lib/fetch/okhttp/OkHttpFetchTestCases.kt b/components/lib/fetch-okhttp/src/test/java/mozilla/components/lib/fetch/okhttp/OkHttpFetchTestCases.kt index 0091827b7de..91287561890 100644 --- a/components/lib/fetch-okhttp/src/test/java/mozilla/components/lib/fetch/okhttp/OkHttpFetchTestCases.kt +++ b/components/lib/fetch-okhttp/src/test/java/mozilla/components/lib/fetch/okhttp/OkHttpFetchTestCases.kt @@ -5,15 +5,16 @@ package mozilla.components.lib.fetch.okhttp import mozilla.components.concept.fetch.Client +import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner -import org.robolectric.RuntimeEnvironment @RunWith(RobolectricTestRunner::class) class OkHttpFetchTestCases : mozilla.components.tooling.fetch.tests.FetchTestCases() { - override fun createNewClient(): Client = OkHttpClient(okhttp3.OkHttpClient(), RuntimeEnvironment.application) + + override fun createNewClient(): Client = OkHttpClient(okhttp3.OkHttpClient(), testContext) // Inherits test methods from generic test suite base class