Skip to content

Commit 5d9f010

Browse files
committed
Format code
1 parent 16dcaee commit 5d9f010

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

sentry-samples/sentry-samples-console/build.gradle.kts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ dependencies {
4545

4646
// Configure the Shadow JAR (executable JAR with all dependencies)
4747
tasks.shadowJar {
48-
manifest {
49-
attributes["Main-Class"] = "io.sentry.samples.console.Main"
50-
}
48+
manifest { attributes["Main-Class"] = "io.sentry.samples.console.Main" }
5149
archiveClassifier.set("") // Remove the classifier so it replaces the regular JAR
5250
mergeServiceFiles()
5351
}
@@ -59,9 +57,7 @@ tasks.jar {
5957
}
6058

6159
// Fix the startScripts task dependency
62-
tasks.startScripts {
63-
dependsOn(tasks.shadowJar)
64-
}
60+
tasks.startScripts { dependsOn(tasks.shadowJar) }
6561

6662
configure<SourceSetContainer> { test { java.srcDir("src/test/java") } }
6763

@@ -85,4 +81,3 @@ tasks.named("test").configure {
8581

8682
filter { excludeTestsMatching("io.sentry.systemtest.*") }
8783
}
88-

sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,16 @@ public static void main(String[] args) throws InterruptedException {
8282
options.setTracesSampleRate(1.0); // set 0.5 to send 50% of traces
8383

8484
// Determine traces sample rate based on the sampling context
85-
// options.setTracesSampler(
86-
// context -> {
87-
// // only 10% of transactions with "/product" prefix will be collected
88-
// if (!context.getTransactionContext().getName().startsWith("/products")) {
89-
// return 0.1;
90-
// } else {
91-
// return 0.5;
92-
// }
93-
// });
85+
// options.setTracesSampler(
86+
// context -> {
87+
// // only 10% of transactions with "/product" prefix will be collected
88+
// if (!context.getTransactionContext().getName().startsWith("/products"))
89+
// {
90+
// return 0.1;
91+
// } else {
92+
// return 0.5;
93+
// }
94+
// });
9495
});
9596

9697
Sentry.addBreadcrumb(

sentry-samples/sentry-samples-console/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package io.sentry.systemtest
22

33
import io.sentry.systemtest.util.TestHelper
4-
import java.io.File
54
import java.util.concurrent.TimeUnit
6-
import org.junit.Test
7-
import org.junit.Before
85
import org.junit.Assert.assertEquals
96
import org.junit.Assert.assertTrue
7+
import org.junit.Before
8+
import org.junit.Test
109

1110
class ConsoleApplicationSystemTest {
1211
lateinit var testHelper: TestHelper
@@ -20,16 +19,18 @@ class ConsoleApplicationSystemTest {
2019
@Test
2120
fun `console application sends expected events when run as JAR`() {
2221
val jarFile = testHelper.findJar("sentry-samples-console")
23-
val process = testHelper.launch(
24-
jarFile,
25-
mapOf(
26-
"SENTRY_DSN" to testHelper.dsn,
27-
"SENTRY_TRACES_SAMPLE_RATE" to "1.0",
28-
"SENTRY_ENABLE_PRETTY_SERIALIZATION_OUTPUT" to "false",
29-
"SENTRY_DEBUG" to "true",
30-
))
22+
val process =
23+
testHelper.launch(
24+
jarFile,
25+
mapOf(
26+
"SENTRY_DSN" to testHelper.dsn,
27+
"SENTRY_TRACES_SAMPLE_RATE" to "1.0",
28+
"SENTRY_ENABLE_PRETTY_SERIALIZATION_OUTPUT" to "false",
29+
"SENTRY_DEBUG" to "true",
30+
),
31+
)
3132

32-
process.waitFor(30, TimeUnit.SECONDS);
33+
process.waitFor(30, TimeUnit.SECONDS)
3334
assertEquals(0, process.exitValue())
3435

3536
// Verify that we received the expected events
@@ -71,7 +72,8 @@ class ConsoleApplicationSystemTest {
7172
try {
7273
for (i in 0..9) {
7374
testHelper.ensureErrorReceived { event ->
74-
val matches = event.message?.message?.contains("items we'll wait to flush to Sentry!") == true
75+
val matches =
76+
event.message?.message?.contains("items we'll wait to flush to Sentry!") == true
7577
if (matches) loopMessageCount++
7678
matches
7779
}
@@ -80,7 +82,10 @@ class ConsoleApplicationSystemTest {
8082
// Some loop messages might be missing, but we should have at least some
8183
}
8284

83-
assertTrue("Should receive at least 5 loop messages, got $loopMessageCount", loopMessageCount >= 5)
85+
assertTrue(
86+
"Should receive at least 5 loop messages, got $loopMessageCount",
87+
loopMessageCount >= 5,
88+
)
8489

8590
// Verify we have breadcrumbs
8691
testHelper.ensureErrorReceived { event ->

sentry-system-test-support/src/main/kotlin/io/sentry/systemtest/util/TestHelper.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import io.sentry.protocol.SentryTransaction
1313
import io.sentry.systemtest.graphql.GraphqlTestClient
1414
import java.io.File
1515
import java.io.PrintWriter
16-
import java.util.concurrent.TimeUnit
1716
import kotlin.test.assertEquals
1817
import kotlin.test.assertFalse
1918
import kotlin.test.assertNotNull
@@ -279,9 +278,8 @@ class TestHelper(backendUrl: String) {
279278
fun findJar(prefix: String, inDir: String = "build/libs"): File {
280279
val buildDir = File(inDir)
281280
val jarFiles =
282-
buildDir
283-
.listFiles { _, name -> name.startsWith(prefix) && name.endsWith(".jar") }
284-
?.toList() ?: emptyList()
281+
buildDir.listFiles { _, name -> name.startsWith(prefix) && name.endsWith(".jar") }?.toList()
282+
?: emptyList()
285283

286284
if (jarFiles.isEmpty()) {
287285
throw AssertionError("No JAR found in ${buildDir.absolutePath}")
@@ -291,8 +289,8 @@ class TestHelper(backendUrl: String) {
291289
}
292290

293291
fun launch(jar: File, env: Map<String, String>): Process {
294-
val processBuilder = ProcessBuilder("java", "-jar", jar.absolutePath)
295-
.inheritIO() // forward i/o to current process
292+
val processBuilder =
293+
ProcessBuilder("java", "-jar", jar.absolutePath).inheritIO() // forward i/o to current process
296294

297295
processBuilder.environment().putAll(env)
298296

0 commit comments

Comments
 (0)