From 2ab5bf8bdd7face078870f260cb2ff022d198150 Mon Sep 17 00:00:00 2001 From: Johannes Ptaszyk Date: Mon, 18 Nov 2024 15:00:43 +0100 Subject: [PATCH] chore: bump robolectric to 4.14 (#98) (#99) Closes #98 --- buildSrc/build.gradle | 4 ++-- gradle/libs.versions.toml | 2 +- .../internal/JUnit5RobolectricAndroidSandbox.kt | 7 ++----- .../internal/JUnit5RobolectricSandboxBuilder.kt | 7 ++----- .../internal/JUnit5RobolectricSandboxManager.kt | 6 +++--- .../internal/JUnit5RobolectricSandboxBuilderTest.kt | 6 +++--- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 4693865..cf845af 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -46,9 +46,9 @@ task downloadAarDepsPlugin { final url = from[i] final targetFile = to[i] try { - new URL(url).withInputStream { inputStream -> targetFile.withOutputStream { it << inputStream } } + URI.create(url).toURL().withInputStream { inputStream -> targetFile.withOutputStream { it << inputStream } } } catch (IOException e) { - logger.debug("Error during downloading ${url.name}. Keep the stored version.\n$e") + logger.debug("Error during downloading ${url}. Keep the stored version.\n$e") } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4c5fae7..cdf7af0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,7 +17,7 @@ jvmToolchainMin = "11" jvmToolchain = "17" kotlin = "2.0.21" kover = "0.8.3" -robolectric = "4.13" +robolectric = "4.14" robolectricExtensionGradlePlugin = "0.8.0" # Use when bom also added to the dependencies sources = "sources" diff --git a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricAndroidSandbox.kt b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricAndroidSandbox.kt index 520564a..aa60579 100644 --- a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricAndroidSandbox.kt +++ b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricAndroidSandbox.kt @@ -1,9 +1,8 @@ package tech.apter.junit.jupiter.robolectric.internal -import org.robolectric.ApkLoader +import org.robolectric.annotation.ResourcesMode import org.robolectric.annotation.SQLiteMode import org.robolectric.internal.AndroidSandbox -import org.robolectric.internal.ResourcesMode import org.robolectric.internal.bytecode.ShadowProviders import org.robolectric.pluginapi.Sdk import java.util.concurrent.ThreadFactory @@ -13,8 +12,7 @@ import java.util.concurrent.atomic.AtomicLong internal class JUnit5RobolectricAndroidSandbox( runtimeSdk: Sdk, compileSdk: Sdk, - resourcesMode: ResourcesMode, - apkLoader: ApkLoader, + resourcesMode: ResourcesMode.Mode, @Suppress("VisibleForTests") testEnvironmentSpec: TestEnvironmentSpec, sdkSandboxClassLoader: SdkSandboxClassLoader, @@ -24,7 +22,6 @@ internal class JUnit5RobolectricAndroidSandbox( runtimeSdk, compileSdk, resourcesMode, - apkLoader, testEnvironmentSpec, sdkSandboxClassLoader, shadowProviders, diff --git a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilder.kt b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilder.kt index a57a715..025ed4b 100644 --- a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilder.kt +++ b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilder.kt @@ -1,10 +1,9 @@ package tech.apter.junit.jupiter.robolectric.internal -import org.robolectric.ApkLoader +import org.robolectric.annotation.ResourcesMode import org.robolectric.annotation.SQLiteMode import org.robolectric.internal.AndroidSandbox import org.robolectric.internal.AndroidSandbox.SdkSandboxClassLoader -import org.robolectric.internal.ResourcesMode import org.robolectric.internal.SandboxManager import org.robolectric.internal.bytecode.ClassInstrumentor import org.robolectric.internal.bytecode.InstrumentationConfiguration @@ -17,7 +16,6 @@ import javax.inject.Inject internal class JUnit5RobolectricSandboxBuilder @Inject constructor( private val testClassContainer: TestClassContainer, - private val apkLoader: ApkLoader, @Suppress("VisibleForTests") private val testEnvironmentSpec: AndroidSandbox.TestEnvironmentSpec, private val shadowProviders: ShadowProviders, @@ -29,7 +27,7 @@ internal class JUnit5RobolectricSandboxBuilder @Inject constructor( instrumentationConfig: InstrumentationConfiguration, runtimeSdk: Sdk, compileSdk: Sdk, - resourcesMode: ResourcesMode, + resourcesMode: ResourcesMode.Mode, sqLiteMode: SQLiteMode.Mode, ): AndroidSandbox { val testClass = testClassContainer.testClass @@ -39,7 +37,6 @@ internal class JUnit5RobolectricSandboxBuilder @Inject constructor( runtimeSdk, compileSdk, resourcesMode, - apkLoader, testEnvironmentSpec, sdkSandboxClassLoader, shadowProviders, diff --git a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxManager.kt b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxManager.kt index 1dafaaf..cf5c697 100644 --- a/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxManager.kt +++ b/robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxManager.kt @@ -2,9 +2,9 @@ package tech.apter.junit.jupiter.robolectric.internal import org.robolectric.annotation.GraphicsMode import org.robolectric.annotation.LooperMode +import org.robolectric.annotation.ResourcesMode import org.robolectric.annotation.SQLiteMode import org.robolectric.internal.AndroidSandbox -import org.robolectric.internal.ResourcesMode import org.robolectric.internal.SandboxManager import org.robolectric.internal.bytecode.InstrumentationConfiguration import org.robolectric.pluginapi.Sdk @@ -23,7 +23,7 @@ internal class JUnit5RobolectricSandboxManager @Inject constructor( override fun getAndroidSandbox( instrumentationConfig: InstrumentationConfiguration, sdk: Sdk, - resourcesMode: ResourcesMode, + resourcesMode: ResourcesMode.Mode, looperMode: LooperMode.Mode, sqliteMode: SQLiteMode.Mode, graphicsMode: GraphicsMode.Mode, @@ -50,7 +50,7 @@ internal class JUnit5RobolectricSandboxManager @Inject constructor( private val testClassName: String, private val instrumentationConfiguration: InstrumentationConfiguration, private val sdk: Sdk, - private val resourcesMode: ResourcesMode, + private val resourcesMode: ResourcesMode.Mode, private val graphicsMode: GraphicsMode.Mode, ) diff --git a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt index 4ef46c6..8f50bc9 100644 --- a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt +++ b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt @@ -1,8 +1,8 @@ package tech.apter.junit.jupiter.robolectric.internal +import org.robolectric.annotation.ResourcesMode import org.robolectric.annotation.SQLiteMode import org.robolectric.internal.AndroidSandbox -import org.robolectric.internal.ResourcesMode import org.robolectric.internal.SandboxManager.SandboxBuilder import org.robolectric.internal.bytecode.InstrumentationConfiguration import org.robolectric.pluginapi.Sdk @@ -24,7 +24,7 @@ class JUnit5RobolectricSandboxBuilderTest { val instrumentationConfiguration = createInstrumentationConfiguration() val runtimeSdk: Sdk = TestUtil.sdkCollection.getSdk(33) val compileSdk: Sdk = TestUtil.sdkCollection.getSdk(33) - val resourcesMode: ResourcesMode = ResourcesMode.BINARY + val resourcesMode: ResourcesMode.Mode = ResourcesMode.Mode.BINARY val sqLiteMode: SQLiteMode.Mode = SQLiteMode.Mode.NATIVE subjectUnderTest { @@ -50,7 +50,7 @@ class JUnit5RobolectricSandboxBuilderTest { val instrumentationConfiguration2 = createInstrumentationConfiguration() val runtimeSdk2: Sdk = TestUtil.sdkCollection.getSdk(32) val compileSdk2: Sdk = TestUtil.sdkCollection.getSdk(32) - val resourcesMode: ResourcesMode = ResourcesMode.BINARY + val resourcesMode: ResourcesMode.Mode = ResourcesMode.Mode.BINARY val sqLiteMode: SQLiteMode.Mode = SQLiteMode.Mode.NATIVE subjectUnderTest {