Fixed RMI async unit test

This commit is contained in:
Robinson 2022-03-15 14:44:50 +01:00
parent 5c6c52e8b9
commit 6355dfced7
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C

View File

@ -22,6 +22,7 @@ import dorkbox.network.Server
import dorkbox.network.connection.Connection
import dorkbox.network.rmi.RemoteObject
import dorkboxTest.network.BaseTest
import kotlinx.coroutines.delay
import org.junit.Assert
import org.junit.Test
import java.util.concurrent.atomic.*
@ -107,6 +108,16 @@ class RmiSpamAsyncTest : BaseTest() {
}
}
// The async nature means that we don't know EXACTLY when all the messages will arrive. For testing, this is the closest
// we can do to attempt to have a correct info lookup.
var count = 0
while (counter.get() < totalRuns && count < 30) {
logger.error("Waiting for ${totalRuns - counter.get()} more messages...")
count++
delay(1_000)
}
// have to do this first, so it will wait for the client responses!
// if we close the client first, the connection will be closed, and the responses will never arrive to the server
stopEndPoints()