Skip to content

Commit 37a1e9d

Browse files
committed
Replace direct security manager usage with assertSystemExit in tests
1 parent 329b77d commit 37a1e9d

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

tests/src/test/kotlin/AbstractMainTest.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,9 @@ abstract class AbstractMainTest : AbstractTest() {
8484
fun printHelp(client: String) {
8585
val parameters =
8686
"$client --help".split(" ").toTypedArray()
87-
val previousManager = System.getSecurityManager()
88-
try {
89-
val manager = NoExitSecurityManager(previousManager)
90-
System.setSecurityManager(manager)
87+
assertSystemExit(0, Executable {
9188
main(parameters)
92-
fail("expected exception")
93-
} catch (e: SystemExitingWithStatus) {
94-
assertThat(e.status).isEqualTo(0)
95-
} finally {
96-
System.setSecurityManager(previousManager)
97-
}
89+
})
9890
}
9991

10092
@Tag("external")
@@ -136,7 +128,9 @@ abstract class AbstractMainTest : AbstractTest() {
136128
"connector --broker $brokerUrl --address $address --count 1".split(" ").toTypedArray()
137129
assertTimeoutPreemptively(Duration.ofSeconds(10)) {
138130
print("Connecting: ")
139-
main(connectorParameters)
131+
assertNoSystemExit {
132+
main(connectorParameters)
133+
}
140134
}
141135
}
142136

0 commit comments

Comments
 (0)