-
-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathConsoleApplicationSystemTest.kt
More file actions
72 lines (61 loc) · 2.1 KB
/
ConsoleApplicationSystemTest.kt
File metadata and controls
72 lines (61 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package io.sentry.systemtest
import io.sentry.SentryLevel
import io.sentry.systemtest.util.TestHelper
import java.util.concurrent.TimeUnit
import org.junit.Assert
import org.junit.Before
import org.junit.Test
class ConsoleApplicationSystemTest {
lateinit var testHelper: TestHelper
@Before
fun setup() {
testHelper = TestHelper("http://localhost:8000")
testHelper.reset()
}
@Test
fun `logback application sends expected events when run as JAR`() {
val jarFile = testHelper.findJar("sentry-samples-logback")
val process =
testHelper.launch(
jarFile,
mapOf(
"SENTRY_DSN" to testHelper.dsn,
"SENTRY_TRACES_SAMPLE_RATE" to "1.0",
"SENTRY_ENABLE_PRETTY_SERIALIZATION_OUTPUT" to "false",
"SENTRY_DEBUG" to "true",
),
)
process.waitFor(30, TimeUnit.SECONDS)
Assert.assertEquals(0, process.exitValue())
// Verify that we received the expected events
verifyExpectedEvents()
}
private fun verifyExpectedEvents() {
// Verify we received the RuntimeException
testHelper.ensureErrorReceived { event ->
event.exceptions?.any { ex ->
ex.type == "RuntimeException" && ex.value == "Invalid productId=445"
} == true &&
event.message?.formatted == "Something went wrong" &&
event.level?.name == "ERROR"
}
testHelper.ensureErrorReceived { event ->
event.breadcrumbs?.firstOrNull {
it.message == "Hello Sentry!" && it.level == SentryLevel.DEBUG
} != null
}
testHelper.ensureErrorReceived { event ->
event.message?.message == "important warning" &&
testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
}
testHelper.ensureErrorReceived { event ->
event.breadcrumbs?.firstOrNull {
it.message == "User has made a purchase of product: 445" && it.level == SentryLevel.INFO
} != null
}
testHelper.ensureLogsReceived { logs, _ ->
testHelper.doesContainLogWithBody(logs, "User has made a purchase of product: 445") &&
testHelper.doesContainLogWithBody(logs, "Something went wrong")
}
}
}