From aec7710bb165197a05a5736e9658d29cbd4e8b32 Mon Sep 17 00:00:00 2001 From: Jason Plumb Date: Wed, 2 Oct 2024 13:41:58 -0700 Subject: [PATCH 1/2] fix warnings in test code --- .../com/splunk/rum/TracingHurlStackTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/splunk-otel-android-volley/src/test/java/com/splunk/rum/TracingHurlStackTest.java b/splunk-otel-android-volley/src/test/java/com/splunk/rum/TracingHurlStackTest.java index 39a8978e..43132c29 100644 --- a/splunk-otel-android-volley/src/test/java/com/splunk/rum/TracingHurlStackTest.java +++ b/splunk-otel-android-volley/src/test/java/com/splunk/rum/TracingHurlStackTest.java @@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Fail.fail; +import static org.junit.Assert.assertTrue; import com.android.volley.DefaultRetryPolicy; import com.android.volley.Request; @@ -168,7 +169,10 @@ public void connectionError() throws IOException { assertThat(span.getEvents()) .hasSize(1) - .allSatisfy(e -> e.getName().equals(SemanticAttributes.EXCEPTION_EVENT_NAME)); + .allSatisfy( + e -> + assertThat(e.getName()) + .isEqualTo(SemanticAttributes.EXCEPTION_EVENT_NAME)); verifyAttributes(span, url, null, null); } @@ -191,7 +195,7 @@ public void reusedRequest() throws IOException, InterruptedException { testQueue.addToQueue(stringRequest); testQueue.addToQueue(stringRequest); - testResponseListener.countDownLatch.await(10, TimeUnit.SECONDS); + assertTrue(testResponseListener.countDownLatch.await(10, TimeUnit.SECONDS)); assertThat(server.getRequestCount()).isEqualTo(2); @@ -241,16 +245,11 @@ public void concurrency() throws IOException, InterruptedException { } latch.countDown(); - testResponseListener.countDownLatch.await(10, TimeUnit.SECONDS); + assertTrue(testResponseListener.countDownLatch.await(10, TimeUnit.SECONDS)); assertThat(server.getRequestCount()).isEqualTo(50); - otelTesting - .getSpans() - .forEach( - span -> { - verifyAttributes(span, url, 200L, "success"); - }); + otelTesting.getSpans().forEach(span -> verifyAttributes(span, url, 200L, "success")); pool.shutdown(); } From 00a7337f1a94b7aa09f2b833a501fb822b7c189e Mon Sep 17 00:00:00 2001 From: Jason Plumb Date: Wed, 2 Oct 2024 13:42:29 -0700 Subject: [PATCH 2/2] make test framework/platform dependency explicit for future gradle compatibility https://docs.gradle.org/8.10.2/userguide/upgrading_version_8.html#test_framework_implementation_dependencies --- .../main/kotlin/splunk.android-library-conventions.gradle.kts | 1 + gradle/libs.versions.toml | 1 + sample-app/build.gradle.kts | 1 + 3 files changed, 3 insertions(+) diff --git a/buildSrc/src/main/kotlin/splunk.android-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/splunk.android-library-conventions.gradle.kts index 7b36d021..c8fd8c4f 100644 --- a/buildSrc/src/main/kotlin/splunk.android-library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/splunk.android-library-conventions.gradle.kts @@ -97,6 +97,7 @@ dependencies { testImplementation(libs.findLibrary("assertj-core").get()) testImplementation(libs.findBundle("mocking").get()) testImplementation(libs.findBundle("junit").get()) + testRuntimeOnly(libs.findLibrary("junit-platform-launcher").get()) testImplementation(libs.findLibrary("robolectric").get()) testImplementation(libs.findLibrary("opentelemetry-sdk-testing").get()) coreLibraryDesugaring(libs.findLibrary("desugarJdkLibs").get()) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 453c6682..ba2ebeef 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -47,6 +47,7 @@ mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" } mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" } junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version = "1.11.1" } junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit" } mockwebserver = "com.google.mockwebserver:mockwebserver:20130706" robolectric = "org.robolectric:robolectric:4.13" diff --git a/sample-app/build.gradle.kts b/sample-app/build.gradle.kts index 175a60c9..28144317 100644 --- a/sample-app/build.gradle.kts +++ b/sample-app/build.gradle.kts @@ -97,6 +97,7 @@ dependencies { implementation(libs.opentelemetry.sdk) implementation(libs.opentelemetry.api.incubator) testImplementation(libs.bundles.junit) + testRuntimeOnly(libs.junit.platform.launcher) androidTestImplementation(libs.androidx.test.core) androidTestImplementation(libs.androidx.junit) debugImplementation(libs.androidx.ui.tooling)