Updated unit tests to only have serialization registration on the server
This commit is contained in:
parent
23de6725fc
commit
4504f7167e
|
@ -81,12 +81,12 @@ abstract class BaseTest {
|
||||||
jc.context = context
|
jc.context = context
|
||||||
context.reset() // override default configuration
|
context.reset() // override default configuration
|
||||||
|
|
||||||
// rootLogger.setLevel(Level.OFF);
|
// rootLogger.setLevel(Level.OFF)
|
||||||
|
|
||||||
rootLogger.level = Level.INFO;
|
// rootLogger.level = Level.INFO
|
||||||
// rootLogger.level = Level.TRACE;
|
rootLogger.level = Level.TRACE
|
||||||
// rootLogger.level = Level.DEBUG
|
// rootLogger.level = Level.DEBUG
|
||||||
// rootLogger.level = Level.ALL;
|
// rootLogger.level = Level.ALL
|
||||||
|
|
||||||
|
|
||||||
// we only want error messages
|
// we only want error messages
|
||||||
|
|
|
@ -38,11 +38,9 @@ import dorkbox.network.Client
|
||||||
import dorkbox.network.Server
|
import dorkbox.network.Server
|
||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
import dorkbox.network.serialization.Serialization
|
import dorkbox.network.serialization.Serialization
|
||||||
import dorkbox.util.exceptions.SecurityException
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.IOException
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
class PingPongTest : BaseTest() {
|
class PingPongTest : BaseTest() {
|
||||||
|
@ -51,7 +49,6 @@ class PingPongTest : BaseTest() {
|
||||||
var tries = 1000
|
var tries = 1000
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(SecurityException::class, IOException::class)
|
|
||||||
fun pingPong() {
|
fun pingPong() {
|
||||||
fail = "Data not received."
|
fail = "Data not received."
|
||||||
val data = Data()
|
val data = Data()
|
||||||
|
@ -84,7 +81,6 @@ class PingPongTest : BaseTest() {
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val config = clientConfig()
|
val config = clientConfig()
|
||||||
register(config.serialization)
|
|
||||||
|
|
||||||
val client: Client<Connection> = Client(config)
|
val client: Client<Connection> = Client(config)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
|
@ -42,7 +42,6 @@ class SerializationValidationTest : BaseTest() {
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
register(configuration.serialization)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
@ -66,7 +65,7 @@ class SerializationValidationTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = serverConfig()
|
val configuration = serverConfig()
|
||||||
configuration.serialization.registerRmi(TestObject::class.java, TestObjectImpl::class.java)
|
configuration.serialization.registerRmi(TestObject::class.java, TestObjectImpl::class.java)
|
||||||
configuration.serialization.register(TestObject::class.java) // the iface is again, on purpose to verify registration order!
|
configuration.serialization.register(TestObjectImpl::class.java) // this is again, on purpose to verify registration order!
|
||||||
|
|
||||||
val server = Server<Connection>(configuration)
|
val server = Server<Connection>(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
|
@ -80,7 +79,6 @@ class SerializationValidationTest : BaseTest() {
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
configuration.serialization.register(TestObject::class.java)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
|
@ -39,6 +39,7 @@ import dorkbox.network.rmi.RemoteObject
|
||||||
import dorkbox.network.serialization.Serialization
|
import dorkbox.network.serialization.Serialization
|
||||||
import dorkboxTest.network.rmi.cows.MessageWithTestCow
|
import dorkboxTest.network.rmi.cows.MessageWithTestCow
|
||||||
import dorkboxTest.network.rmi.cows.TestCow
|
import dorkboxTest.network.rmi.cows.TestCow
|
||||||
|
import dorkboxTest.network.rmi.cows.TestCowImpl
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
||||||
object RmiCommonTest {
|
object RmiCommonTest {
|
||||||
|
@ -141,10 +142,9 @@ object RmiCommonTest {
|
||||||
connection.logger.error("Finished tests")
|
connection.logger.error("Finished tests")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun register(manager: Serialization) {
|
fun register(serialization: Serialization) {
|
||||||
// manager.register(Any::class.java) // Needed for Object#toString, hashCode, etc.
|
serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
||||||
manager.register(TestCow::class.java)
|
serialization.register(MessageWithTestCow::class.java)
|
||||||
manager.register(MessageWithTestCow::class.java)
|
serialization.register(UnsupportedOperationException::class.java)
|
||||||
manager.register(UnsupportedOperationException::class.java)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,16 +15,21 @@
|
||||||
*/
|
*/
|
||||||
package dorkboxTest.network.rmi
|
package dorkboxTest.network.rmi
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.Level
|
||||||
|
import ch.qos.logback.classic.Logger
|
||||||
|
import ch.qos.logback.classic.joran.JoranConfigurator
|
||||||
import dorkbox.network.Client
|
import dorkbox.network.Client
|
||||||
import dorkbox.network.Configuration
|
import dorkbox.network.Configuration
|
||||||
import dorkbox.network.Server
|
import dorkbox.network.Server
|
||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
import dorkbox.network.rmi.RemoteObject
|
import dorkbox.network.rmi.RemoteObject
|
||||||
import dorkbox.network.serialization.Serialization
|
|
||||||
import dorkboxTest.network.BaseTest
|
import dorkboxTest.network.BaseTest
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.junit.After
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
|
||||||
class RmiDelayedInvocationSpamTest : BaseTest() {
|
class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||||
|
@ -34,6 +39,32 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||||
|
|
||||||
var async = true
|
var async = true
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setupLogBefore() {
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// the logger cannot keep-up if it's on trace
|
||||||
|
rootLogger.level = Level.DEBUG
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun setupLogAfter() {
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// the logger cannot keep-up if it's on trace
|
||||||
|
rootLogger.level = Level.TRACE
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun rmiNetwork() {
|
fun rmiNetwork() {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
|
@ -70,10 +101,6 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun register(serialization: Serialization) {
|
|
||||||
serialization.registerRmi(TestObject::class.java, TestObjectImpl::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this test the server has two objects in an object space. The client
|
* 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.
|
* uses the first remote object to get the second remote object.
|
||||||
|
@ -87,7 +114,8 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = serverConfig()
|
val configuration = serverConfig()
|
||||||
config(configuration)
|
config(configuration)
|
||||||
register(configuration.serialization)
|
|
||||||
|
configuration.serialization.registerRmi(TestObject::class.java, TestObjectImpl::class.java)
|
||||||
|
|
||||||
server = Server(configuration)
|
server = Server(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
|
@ -100,7 +128,6 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
config(configuration)
|
config(configuration)
|
||||||
register(configuration.serialization)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
|
@ -69,7 +69,6 @@ class RmiDelayedInvocationTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
config(configuration)
|
config(configuration)
|
||||||
register(configuration.serialization)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
|
@ -85,9 +85,6 @@ class RmiNestedTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
|
|
||||||
configuration.serialization.registerRmi(TestObject::class.java, TestObjectAnnotImpl::class.java)
|
|
||||||
configuration.serialization.registerRmi(OtherObject::class.java, OtherObjectImpl::class.java)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
||||||
|
@ -154,8 +151,6 @@ class RmiNestedTest : BaseTest() {
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
configuration.serialization.register(TestObject::class.java)
|
|
||||||
configuration.serialization.register(OtherObject::class.java)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
@ -223,8 +218,6 @@ class RmiNestedTest : BaseTest() {
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
configuration.serialization.register(TestObject::class.java)
|
|
||||||
configuration.serialization.register(OtherObjectImpl::class.java)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
|
@ -78,9 +78,6 @@ class RmiSimpleTest : BaseTest() {
|
||||||
config(configuration)
|
config(configuration)
|
||||||
RmiCommonTest.register(configuration.serialization)
|
RmiCommonTest.register(configuration.serialization)
|
||||||
|
|
||||||
// for Client -> Server RMI
|
|
||||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
|
||||||
|
|
||||||
val server = Server<Connection>(configuration)
|
val server = Server<Connection>(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
server.bind()
|
server.bind()
|
||||||
|
@ -105,10 +102,6 @@ class RmiSimpleTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
config(configuration)
|
config(configuration)
|
||||||
RmiCommonTest.register(configuration.serialization)
|
|
||||||
|
|
||||||
// for Server -> Client RMI
|
|
||||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
@ -173,10 +166,7 @@ class RmiSimpleTest : BaseTest() {
|
||||||
run {
|
run {
|
||||||
val configuration = clientConfig()
|
val configuration = clientConfig()
|
||||||
config(configuration)
|
config(configuration)
|
||||||
RmiCommonTest.register(configuration.serialization)
|
|
||||||
|
|
||||||
// for Server -> Client RMI
|
|
||||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
addEndPoint(client)
|
addEndPoint(client)
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,6 @@ import ch.qos.logback.core.ConsoleAppender
|
||||||
import dorkbox.network.Client
|
import dorkbox.network.Client
|
||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
import dorkboxTest.network.BaseTest
|
import dorkboxTest.network.BaseTest
|
||||||
import dorkboxTest.network.rmi.RmiCommonTest
|
|
||||||
import dorkboxTest.network.rmi.cows.TestBabyCow
|
|
||||||
import dorkboxTest.network.rmi.cows.TestBabyCowImpl
|
|
||||||
import dorkboxTest.network.rmi.cows.TestCow
|
import dorkboxTest.network.rmi.cows.TestCow
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
@ -68,9 +65,6 @@ object TestClient {
|
||||||
setup()
|
setup()
|
||||||
|
|
||||||
val configuration = BaseTest.clientConfig()
|
val configuration = BaseTest.clientConfig()
|
||||||
RmiCommonTest.register(configuration.serialization)
|
|
||||||
configuration.serialization.registerRmi(TestBabyCow::class.java, TestBabyCowImpl::class.java)
|
|
||||||
configuration.serialization.register(TestCow::class.java)
|
|
||||||
configuration.enableRemoteSignatureValidation = false
|
configuration.enableRemoteSignatureValidation = false
|
||||||
|
|
||||||
val client = Client<Connection>(configuration)
|
val client = Client<Connection>(configuration)
|
||||||
|
|
|
@ -20,7 +20,7 @@ import dorkbox.network.connection.Connection
|
||||||
import dorkboxTest.network.BaseTest
|
import dorkboxTest.network.BaseTest
|
||||||
import dorkboxTest.network.rmi.RmiCommonTest
|
import dorkboxTest.network.rmi.RmiCommonTest
|
||||||
import dorkboxTest.network.rmi.cows.MessageWithTestCow
|
import dorkboxTest.network.rmi.cows.MessageWithTestCow
|
||||||
import dorkboxTest.network.rmi.cows.TestBabyCow
|
import dorkboxTest.network.rmi.cows.TestBabyCowImpl
|
||||||
import dorkboxTest.network.rmi.cows.TestCow
|
import dorkboxTest.network.rmi.cows.TestCow
|
||||||
import dorkboxTest.network.rmi.cows.TestCowImpl
|
import dorkboxTest.network.rmi.cows.TestCowImpl
|
||||||
import dorkboxTest.network.rmi.multiJVM.TestClient.setup
|
import dorkboxTest.network.rmi.multiJVM.TestClient.setup
|
||||||
|
@ -37,7 +37,7 @@ object TestServer {
|
||||||
val configuration = BaseTest.serverConfig()
|
val configuration = BaseTest.serverConfig()
|
||||||
|
|
||||||
RmiCommonTest.register(configuration.serialization)
|
RmiCommonTest.register(configuration.serialization)
|
||||||
configuration.serialization.register(TestBabyCow::class.java)
|
configuration.serialization.register(TestBabyCowImpl::class.java)
|
||||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
||||||
configuration.enableRemoteSignatureValidation = false
|
configuration.enableRemoteSignatureValidation = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user