Skip to content

Commit

Permalink
Removed Commons dependency (#369)
Browse files Browse the repository at this point in the history
* Removed Commons dependency

Signed-off-by: Arnau Mora Gras <[email protected]>

* Upgrade ical4android and get rid of unused commons versions

Signed-off-by: Arnau Mora <[email protected]>

* Replaced usage

Signed-off-by: Arnau Mora <[email protected]>

* Using bufferred readers

Signed-off-by: Arnau Mora <[email protected]>

---------

Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora <[email protected]>
Co-authored-by: Sunik Kupfer <[email protected]>
  • Loading branch information
ArnyminerZ and sunkup authored Jul 29, 2024
1 parent 7bc1643 commit 21919b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
6 changes: 0 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ dependencies {
// FIXME - Add when OkHttp 5.0.0 is stable
// implementation(libs.okhttp.coroutines)

// latest commons that don"t require Java 8
//noinspection GradleDependency
implementation(libs.commons.io)
//noinspection GradleDependency
implementation(libs.commons.lang3)

// Room Database
implementation(libs.room.base)
ksp(libs.room.compiler)
Expand Down
21 changes: 11 additions & 10 deletions app/src/androidTest/java/at/bitfire/icsdroid/CalendarFetcherTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ import androidx.test.platform.app.InstrumentationRegistry
import at.bitfire.icsdroid.HttpUtils.toAndroidUri
import at.bitfire.icsdroid.test.BuildConfig
import at.bitfire.icsdroid.test.R
import java.io.IOException
import java.io.InputStream
import java.net.HttpURLConnection
import java.util.LinkedList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import okhttp3.MediaType
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.apache.commons.io.IOUtils
import org.junit.AfterClass
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.BeforeClass
import org.junit.Test
import java.io.IOException
import java.io.InputStream
import java.net.HttpURLConnection
import java.util.LinkedList

class CalendarFetcherTest {

Expand Down Expand Up @@ -56,15 +57,15 @@ class CalendarFetcherTest {
var ical: String? = null
val fetcher = object: CalendarFetcher(appContext, uri) {
override suspend fun onSuccess(data: InputStream, contentType: MediaType?, eTag: String?, lastModified: Long?, displayName: String?) {
ical = IOUtils.toString(data, Charsets.UTF_8)
ical = data.bufferedReader().use { it.readText() }
}
}
runBlocking {
fetcher.fetch()
}

testContext.resources.openRawResource(R.raw.vienna_evolution).use { streamCorrect ->
val referenceData = IOUtils.toString(streamCorrect, Charsets.UTF_8)
val referenceData = streamCorrect.bufferedReader().use { it.readText() }
assertEquals(referenceData, ical)
}
}
Expand All @@ -74,7 +75,7 @@ class CalendarFetcherTest {
val etagCorrect = "33a64df551425fcc55e4d42a148795d9f25f89d4"
val lastModifiedCorrect = "Wed, 21 Oct 2015 07:28:00 GMT" // UNIX timestamp 1445405280
val icalCorrect = testContext.resources.openRawResource(R.raw.vienna_evolution).use { streamCorrect ->
IOUtils.toString(streamCorrect, Charsets.UTF_8)
streamCorrect.bufferedReader().use { it.readText() }
}

// create mock response
Expand All @@ -90,7 +91,7 @@ class CalendarFetcherTest {
var lastmod: Long? = null
val fetcher = object: CalendarFetcher(appContext, server.url("/").toAndroidUri()) {
override suspend fun onSuccess(data: InputStream, contentType: MediaType?, eTag: String?, lastModified: Long?, displayName: String?) {
ical = IOUtils.toString(data, Charsets.UTF_8)
ical = data.bufferedReader().use { it.readText() }
etag = eTag
lastmod = lastModified
}
Expand Down Expand Up @@ -131,7 +132,7 @@ class CalendarFetcherTest {
super.onRedirect(httpCode, target)
}
override suspend fun onSuccess(data: InputStream, contentType: MediaType?, eTag: String?, lastModified: Long?, displayName: String?) {
ical = IOUtils.toString(data, Charsets.UTF_8)
ical = data.bufferedReader().use { it.readText() }
}
}
runBlocking {
Expand Down
10 changes: 3 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ androidx-test-rules = "1.6.1"
androidx-test-runner = "1.6.1"
androidx-work = "2.9.0"
bitfire-cert4android = "f0964cb"
bitfire-ical4android = "821ab3f"
#noinspection GradleDependency
commons-io = "2.6"
#noinspection GradleDependency
commons-lang3 = "3.8.1"
bitfire-ical4android = "505f747"
# Keep in sync with Kotlin version: https://developer.android.com/jetpack/androidx/releases/compose-kotlin
compose-compiler = "1.5.14"
compose-dialogs = "1.3.0"
compose-material = "1.6.8"
compose-material3 = "1.2.1"
Expand Down Expand Up @@ -46,8 +44,6 @@ androidx-work-runtime = { module = "androidx.work:work-runtime-ktx", version.ref
androidx-work-testing = { module = "androidx.work:work-testing", version.ref = "androidx-work" }
bitfire-cert4android = { module = "com.github.bitfireAT:cert4android", version.ref = "bitfire-cert4android" }
bitfire-ical4android = { module = "com.github.bitfireAT:ical4android", version.ref = "bitfire-ical4android" }
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commons-lang3" }
commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
compose-dialogs-color = { module = "com.maxkeppeler.sheets-compose-dialogs:color", version.ref = "compose-dialogs" }
compose-dialogs-core = { module = "com.maxkeppeler.sheets-compose-dialogs:core", version.ref = "compose-dialogs" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
Expand Down

0 comments on commit 21919b3

Please sign in to comment.