WIP unit tests. Renamed package, so stacktrace cleanup works correctly (it's based on package name)
This commit is contained in:
parent
10e581a21c
commit
994fa8d196
|
@ -1,4 +1,4 @@
|
|||
package dorkbox.network
|
||||
package dorkboxTest.network
|
||||
|
||||
import ch.qos.logback.classic.Level
|
||||
import ch.qos.logback.classic.Logger
|
||||
|
@ -6,6 +6,8 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder
|
|||
import ch.qos.logback.classic.joran.JoranConfigurator
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent
|
||||
import ch.qos.logback.core.ConsoleAppender
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Configuration
|
||||
import dorkbox.network.connection.Connection
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.slf4j.LoggerFactory
|
||||
|
@ -91,6 +93,9 @@ object AeronClient {
|
|||
configuration.publicationPort = 2001
|
||||
val client = Client<Connection>(configuration)
|
||||
|
||||
|
||||
// client.filter(IpSubnetFilterRule(IPv4.LOCALHOST, 32, IpFilterRuleType.ACCEPT))
|
||||
|
||||
client.filter { connection ->
|
||||
println("should this connection be allowed?")
|
||||
true
|
||||
|
@ -115,8 +120,8 @@ object AeronClient {
|
|||
}
|
||||
|
||||
runBlocking {
|
||||
// client.connect("127.0.0.1") // UDP connection via loopback
|
||||
client.connect() // IPC connection
|
||||
client.connect("127.0.0.1") // UDP connection via loopback
|
||||
// client.connect() // IPC connection
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,7 +133,7 @@ object AeronClient {
|
|||
// send - IPC/local
|
||||
runBlocking {
|
||||
while (!client.isShutdown()) {
|
||||
client.send("ECHO " + java.lang.Long.toUnsignedString(client.secureRandom.nextLong(), 16))
|
||||
client.send("ECHO " + java.lang.Long.toUnsignedString(client.crypto.secureRandom.nextLong(), 16))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dorkbox.network
|
||||
package dorkboxTest.network
|
||||
|
||||
import ch.qos.logback.classic.Level
|
||||
import ch.qos.logback.classic.Logger
|
||||
|
@ -6,6 +6,8 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder
|
|||
import ch.qos.logback.classic.joran.JoranConfigurator
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent
|
||||
import ch.qos.logback.core.ConsoleAppender
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.ServerConfiguration
|
||||
import dorkbox.network.connection.Connection
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.slf4j.LoggerFactory
|
|
@ -17,7 +17,7 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package dorkbox.network
|
||||
package dorkboxTest.network
|
||||
|
||||
import ch.qos.logback.classic.Level
|
||||
import ch.qos.logback.classic.Logger
|
||||
|
@ -25,8 +25,12 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder
|
|||
import ch.qos.logback.classic.joran.JoranConfigurator
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent
|
||||
import ch.qos.logback.core.ConsoleAppender
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Configuration
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.ServerConfiguration
|
||||
import dorkbox.network.connection.EndPoint
|
||||
import dorkbox.util.OS
|
||||
import dorkbox.os.OS
|
||||
import dorkbox.util.entropy.Entropy
|
||||
import dorkbox.util.entropy.SimpleEntropy
|
||||
import dorkbox.util.exceptions.InitializationException
|
|
@ -17,9 +17,11 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package dorkbox.network
|
||||
package dorkboxTest.network
|
||||
|
||||
import dorkbox.network.connection.ConnectionImpl
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.connection.EndPoint
|
||||
import dorkbox.network.connection.MediaDriverConnection
|
||||
import dorkbox.util.exceptions.InitializationException
|
||||
|
@ -38,24 +40,25 @@ class ListenerTest : BaseTest() {
|
|||
var checkFail1 = AtomicBoolean(false)
|
||||
var checkFail2 = AtomicBoolean(false)
|
||||
|
||||
var check1 = AtomicBoolean(false)
|
||||
var check2 = AtomicBoolean(false)
|
||||
var check3 = AtomicBoolean(false)
|
||||
var check4 = AtomicBoolean(false)
|
||||
var check5 = AtomicBoolean(false)
|
||||
var check6 = AtomicBoolean(false)
|
||||
var overrideCheck = AtomicBoolean(false)
|
||||
var serverOnMessage = AtomicBoolean(false)
|
||||
var serverConnect = AtomicBoolean(false)
|
||||
var serverDisconnect = AtomicBoolean(false)
|
||||
var clientConnect = AtomicBoolean(false)
|
||||
var clientDisconnect = AtomicBoolean(false)
|
||||
|
||||
// quick and dirty test to also test connection sub-classing
|
||||
internal open inner class TestConnectionA(endPointConnection: EndPoint<TestConnectionA>, driverConnection: MediaDriverConnection) : ConnectionImpl(endPointConnection, driverConnection) {
|
||||
internal open inner class TestConnectionA(endPointConnection: EndPoint<TestConnectionA>, driverConnection: MediaDriverConnection) : Connection(endPointConnection, driverConnection) {
|
||||
open fun check() {
|
||||
check1.set(true)
|
||||
overrideCheck.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, InitializationException::class, IOException::class, InterruptedException::class)
|
||||
fun listener() {
|
||||
val server: Server<TestConnectionA> = object : Server<TestConnectionA>(serverConfig()) {
|
||||
val server: Server<TestConnectionA> = object : Server<TestConnectionA>(
|
||||
serverConfig()) {
|
||||
override fun newConnection(endPoint: EndPoint<TestConnectionA>, mediaDriverConnection: MediaDriverConnection): TestConnectionA {
|
||||
return TestConnectionA(endPoint, mediaDriverConnection)
|
||||
}
|
||||
|
@ -72,17 +75,17 @@ class ListenerTest : BaseTest() {
|
|||
// generic listener
|
||||
server.onMessage<Any> { _, _ ->
|
||||
// should be called!
|
||||
check2.set(true)
|
||||
serverOnMessage.set(true)
|
||||
}
|
||||
|
||||
// standard connect check
|
||||
server.onConnect {
|
||||
check3.set(true)
|
||||
serverConnect.set(true)
|
||||
}
|
||||
|
||||
// standard listener disconnect check
|
||||
server.onDisconnect {
|
||||
check4.set(true)
|
||||
serverDisconnect.set(true)
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,7 +95,8 @@ class ListenerTest : BaseTest() {
|
|||
|
||||
|
||||
// ----
|
||||
val client: Client<TestConnectionA> = object : Client<TestConnectionA>(clientConfig()) {
|
||||
val client: Client<TestConnectionA> = object : Client<TestConnectionA>(
|
||||
clientConfig()) {
|
||||
override fun newConnection(endPoint: EndPoint<TestConnectionA>, mediaDriverConnection: MediaDriverConnection): TestConnectionA {
|
||||
return TestConnectionA(endPoint, mediaDriverConnection)
|
||||
}
|
||||
|
@ -121,13 +125,13 @@ class ListenerTest : BaseTest() {
|
|||
|
||||
// standard connect check
|
||||
client.onConnect {
|
||||
check5.set(true)
|
||||
clientConnect.set(true)
|
||||
}
|
||||
|
||||
|
||||
// standard listener disconnect check
|
||||
client.onDisconnect {
|
||||
check6.set(true)
|
||||
clientDisconnect.set(true)
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,12 +143,12 @@ class ListenerTest : BaseTest() {
|
|||
|
||||
// -1 BECAUSE we are `getAndIncrement` for each check earlier
|
||||
Assert.assertEquals(limit.toLong(), count.get() - 1.toLong())
|
||||
Assert.assertTrue(check1.get())
|
||||
Assert.assertTrue(check2.get())
|
||||
Assert.assertTrue(check3.get())
|
||||
Assert.assertTrue(check4.get())
|
||||
Assert.assertTrue(check5.get())
|
||||
Assert.assertTrue(check6.get())
|
||||
Assert.assertTrue(overrideCheck.get())
|
||||
Assert.assertTrue(serverOnMessage.get())
|
||||
Assert.assertTrue(serverConnect.get())
|
||||
Assert.assertTrue(serverDisconnect.get())
|
||||
Assert.assertTrue(clientConnect.get())
|
||||
Assert.assertTrue(clientDisconnect.get())
|
||||
|
||||
Assert.assertFalse(checkFail1.get())
|
||||
Assert.assertFalse(checkFail2.get())
|
|
@ -17,8 +17,10 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package dorkbox.network
|
||||
package dorkboxTest.network
|
||||
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import kotlinx.coroutines.runBlocking
|
|
@ -17,8 +17,10 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package dorkbox.network
|
||||
package dorkboxTest.network
|
||||
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkbox.util.serialization.SerializationManager
|
|
@ -17,10 +17,8 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
package dorkbox.network.kryo;
|
||||
package dorkboxTest.network.kryo;
|
||||
|
||||
import static dorkbox.network.kryo.KryoAssert.assertDoubleEquals;
|
||||
import static dorkbox.network.kryo.KryoAssert.assertFloatEquals;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -716,47 +714,47 @@ public class InputOutputByteBufTest extends KryoTestCase {
|
|||
assertEquals(5, write.writeVarFloat(-8192, 1000, true));
|
||||
|
||||
AeronInput read = new AeronInput(write.toBytes());
|
||||
assertFloatEquals(read.readFloat(), 0f);
|
||||
assertFloatEquals(read.readFloat(), 63f);
|
||||
assertFloatEquals(read.readFloat(), 64f);
|
||||
assertFloatEquals(read.readFloat(), 127f);
|
||||
assertFloatEquals(read.readFloat(), 128f);
|
||||
assertFloatEquals(read.readFloat(), 8192f);
|
||||
assertFloatEquals(read.readFloat(), 16384f);
|
||||
assertFloatEquals(read.readFloat(), 32767f);
|
||||
assertFloatEquals(read.readFloat(), -63f);
|
||||
assertFloatEquals(read.readFloat(), -64f);
|
||||
assertFloatEquals(read.readFloat(), -127f);
|
||||
assertFloatEquals(read.readFloat(), -128f);
|
||||
assertFloatEquals(read.readFloat(), -8192f);
|
||||
assertFloatEquals(read.readFloat(), -16384f);
|
||||
assertFloatEquals(read.readFloat(), -32768f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 0f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 0f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 63f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 63f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 64f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 64f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 127f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 127f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 128f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 128f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 8191f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 8191f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 8192f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 8192f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 16383f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 16383f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 16384f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 16384f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), 32767f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), 32767f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), -64f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), -64f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), -65f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), -65f);
|
||||
assertFloatEquals(read.readVarFloat(1000, false), -8192f);
|
||||
assertFloatEquals(read.readVarFloat(1000, true), -8192f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 0f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 63f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 64f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 127f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 128f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 8192f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 16384f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), 32767f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -63f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -64f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -127f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -128f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -8192f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -16384f);
|
||||
KryoAssert.assertFloatEquals(read.readFloat(), -32768f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 0f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 0f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 63f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 63f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 64f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 64f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 127f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 127f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 128f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 128f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 8191f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 8191f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 8192f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 8192f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 16383f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 16383f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 16384f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 16384f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), 32767f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), 32767f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), -64f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), -64f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), -65f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), -65f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, false), -8192f);
|
||||
KryoAssert.assertFloatEquals(read.readVarFloat(1000, true), -8192f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -810,48 +808,48 @@ public class InputOutputByteBufTest extends KryoTestCase {
|
|||
write.writeDouble(1.23456d);
|
||||
|
||||
AeronInput read = new AeronInput(write.toBytes());
|
||||
assertDoubleEquals(read.readDouble(), 0d);
|
||||
assertDoubleEquals(read.readDouble(), 63d);
|
||||
assertDoubleEquals(read.readDouble(), 64d);
|
||||
assertDoubleEquals(read.readDouble(), 127d);
|
||||
assertDoubleEquals(read.readDouble(), 128d);
|
||||
assertDoubleEquals(read.readDouble(), 8192d);
|
||||
assertDoubleEquals(read.readDouble(), 16384d);
|
||||
assertDoubleEquals(read.readDouble(), 32767d);
|
||||
assertDoubleEquals(read.readDouble(), -63d);
|
||||
assertDoubleEquals(read.readDouble(), -64d);
|
||||
assertDoubleEquals(read.readDouble(), -127d);
|
||||
assertDoubleEquals(read.readDouble(), -128d);
|
||||
assertDoubleEquals(read.readDouble(), -8192d);
|
||||
assertDoubleEquals(read.readDouble(), -16384d);
|
||||
assertDoubleEquals(read.readDouble(), -32768d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 0d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 0d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 63d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 63d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 64d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 64d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 127d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 127d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 128d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 128d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 8191d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 8191d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 8192d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 8192d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 16383d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 16383d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 16384d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 16384d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), 32767d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), 32767d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), -64d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), -64d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), -65d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), -65d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, false), -8192d);
|
||||
assertDoubleEquals(read.readVarDouble(1000, true), -8192d);
|
||||
assertDoubleEquals(1.23456d, read.readDouble());
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 0d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 63d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 64d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 127d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 128d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 8192d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 16384d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), 32767d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -63d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -64d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -127d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -128d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -8192d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -16384d);
|
||||
KryoAssert.assertDoubleEquals(read.readDouble(), -32768d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 0d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 0d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 63d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 63d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 64d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 64d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 127d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 127d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 128d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 128d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 8191d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 8191d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 8192d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 8192d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 16383d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 16383d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 16384d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 16384d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), 32767d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), 32767d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), -64d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), -64d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), -65d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), -65d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, false), -8192d);
|
||||
KryoAssert.assertDoubleEquals(read.readVarDouble(1000, true), -8192d);
|
||||
KryoAssert.assertDoubleEquals(1.23456d, read.readDouble());
|
||||
}
|
||||
|
||||
@Test
|
|
@ -1,6 +1,6 @@
|
|||
package dorkbox.network.kryo;
|
||||
package dorkboxTest.network.kryo;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Junit Assert wrapper methods class
|
|
@ -17,7 +17,7 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
package dorkbox.network.kryo;
|
||||
package dorkboxTest.network.kryo;
|
||||
|
||||
import static com.esotericsoftware.minlog.Log.WARN;
|
||||
import static com.esotericsoftware.minlog.Log.warn;
|
||||
|
@ -79,23 +79,28 @@ abstract public class KryoTestCase {
|
|||
/** @param length Pass Integer.MIN_VALUE to disable checking the length. */
|
||||
public <T> T roundTrip (int length, T object1) {
|
||||
T object2 = roundTripWithBufferFactory(length, object1, new BufferFactory() {
|
||||
public Output createOutput (OutputStream os) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os) {
|
||||
return new Output(os);
|
||||
}
|
||||
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
return new Output(os, size);
|
||||
}
|
||||
|
||||
public Output createOutput (int size, int limit) {
|
||||
@Override
|
||||
public Output createOutput (int size, int limit) {
|
||||
return new Output(size, limit);
|
||||
}
|
||||
|
||||
public Input createInput (InputStream os, int size) {
|
||||
@Override
|
||||
public Input createInput (InputStream os, int size) {
|
||||
return new Input(os, size);
|
||||
}
|
||||
|
||||
public Input createInput (byte[] buffer) {
|
||||
@Override
|
||||
public Input createInput (byte[] buffer) {
|
||||
return new Input(buffer);
|
||||
}
|
||||
});
|
||||
|
@ -103,23 +108,28 @@ abstract public class KryoTestCase {
|
|||
if (debug) return object2;
|
||||
|
||||
roundTripWithBufferFactory(length, object1, new BufferFactory() {
|
||||
public Output createOutput (OutputStream os) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os) {
|
||||
return new ByteBufferOutput(os);
|
||||
}
|
||||
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
return new ByteBufferOutput(os, size);
|
||||
}
|
||||
|
||||
public Output createOutput (int size, int limit) {
|
||||
@Override
|
||||
public Output createOutput (int size, int limit) {
|
||||
return new ByteBufferOutput(size, limit);
|
||||
}
|
||||
|
||||
public Input createInput (InputStream os, int size) {
|
||||
@Override
|
||||
public Input createInput (InputStream os, int size) {
|
||||
return new ByteBufferInput(os, size);
|
||||
}
|
||||
|
||||
public Input createInput (byte[] buffer) {
|
||||
@Override
|
||||
public Input createInput (byte[] buffer) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(buffer.length);
|
||||
byteBuffer.put(buffer).flip();
|
||||
return new ByteBufferInput(byteBuffer);
|
||||
|
@ -127,45 +137,55 @@ abstract public class KryoTestCase {
|
|||
});
|
||||
|
||||
roundTripWithBufferFactory(length, object1, new BufferFactory() {
|
||||
public Output createOutput (OutputStream os) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os) {
|
||||
return new UnsafeOutput(os);
|
||||
}
|
||||
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
return new UnsafeOutput(os, size);
|
||||
}
|
||||
|
||||
public Output createOutput (int size, int limit) {
|
||||
@Override
|
||||
public Output createOutput (int size, int limit) {
|
||||
return new UnsafeOutput(size, limit);
|
||||
}
|
||||
|
||||
public Input createInput (InputStream os, int size) {
|
||||
@Override
|
||||
public Input createInput (InputStream os, int size) {
|
||||
return new UnsafeInput(os, size);
|
||||
}
|
||||
|
||||
public Input createInput (byte[] buffer) {
|
||||
@Override
|
||||
public Input createInput (byte[] buffer) {
|
||||
return new UnsafeInput(buffer);
|
||||
}
|
||||
});
|
||||
|
||||
roundTripWithBufferFactory(length, object1, new BufferFactory() {
|
||||
public Output createOutput (OutputStream os) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os) {
|
||||
return new UnsafeByteBufferOutput(os);
|
||||
}
|
||||
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
@Override
|
||||
public Output createOutput (OutputStream os, int size) {
|
||||
return new UnsafeByteBufferOutput(os, size);
|
||||
}
|
||||
|
||||
public Output createOutput (int size, int limit) {
|
||||
@Override
|
||||
public Output createOutput (int size, int limit) {
|
||||
return new UnsafeByteBufferOutput(size, limit);
|
||||
}
|
||||
|
||||
public Input createInput (InputStream os, int size) {
|
||||
@Override
|
||||
public Input createInput (InputStream os, int size) {
|
||||
return new UnsafeByteBufferInput(os, size);
|
||||
}
|
||||
|
||||
public Input createInput (byte[] buffer) {
|
||||
@Override
|
||||
public Input createInput (byte[] buffer) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(buffer.length);
|
||||
byteBuffer.put(buffer).flip();
|
||||
return new UnsafeByteBufferInput(byteBuffer);
|
196
test/dorkboxTest/network/rmi/RmiGlobalTest.kt
Normal file
196
test/dorkboxTest/network/rmi/RmiGlobalTest.kt
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Copyright 2016 dorkbox, llc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Copyright (c) 2008, Nathan Sweet
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* - Neither the name of Esoteric Software nor the names of its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package dorkboxTest.network.rmi
|
||||
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Configuration
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import dorkboxTest.network.rmi.classes.MessageWithTestCow
|
||||
import dorkboxTest.network.rmi.classes.TestCow
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
|
||||
class RmiGlobalTest : BaseTest() {
|
||||
companion object {
|
||||
private const val CLIENT_GLOBAL_OBJECT_ID = 123
|
||||
private const val SERVER_GLOBAL_OBJECT_ID = 2453
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, IOException::class)
|
||||
fun rmiNetwork() {
|
||||
rmi()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, IOException::class)
|
||||
fun rmiLocal() {
|
||||
// rmi(object : Config() {
|
||||
// fun apply(configuration: Configuration) {
|
||||
// configuration.localChannelName = EndPoint.LOCAL_CHANNEL
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
fun rmi(config: (Configuration) -> Unit = {}) {
|
||||
run {
|
||||
val configuration = serverConfig()
|
||||
config(configuration)
|
||||
RmiTest.register(configuration.serialization)
|
||||
|
||||
// NOTICE: none of the super classes/interfaces are registered!
|
||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
||||
|
||||
val server = Server<Connection>(configuration)
|
||||
addEndPoint(server)
|
||||
|
||||
// register this object as a global object that the client will get
|
||||
server.saveGlobalObject(TestCowImpl(SERVER_GLOBAL_OBJECT_ID), SERVER_GLOBAL_OBJECT_ID)
|
||||
|
||||
server.onConnect { connection ->
|
||||
val remoteObject = connection.getObject<TestCow>(CLIENT_GLOBAL_OBJECT_ID)
|
||||
|
||||
System.err.println("Running test for: Server (LOCAL) -> Client (REMOTE)")
|
||||
RmiTest.runTests(connection, remoteObject, CLIENT_GLOBAL_OBJECT_ID)
|
||||
System.err.println("Done with test for: Server (LOCAL) -> Client (REMOTE)")
|
||||
}
|
||||
|
||||
server.onMessage<MessageWithTestCow> { connection, message ->
|
||||
System.err.println("Received finish signal for test for: Client (LOCAL) -> Server (REMOTE)")
|
||||
val `object`: TestCow = message.testCow
|
||||
val id: Int = `object`.id()
|
||||
|
||||
Assert.assertEquals(SERVER_GLOBAL_OBJECT_ID.toLong(), id.toLong())
|
||||
System.err.println("Finished test for: Client (LOCAL) -> Server (REMOTE)")
|
||||
|
||||
stopEndPoints(2000)
|
||||
}
|
||||
|
||||
server.bind(false)
|
||||
}
|
||||
|
||||
run {
|
||||
val configuration = clientConfig()
|
||||
config(configuration)
|
||||
RmiTest.register(configuration.serialization)
|
||||
|
||||
// NOTICE: none of the super classes/interfaces are registered!
|
||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
||||
|
||||
val client = Client<Connection>(configuration)
|
||||
addEndPoint(client)
|
||||
|
||||
// register this object as a global object that the server will get
|
||||
client.saveObject(TestCowImpl(CLIENT_GLOBAL_OBJECT_ID), CLIENT_GLOBAL_OBJECT_ID)
|
||||
|
||||
client.onMessage<MessageWithTestCow> { connection, message ->
|
||||
System.err.println("Received finish signal for test for: Server (LOCAL) -> Client (REMOTE)")
|
||||
|
||||
// this TestCow object should be the implementation, not the proxy.
|
||||
val `object`: TestCow = message.testCow
|
||||
val id: Int = `object`.id()
|
||||
Assert.assertEquals(CLIENT_GLOBAL_OBJECT_ID.toLong(), id.toLong())
|
||||
System.err.println("Finished test for: Server (LOCAL) -> Client (REMOTE)")
|
||||
|
||||
// normally this is in the 'connected', but we do it here, so that it's more linear and easier to debug
|
||||
val remoteCow = connection.getGlobalObject<TestCow>(SERVER_GLOBAL_OBJECT_ID)
|
||||
|
||||
System.err.println("Running test for: Client (LOCAL) -> Server (REMOTE)")
|
||||
RmiTest.runTests(connection, remoteCow, SERVER_GLOBAL_OBJECT_ID)
|
||||
System.err.println("Done with test for: Client (LOCAL) -> Server (REMOTE)")
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
client.connect(LOOPBACK)
|
||||
}
|
||||
}
|
||||
|
||||
waitForThreads(99999999)
|
||||
}
|
||||
|
||||
private open class ConnectionAware {
|
||||
var connection: Connection? = null
|
||||
}
|
||||
|
||||
private class TestCowImpl(private val id: Int) : ConnectionAware(),
|
||||
TestCow {
|
||||
var value = System.currentTimeMillis()
|
||||
var moos = 0
|
||||
|
||||
override fun throwException() {
|
||||
throw UnsupportedOperationException("Why would I do that?")
|
||||
}
|
||||
|
||||
override fun moo() {
|
||||
moos++
|
||||
println("Moo!")
|
||||
}
|
||||
|
||||
override fun moo(value: String) {
|
||||
moos += 2
|
||||
println("Moo: $value")
|
||||
}
|
||||
|
||||
override fun moo(value: String, delay: Long) {
|
||||
moos += 4
|
||||
println("Moo: $value ($delay)")
|
||||
try {
|
||||
Thread.sleep(delay)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun id(): Int {
|
||||
return id
|
||||
}
|
||||
|
||||
override fun slow(): Float {
|
||||
println("Slowdown!!")
|
||||
try {
|
||||
Thread.sleep(2000)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return 123.0f
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,14 +13,15 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dorkbox.network.rmi
|
||||
package dorkboxTest.network.rmi
|
||||
|
||||
import dorkbox.network.BaseTest
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Configuration
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.Rmi
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
|
@ -32,14 +32,15 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package dorkbox.network.rmi
|
||||
package dorkboxTest.network.rmi
|
||||
|
||||
import dorkbox.network.BaseTest
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Configuration
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.Rmi
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
|
@ -32,15 +32,20 @@
|
|||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package dorkbox.network.rmi
|
||||
package dorkboxTest.network.rmi
|
||||
|
||||
import dorkbox.network.*
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Configuration
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.ServerConfiguration
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.classes.MessageWithTestCow
|
||||
import dorkbox.network.rmi.classes.TestCow
|
||||
import dorkbox.network.rmi.classes.TestCowImpl
|
||||
import dorkbox.network.rmi.RemoteObject
|
||||
import dorkbox.network.serialization.NetworkSerializationManager
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import dorkboxTest.network.rmi.classes.MessageWithTestCow
|
||||
import dorkboxTest.network.rmi.classes.TestCow
|
||||
import dorkboxTest.network.rmi.classes.TestCowImpl
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
@ -76,17 +81,7 @@ class RmiTest : BaseTest() {
|
|||
try {
|
||||
test.throwException()
|
||||
} catch (ex: UnsupportedOperationException) {
|
||||
System.err.println("\tExpected exception (exception log should ONLY be on the server).")
|
||||
caught = true
|
||||
}
|
||||
Assert.assertTrue(caught)
|
||||
|
||||
|
||||
// can ONLY wait for responses if we are ASYNC!
|
||||
caught = false
|
||||
try {
|
||||
remoteObject.waitForLastResponse()
|
||||
} catch (ex: IllegalStateException) {
|
||||
System.err.println("\tExpected exception (exception log should ONLY be on the object impl side).")
|
||||
caught = true
|
||||
}
|
||||
Assert.assertTrue(caught)
|
||||
|
@ -113,32 +108,13 @@ class RmiTest : BaseTest() {
|
|||
try {
|
||||
test.throwException()
|
||||
} catch (ex: IllegalStateException) {
|
||||
System.err.println("\tExpected exception (exception log should ONLY be on the object impl side).")
|
||||
caught = true
|
||||
}
|
||||
// exceptions are not caught when async = true!
|
||||
Assert.assertFalse(caught)
|
||||
|
||||
|
||||
// now enable us to wait for responses
|
||||
// can ONLY wait for responses if we are ASYNC + enabled waiting!!
|
||||
remoteObject.enableWaitingForResponse(true)
|
||||
|
||||
|
||||
test.id()
|
||||
// wait for the response to id()
|
||||
Assert.assertEquals(remoteObjectID, remoteObject.waitForLastResponse())
|
||||
|
||||
|
||||
// wait for the response to id()
|
||||
Assert.assertEquals(0, test.id().toLong())
|
||||
val responseId = remoteObject.lastResponseId
|
||||
Assert.assertEquals(remoteObjectID, remoteObject.waitForResponse(responseId))
|
||||
|
||||
|
||||
// Non-blocking call that errors out
|
||||
test.throwException()
|
||||
Assert.assertEquals(remoteObject.waitForLastResponse()?.javaClass, UnsupportedOperationException::class.java)
|
||||
|
||||
// Call will time out if non-blocking isn't working properly
|
||||
test.moo("Mooooooooo", 4000)
|
||||
|
||||
|
@ -241,12 +217,11 @@ class RmiTest : BaseTest() {
|
|||
|
||||
// for Server -> Client RMI
|
||||
configuration.serialization.registerRmi(TestCow::class.java, TestCowImpl::class.java)
|
||||
|
||||
val client = Client<Connection>(configuration)
|
||||
addEndPoint(client)
|
||||
|
||||
client.onConnect { connection ->
|
||||
System.err.println("Starting test for: Client -> Server")
|
||||
|
||||
connection.createObject<TestCow> { remoteObject ->
|
||||
System.err.println("Running test for: Client -> Server")
|
||||
runTests(connection, remoteObject, 1)
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dorkbox.network.rmi.classes
|
||||
package dorkboxTest.network.rmi.classes
|
||||
|
||||
class MessageWithTestCow(val testCow: TestCow) {
|
||||
var number = 0
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dorkbox.network.rmi.classes
|
||||
package dorkboxTest.network.rmi.classes
|
||||
|
||||
/**
|
||||
*
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dorkbox.network.rmi.classes
|
||||
package dorkboxTest.network.rmi.classes
|
||||
|
||||
/**
|
||||
* This is a different interface so we can also test CachedMethod operations
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dorkbox.network.rmi.classes
|
||||
package dorkboxTest.network.rmi.classes
|
||||
|
||||
open class TestCowBaseImpl : TestCowBase {
|
||||
override fun throwException() {
|
|
@ -12,11 +12,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dorkbox.network.rmi.classes
|
||||
package dorkboxTest.network.rmi.classes
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class TestCowImpl : TestCowBaseImpl(), TestCow {
|
||||
class TestCowImpl : TestCowBaseImpl(),
|
||||
TestCow {
|
||||
|
||||
companion object {
|
||||
// has to start at 1
|
Loading…
Reference in New Issue
Block a user