Code cleanup

This commit is contained in:
nathan 2020-08-27 00:47:51 +02:00
parent 661c978b07
commit e995dbdef5

View File

@ -52,7 +52,6 @@ class RmiTest : BaseTest() {
companion object { companion object {
suspend fun runTests(connection: Connection, test: TestCow, remoteObjectID: Int) { suspend fun runTests(connection: Connection, test: TestCow, remoteObjectID: Int) {
var caught = false
val remoteObject = test as RemoteObject val remoteObject = test as RemoteObject
// Default behavior. RMI is transparent, method calls behave like normal // Default behavior. RMI is transparent, method calls behave like normal
@ -82,23 +81,18 @@ class RmiTest : BaseTest() {
// Try exception handling // Try exception handling
try { try {
test.throwException() test.throwException()
Assert.fail("sync should be throwing an exception!")
} catch (e: UnsupportedOperationException) { } catch (e: UnsupportedOperationException) {
connection.logger.error("Expected exception (exception log should also be on the object impl side).", e) connection.logger.error("Expected exception (exception log should also be on the object impl side).", e)
caught = true
} }
Assert.assertTrue(caught)
caught = false
try { try {
test.throwSuspendException() test.throwSuspendException()
Assert.fail("sync should be throwing an exception!")
} catch (e: UnsupportedOperationException) { } catch (e: UnsupportedOperationException) {
connection.logger.error("\tExpected exception (exception log should also be on the object impl side).", e) connection.logger.error("\tExpected exception (exception log should also be on the object impl side).", e)
caught = true
} }
Assert.assertTrue(caught)
caught = false
// Non-blocking call tests // Non-blocking call tests
// Non-blocking call tests // Non-blocking call tests
// Non-blocking call tests // Non-blocking call tests
@ -119,23 +113,18 @@ class RmiTest : BaseTest() {
try { try {
test.throwException() test.throwException()
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
connection.logger.error("\tExpected exception (exception log should also be on the object impl side).") // exceptions are not caught when async = true!
e.printStackTrace() Assert.fail("Async should not be throwing an exception!")
caught = true
} }
// exceptions are not caught when async = true!
Assert.assertFalse(caught)
caught = false
try { try {
test.throwSuspendException() test.throwSuspendException()
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
connection.logger.error("\tExpected exception (exception log should also be on the object impl side).") // exceptions are not caught when async = true!
e.printStackTrace() Assert.fail("Async should not be throwing an exception!")
caught = true
} }
// exceptions are not caught when async = true!
Assert.assertFalse(caught)
// Call will time out if non-blocking isn't working properly // Call will time out if non-blocking isn't working properly