From 496b6cd63344439dbed18f0e5b6337c3f0ecbcb3 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 28 Nov 2019 18:11:56 +0200 Subject: [PATCH] Fix tests. --- app/build.gradle | 4 ++++ app/src/main/java/com/etesync/syncadapter/HttpClient.kt | 2 +- .../etesync/syncadapter/journalmanager/AuthenticatorTest.kt | 2 +- .../com/etesync/syncadapter/journalmanager/ServiceTest.kt | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 39cf374e..67533be5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -89,6 +89,10 @@ android { exclude 'META-INF/NOTICE.txt' } + testOptions { + unitTests.returnDefaultValues = true + } + defaultConfig { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/etesync/syncadapter/HttpClient.kt b/app/src/main/java/com/etesync/syncadapter/HttpClient.kt index a4f7128f..97506420 100644 --- a/app/src/main/java/com/etesync/syncadapter/HttpClient.kt +++ b/app/src/main/java/com/etesync/syncadapter/HttpClient.kt @@ -115,7 +115,7 @@ class HttpClient private constructor( } } - constructor(context: Context, host: String?, authToken: String): this(context) { + constructor(context: Context?, host: String?, authToken: String): this(context) { addAuthentication(host, authToken) } diff --git a/app/src/test/java/com/etesync/syncadapter/journalmanager/AuthenticatorTest.kt b/app/src/test/java/com/etesync/syncadapter/journalmanager/AuthenticatorTest.kt index 0535c2ca..b5c669fe 100644 --- a/app/src/test/java/com/etesync/syncadapter/journalmanager/AuthenticatorTest.kt +++ b/app/src/test/java/com/etesync/syncadapter/journalmanager/AuthenticatorTest.kt @@ -24,7 +24,7 @@ class AuthenticatorTest { @Before @Throws(IOException::class) fun setUp() { - httpClient = HttpClient.create(null) + httpClient = HttpClient.Builder().build().okHttpClient remote = HttpUrl.parse("http://localhost:8000") // FIXME: hardcode for now, should make configureable } diff --git a/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt b/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt index 49a35083..c426c57a 100644 --- a/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt +++ b/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt @@ -28,12 +28,12 @@ class ServiceTest { @Before @Throws(Exception::class) fun setUp() { - httpClient = HttpClient.create(null) + httpClient = HttpClient.Builder().build().okHttpClient remote = HttpUrl.parse("http://localhost:8000") // FIXME: hardcode for now, should make configureable val journalAuthenticator = JournalAuthenticator(httpClient!!, remote!!) authToken = journalAuthenticator.getAuthToken(Helpers.USER, Helpers.PASSWORD) - httpClient = HttpClient.create(null, App.log, null, authToken!!) + httpClient = HttpClient.Builder(null, null, authToken!!).build().okHttpClient /* Reset */ val request = Request.Builder()