updated tests to latest source
This commit is contained in:
parent
bfccc6f7a5
commit
c529bde55b
|
@ -128,10 +128,7 @@ object AeronClient {
|
|||
println(message)
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect("127.0.0.1") // UDP connection via loopback
|
||||
}
|
||||
|
||||
client.connect("127.0.0.1") // UDP connection via loopback
|
||||
|
||||
|
||||
// different ones needed
|
||||
|
|
|
@ -70,14 +70,23 @@ abstract class BaseTest {
|
|||
private var autoFailThread: Thread? = null
|
||||
|
||||
companion object {
|
||||
fun setLog() {
|
||||
setLogLevel(Level.TRACE)
|
||||
}
|
||||
|
||||
const val LOOPBACK = "loopback"
|
||||
fun clientConfig(block: Configuration.() -> Unit = {}): Configuration {
|
||||
|
||||
val configuration = Configuration()
|
||||
configuration.settingsStore = MemoryStore.type() // don't want to persist anything on disk!
|
||||
configuration.subscriptionPort = 2000
|
||||
configuration.publicationPort = 2001
|
||||
|
||||
configuration.enableIpc = false
|
||||
|
||||
block(configuration)
|
||||
|
||||
setLog()
|
||||
return configuration
|
||||
}
|
||||
|
||||
|
@ -88,16 +97,51 @@ abstract class BaseTest {
|
|||
configuration.subscriptionPort = 2000
|
||||
configuration.publicationPort = 2001
|
||||
|
||||
configuration.enableIpc = false
|
||||
configuration.maxClientCount = 5
|
||||
configuration.maxConnectionsPerIpAddress = 5
|
||||
|
||||
block(configuration)
|
||||
|
||||
setLog()
|
||||
return configuration
|
||||
}
|
||||
|
||||
fun setLogLevel(level: Level) {
|
||||
// assume SLF4J is bound to logback in the current environment
|
||||
val rootLogger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME) as Logger
|
||||
rootLogger.level = level
|
||||
|
||||
val context = rootLogger.loggerContext
|
||||
val jc = JoranConfigurator()
|
||||
context.reset() // override default configuration
|
||||
|
||||
jc.context = context
|
||||
|
||||
|
||||
context.getLogger(Server::class.simpleName).level = level
|
||||
context.getLogger(Client::class.simpleName).level = level
|
||||
|
||||
// we only want error messages
|
||||
val kryoLogger = LoggerFactory.getLogger("com.esotericsoftware") as Logger
|
||||
kryoLogger.level = Level.ERROR
|
||||
|
||||
val encoder = PatternLayoutEncoder()
|
||||
encoder.context = context
|
||||
encoder.pattern = "%date{HH:mm:ss.SSS} %-5level [%logger{35}] %msg%n"
|
||||
encoder.start()
|
||||
val consoleAppender = ConsoleAppender<ILoggingEvent>()
|
||||
consoleAppender.context = context
|
||||
consoleAppender.encoder = encoder
|
||||
consoleAppender.start()
|
||||
rootLogger.addAppender(consoleAppender)
|
||||
//
|
||||
// context.getLogger(Server::class.simpleName).trace("TESTING")
|
||||
// context.getLogger(Client::class.simpleName).trace("TESTING")
|
||||
}
|
||||
|
||||
// wait minimum of 2 minutes before we automatically fail the unit test.
|
||||
const val AUTO_FAIL_TIMEOUT: Long = 120
|
||||
var AUTO_FAIL_TIMEOUT: Long = 120
|
||||
|
||||
init {
|
||||
if (OS.javaVersion >= 9) {
|
||||
|
@ -133,39 +177,8 @@ abstract class BaseTest {
|
|||
|
||||
init {
|
||||
println("---- " + this.javaClass.simpleName)
|
||||
|
||||
// setLogLevel(Level.INFO)
|
||||
setLogLevel(Level.TRACE)
|
||||
// setLogLevel(Level.DEBUG)
|
||||
}
|
||||
|
||||
fun setLogLevel(level: Level) {
|
||||
// assume SLF4J is bound to logback in the current environment
|
||||
val rootLogger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME) as Logger
|
||||
val context = rootLogger.loggerContext
|
||||
val jc = JoranConfigurator()
|
||||
jc.context = context
|
||||
context.reset() // override default configuration
|
||||
|
||||
rootLogger.level = level
|
||||
|
||||
// we only want error messages
|
||||
val kryoLogger = LoggerFactory.getLogger("com.esotericsoftware") as Logger
|
||||
kryoLogger.level = Level.ERROR
|
||||
|
||||
|
||||
val encoder = PatternLayoutEncoder()
|
||||
encoder.context = context
|
||||
encoder.pattern = "%date{HH:mm:ss.SSS} %-5level [%logger{35}] %msg%n"
|
||||
encoder.start()
|
||||
val consoleAppender = ConsoleAppender<ILoggingEvent>()
|
||||
consoleAppender.context = context
|
||||
consoleAppender.encoder = encoder
|
||||
consoleAppender.start()
|
||||
rootLogger.addAppender(consoleAppender)
|
||||
}
|
||||
|
||||
|
||||
fun addEndPoint(endPointConnection: EndPoint<*>) {
|
||||
endPointConnections.add(endPointConnection)
|
||||
synchronized(lock) { latch = CountDownLatch(endPointConnections.size + 1) }
|
||||
|
@ -253,11 +266,5 @@ abstract class BaseTest {
|
|||
autoFailThread!!.interrupt()
|
||||
autoFailThread = null
|
||||
}
|
||||
|
||||
// Give sockets a chance to close before starting the next test.
|
||||
try {
|
||||
Thread.sleep(1000)
|
||||
} catch (ignored: InterruptedException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,6 +186,7 @@ class ConnectionFilterTest : BaseTest() {
|
|||
}
|
||||
|
||||
client.onDisconnect {
|
||||
println("**************************** CLOSE")
|
||||
stopEndPoints()
|
||||
}
|
||||
|
||||
|
@ -233,6 +234,7 @@ class ConnectionFilterTest : BaseTest() {
|
|||
try {
|
||||
client.connect(LOOPBACK)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
stopEndPoints()
|
||||
throw e
|
||||
}
|
||||
|
@ -241,6 +243,58 @@ class ConnectionFilterTest : BaseTest() {
|
|||
waitForThreads()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rejectServerIpc() {
|
||||
val serverConnectSuccess = atomic(false)
|
||||
val clientConnectSuccess = atomic(false)
|
||||
|
||||
run {
|
||||
val configuration = serverConfig() {
|
||||
enableIpc = true
|
||||
}
|
||||
|
||||
val server: Server<Connection> = Server(configuration)
|
||||
addEndPoint(server)
|
||||
server.bind()
|
||||
server.filter(IpSubnetFilterRule("1.1.1.1", 32)) // this address will NEVER actually connect. we just use it for testing
|
||||
|
||||
server.onConnect { connection ->
|
||||
serverConnectSuccess.lazySet(true)
|
||||
connection.close()
|
||||
}
|
||||
}
|
||||
|
||||
run {
|
||||
val config = clientConfig() {
|
||||
enableIpc = true
|
||||
}
|
||||
|
||||
val client: Client<Connection> = Client(config)
|
||||
addEndPoint(client)
|
||||
|
||||
client.onConnect {
|
||||
clientConnectSuccess.value = true
|
||||
}
|
||||
|
||||
client.onDisconnect {
|
||||
stopEndPoints()
|
||||
}
|
||||
|
||||
try {
|
||||
client.connect(LOOPBACK)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
stopEndPoints()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
|
||||
Assert.assertTrue(serverConnectSuccess.value)
|
||||
Assert.assertTrue(clientConnectSuccess.value)
|
||||
}
|
||||
|
||||
@Test(expected = ClientException::class)
|
||||
fun rejectClient() {
|
||||
run {
|
||||
|
|
|
@ -57,13 +57,85 @@ class DisconnectReconnectTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
|
||||
waitForThreads()
|
||||
waitForThreads(0)
|
||||
|
||||
System.err.println("Connection count (after reconnecting) is: " + reconnectCount.value)
|
||||
Assert.assertEquals(4, reconnectCount.value)
|
||||
}
|
||||
|
||||
interface CloseIface {
|
||||
suspend fun close()
|
||||
}
|
||||
|
||||
class CloseImpl : CloseIface {
|
||||
override suspend fun close() {
|
||||
// the connection specific one is called instead
|
||||
}
|
||||
|
||||
suspend fun close(connection: Connection) {
|
||||
connection.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun reconnectRmiClient() {
|
||||
val CLOSE_ID = 33
|
||||
|
||||
run {
|
||||
val config = serverConfig()
|
||||
config.serialization.registerRmi(CloseIface::class.java)
|
||||
|
||||
val server: Server<Connection> = Server(config)
|
||||
addEndPoint(server)
|
||||
server.bind()
|
||||
|
||||
|
||||
server.onConnect { connection ->
|
||||
connection.logger.error("Disconnecting after 2 seconds.")
|
||||
delay(2000)
|
||||
|
||||
connection.logger.error("Disconnecting via RMI ....")
|
||||
val closerObject = connection.getGlobalObject<CloseIface>(CLOSE_ID)
|
||||
closerObject.close()
|
||||
}
|
||||
}
|
||||
|
||||
run {
|
||||
val config = clientConfig()
|
||||
config.serialization.registerRmi(CloseIface::class.java, CloseImpl::class.java)
|
||||
|
||||
val client: Client<Connection> = Client(config)
|
||||
addEndPoint(client)
|
||||
client.saveGlobalObject(CloseImpl(), CLOSE_ID)
|
||||
|
||||
client.onDisconnect { connection ->
|
||||
connection.logger.error("Disconnected!")
|
||||
|
||||
val count = reconnectCount.getAndIncrement()
|
||||
if (count == 3) {
|
||||
connection.logger.error("Shutting down")
|
||||
stopEndPoints()
|
||||
}
|
||||
else {
|
||||
connection.logger.error("Reconnecting: $count")
|
||||
try {
|
||||
client.connect(LOOPBACK)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
|
||||
waitForThreads(0)
|
||||
|
||||
System.err.println("Connection count (after reconnecting) is: " + reconnectCount.value)
|
||||
Assert.assertEquals(4, reconnectCount.value)
|
||||
|
@ -116,17 +188,12 @@ class DisconnectReconnectTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
|
||||
waitForThreads()
|
||||
|
||||
runBlocking {
|
||||
aeronDriver.close()
|
||||
}
|
||||
aeronDriver.close()
|
||||
|
||||
System.err.println("Connection count (after reconnecting) is: " + reconnectCount.value)
|
||||
Assert.assertEquals(4, reconnectCount.value)
|
||||
|
@ -134,6 +201,7 @@ class DisconnectReconnectTest : BaseTest() {
|
|||
|
||||
@Test
|
||||
fun reconnectWithFallbackClient() {
|
||||
// this tests IPC with fallback to UDP (because the server has IPC disabled, and the client has it enabled)
|
||||
run {
|
||||
val config = serverConfig()
|
||||
config.enableIpc = false
|
||||
|
@ -154,7 +222,6 @@ class DisconnectReconnectTest : BaseTest() {
|
|||
run {
|
||||
val config = clientConfig()
|
||||
config.enableIpc = true
|
||||
config.enableIpcForLoopback = true
|
||||
|
||||
val client: Client<Connection> = Client(config)
|
||||
addEndPoint(client)
|
||||
|
@ -178,9 +245,7 @@ class DisconnectReconnectTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,9 +289,7 @@ class DisconnectReconnectTest : BaseTest() {
|
|||
stopEndPoints()
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
server.close()
|
||||
|
|
|
@ -41,7 +41,6 @@ import dorkbox.network.connection.ConnectionParams
|
|||
import dorkbox.util.exceptions.InitializationException
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
|
@ -158,9 +157,7 @@ class ListenerTest : BaseTest() {
|
|||
}
|
||||
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
|
||||
waitForThreads()
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ import dorkbox.network.Client
|
|||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
@ -114,9 +113,7 @@ class MultipleServerTest : BaseTest() {
|
|||
connection.send("client_$count")
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
|
@ -146,6 +143,7 @@ class MultipleServerTest : BaseTest() {
|
|||
configuration.subscriptionPort += offset
|
||||
configuration.publicationPort += offset
|
||||
configuration.aeronDirectory = serverAeronDir
|
||||
configuration.enableIpc = true
|
||||
|
||||
val server: Server<Connection> = Server(configuration)
|
||||
addEndPoint(server)
|
||||
|
@ -178,6 +176,7 @@ class MultipleServerTest : BaseTest() {
|
|||
configuration.subscriptionPort += offset
|
||||
configuration.publicationPort += offset
|
||||
configuration.aeronDirectory = clientAeronDir
|
||||
configuration.enableIpc = true
|
||||
|
||||
val client: Client<Connection> = Client(configuration)
|
||||
addEndPoint(client)
|
||||
|
@ -189,9 +188,7 @@ class MultipleServerTest : BaseTest() {
|
|||
connection.send("client_$count")
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
|
|
|
@ -109,9 +109,7 @@ class PingPongTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,65 +1,59 @@
|
|||
package dorkboxTest.network
|
||||
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class PingTest : BaseTest() {
|
||||
@Test
|
||||
fun onServerPing() {
|
||||
val serverSuccess = atomic(false)
|
||||
val clientSuccess = atomic(false)
|
||||
|
||||
run {
|
||||
val configuration = serverConfig()
|
||||
|
||||
val server: Server<Connection> = Server(configuration)
|
||||
addEndPoint(server)
|
||||
server.bind()
|
||||
|
||||
server.onPing { ping ->
|
||||
serverSuccess.value = true
|
||||
println("Ping info ${ping.time}")
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
run {
|
||||
val config = clientConfig()
|
||||
|
||||
val client: Client<Connection> = Client(config)
|
||||
addEndPoint(client)
|
||||
|
||||
client.onConnect {
|
||||
clientSuccess.value = true
|
||||
|
||||
it.ping {
|
||||
println("received ping back! Val: $time")
|
||||
}
|
||||
}
|
||||
|
||||
client.onDisconnect {
|
||||
stopEndPoints()
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
try {
|
||||
client.connect(LOOPBACK)
|
||||
} catch (e: Exception) {
|
||||
stopEndPoints()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
waitForThreads()
|
||||
|
||||
Assert.assertTrue(serverSuccess.value)
|
||||
Assert.assertTrue(clientSuccess.value)
|
||||
// val serverSuccess = atomic(false)
|
||||
// val clientSuccess = atomic(false)
|
||||
//
|
||||
// run {
|
||||
// val configuration = serverConfig()
|
||||
//
|
||||
// val server: Server<Connection> = Server(configuration)
|
||||
// addEndPoint(server)
|
||||
// server.bind()
|
||||
//
|
||||
// server.onPing { ping ->
|
||||
// serverSuccess.value = true
|
||||
// println("Ping info ${ping.time}")
|
||||
// close()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// run {
|
||||
// val config = clientConfig()
|
||||
//
|
||||
// val client: Client<Connection> = Client(config)
|
||||
// addEndPoint(client)
|
||||
//
|
||||
// client.onConnect {
|
||||
// clientSuccess.value = true
|
||||
//
|
||||
// it.ping {
|
||||
// println("received ping back! Val: $time")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// client.onDisconnect {
|
||||
// stopEndPoints()
|
||||
// }
|
||||
//
|
||||
// runBlocking {
|
||||
// try {
|
||||
// client.connect(LOOPBACK)
|
||||
// } catch (e: Exception) {
|
||||
// stopEndPoints()
|
||||
// throw e
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// waitForThreads()
|
||||
//
|
||||
// Assert.assertTrue(serverSuccess.value)
|
||||
// Assert.assertTrue(clientSuccess.value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import dorkbox.network.Server
|
|||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.serialization.KryoExtra
|
||||
import dorkbox.network.serialization.Serialization
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
@ -51,10 +50,7 @@ class SerializationValidationTest : BaseTest() {
|
|||
connection.send(FinishedCommand())
|
||||
}
|
||||
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
|
@ -113,10 +109,7 @@ class SerializationValidationTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
|
@ -160,10 +153,7 @@ class SerializationValidationTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
|
|
|
@ -51,8 +51,7 @@ class StorageTest : BaseTest() {
|
|||
}
|
||||
val client = Client<Connection>(config)
|
||||
|
||||
|
||||
client.connect("localhost")
|
||||
client.connect(LOOPBACK)
|
||||
|
||||
Assert.assertTrue(server.storage.getSalt().contentEquals(client.storage.getSalt()))
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class MemoryTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
client.connect()
|
||||
client.connectIpc()
|
||||
}
|
||||
|
||||
Thread.sleep(Long.MAX_VALUE)
|
||||
|
|
|
@ -21,7 +21,6 @@ import dorkbox.network.Server
|
|||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.serialization.Serialization
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
|
@ -31,17 +30,13 @@ class RmiDelayedInvocationTest : BaseTest() {
|
|||
|
||||
@Test
|
||||
fun rmiNetwork() {
|
||||
runBlocking {
|
||||
rmi { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
}
|
||||
rmi()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpc() {
|
||||
runBlocking {
|
||||
rmi()
|
||||
rmi {
|
||||
enableIpc = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +48,7 @@ class RmiDelayedInvocationTest : BaseTest() {
|
|||
* In this test the server has two objects in an object space. The client
|
||||
* uses the first remote object to get the second remote object.
|
||||
*/
|
||||
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
||||
fun rmi(config: Configuration.() -> Unit = {}) {
|
||||
run {
|
||||
val configuration = serverConfig()
|
||||
config(configuration)
|
||||
|
|
|
@ -19,16 +19,13 @@ import dorkbox.network.Client
|
|||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
|
||||
|
||||
@Suppress("unused", "RedundantSuspendModifier")
|
||||
class RmiNestedTest : BaseTest() {
|
||||
|
||||
companion object {
|
||||
private val idCounter = AtomicInteger()
|
||||
}
|
||||
|
@ -118,9 +115,7 @@ class RmiNestedTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK, 5000)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
waitForThreads()
|
||||
}
|
||||
|
@ -185,9 +180,7 @@ class RmiNestedTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK, 5000)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
waitForThreads()
|
||||
}
|
||||
|
@ -245,9 +238,7 @@ class RmiNestedTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK, 5000)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
waitForThreads()
|
||||
}
|
||||
|
@ -306,9 +297,7 @@ class RmiNestedTest : BaseTest() {
|
|||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK, 5000)
|
||||
}
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
waitForThreads()
|
||||
}
|
||||
|
|
|
@ -52,72 +52,60 @@ class RmiSimpleTest : BaseTest() {
|
|||
|
||||
@Test
|
||||
fun rmiIPv4NetworkGlobal() {
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = false) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIPv6NetworkGlobal() {
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = false) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiBothIPv4ConnectNetworkGlobal() {
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = true) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiBothIPv6ConnectNetworkGlobal() {
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = true, runIpv4Connect = true) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmiGlobal(isIpv4 = true, isIpv6 = true, runIpv4Connect = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIPv4NetworkConnection() {
|
||||
rmi(isIpv4 = true, isIpv6 = false) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmi(isIpv4 = true, isIpv6 = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIPv6NetworkConnection() {
|
||||
rmi(isIpv4 = false, isIpv6 = true) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmi(isIpv4 = false, isIpv6 = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiBothIPv4ConnectNetworkConnection() {
|
||||
rmi(isIpv4 = true, isIpv6 = true) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmi(isIpv4 = true, isIpv6 = true)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun rmiBothIPv6ConnectNetworkConnection() {
|
||||
rmi(isIpv4 = true, isIpv6 = true, runIpv4Connect = true) { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmi(isIpv4 = true, isIpv6 = true, runIpv4Connect = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpcNetworkGlobal() {
|
||||
rmiGlobal()
|
||||
rmiGlobal() {
|
||||
enableIpc = true
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpcNetworkConnection() {
|
||||
rmi()
|
||||
rmi() {
|
||||
enableIpc = true
|
||||
}
|
||||
}
|
||||
|
||||
fun rmi(isIpv4: Boolean = false, isIpv6: Boolean = false, runIpv4Connect: Boolean = true, config: (Configuration) -> Unit = {}) {
|
||||
fun rmi(isIpv4: Boolean = false, isIpv6: Boolean = false, runIpv4Connect: Boolean = true, config: Configuration.() -> Unit = {}) {
|
||||
run {
|
||||
val configuration = serverConfig()
|
||||
configuration.enableIPv4 = isIpv4
|
||||
|
@ -176,21 +164,19 @@ class RmiSimpleTest : BaseTest() {
|
|||
stopEndPoints(2000)
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
when {
|
||||
isIpv4 && isIpv6 && runIpv4Connect -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv4 && isIpv6 && !runIpv4Connect -> client.connect(IPv6.LOCALHOST)
|
||||
isIpv4 -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv6 -> client.connect(IPv6.LOCALHOST)
|
||||
else -> client.connect()
|
||||
}
|
||||
when {
|
||||
isIpv4 && isIpv6 && runIpv4Connect -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv4 && isIpv6 && !runIpv4Connect -> client.connect(IPv6.LOCALHOST)
|
||||
isIpv4 -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv6 -> client.connect(IPv6.LOCALHOST)
|
||||
else -> client.connect()
|
||||
}
|
||||
}
|
||||
|
||||
waitForThreads()
|
||||
}
|
||||
|
||||
fun rmiGlobal(isIpv4: Boolean = false, isIpv6: Boolean = false, runIpv4Connect: Boolean = true, config: (Configuration) -> Unit = {}) {
|
||||
fun rmiGlobal(isIpv4: Boolean = false, isIpv6: Boolean = false, runIpv4Connect: Boolean = true, config: Configuration.() -> Unit = {}) {
|
||||
run {
|
||||
val configuration = serverConfig()
|
||||
configuration.enableIPv4 = isIpv4
|
||||
|
@ -244,18 +230,18 @@ class RmiSimpleTest : BaseTest() {
|
|||
stopEndPoints(2000)
|
||||
}
|
||||
|
||||
when {
|
||||
isIpv4 && isIpv6 && runIpv4Connect -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv4 && isIpv6 && !runIpv4Connect -> client.connect(IPv6.LOCALHOST)
|
||||
isIpv4 -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv6 -> client.connect(IPv6.LOCALHOST)
|
||||
else -> client.connect()
|
||||
}
|
||||
|
||||
client.logger.error("Starting test for: Client -> Server")
|
||||
|
||||
// this creates a GLOBAL object on the server (instead of a connection specific object)
|
||||
runBlocking {
|
||||
when {
|
||||
isIpv4 && isIpv6 && runIpv4Connect -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv4 && isIpv6 && !runIpv4Connect -> client.connect(IPv6.LOCALHOST)
|
||||
isIpv4 -> client.connect(IPv4.LOCALHOST)
|
||||
isIpv6 -> client.connect(IPv6.LOCALHOST)
|
||||
else -> client.connect()
|
||||
}
|
||||
|
||||
client.logger.error("Starting test for: Client -> Server")
|
||||
|
||||
// this creates a GLOBAL object on the server (instead of a connection specific object)
|
||||
client.createObject<TestCow>(44) {
|
||||
client.logger.error("Running test for: Client -> Server")
|
||||
RmiCommonTest.runTests(client.connection, this, 44)
|
||||
|
|
|
@ -22,7 +22,6 @@ import dorkbox.network.Server
|
|||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.RemoteObject
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
@ -39,17 +38,13 @@ class RmiSpamAsyncTest : BaseTest() {
|
|||
|
||||
@Test
|
||||
fun rmiNetworkAsync() {
|
||||
runBlocking {
|
||||
rmi { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
}
|
||||
rmi()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpcAsync() {
|
||||
runBlocking {
|
||||
rmi()
|
||||
rmi() {
|
||||
enableIpc = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +52,7 @@ class RmiSpamAsyncTest : BaseTest() {
|
|||
* In this test the server has two objects in an object space. The client
|
||||
* uses the first remote object to get the second remote object.
|
||||
*/
|
||||
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
||||
fun rmi(config: Configuration.() -> Unit = {}) {
|
||||
val server: Server<Connection>
|
||||
|
||||
val mod = 100_000L
|
||||
|
|
|
@ -21,7 +21,6 @@ import dorkbox.network.Server
|
|||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.RemoteObject
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
@ -38,18 +37,14 @@ class RmiSpamSyncSuspendingTest : BaseTest() {
|
|||
|
||||
@Test
|
||||
fun rmiNetwork() {
|
||||
runBlocking {
|
||||
rmi { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
rmi {
|
||||
enableIpc = false
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpc() {
|
||||
runBlocking {
|
||||
rmi()
|
||||
}
|
||||
rmi()
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +52,7 @@ class RmiSpamSyncSuspendingTest : BaseTest() {
|
|||
* In this test the server has two objects in an object space. The client
|
||||
* uses the first remote object to get the second remote object.
|
||||
*/
|
||||
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
||||
fun rmi(config: Configuration.() -> Unit = {}) {
|
||||
val server: Server<Connection>
|
||||
|
||||
val mod = 400L
|
||||
|
|
|
@ -22,7 +22,6 @@ import dorkbox.network.Server
|
|||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.RemoteObject
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
@ -39,17 +38,13 @@ class RmiSpamSyncTest : BaseTest() {
|
|||
|
||||
@Test
|
||||
fun rmiNetwork() {
|
||||
runBlocking {
|
||||
rmi { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
}
|
||||
rmi()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpc() {
|
||||
runBlocking {
|
||||
rmi()
|
||||
rmi() {
|
||||
enableIpc = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +53,7 @@ class RmiSpamSyncTest : BaseTest() {
|
|||
* In this test the server has two objects in an object space. The client
|
||||
* uses the first remote object to get the second remote object.
|
||||
*/
|
||||
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
||||
fun rmi(config: Configuration.() -> Unit = {}) {
|
||||
val server: Server<Connection>
|
||||
|
||||
val mod = 400L
|
||||
|
|
|
@ -102,9 +102,9 @@ object TestClient {
|
|||
connection.close()
|
||||
}
|
||||
|
||||
client.connect(BaseTest.LOOPBACK)
|
||||
|
||||
runBlocking {
|
||||
client.connect(BaseTest.LOOPBACK)
|
||||
client.waitForClose()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue