Added toString() verification to unit tests

This commit is contained in:
nathan 2016-03-06 23:49:56 +01:00
parent baf6e7c895
commit 3f579a7529
2 changed files with 18 additions and 8 deletions

View File

@ -39,6 +39,7 @@ class RmiGlobalTest extends BaseTest {
System.err.println("Starting test for: " + remoteObjectID);
//TestObject test = connection.getRemoteObject(id, TestObject.class);
assertEquals(remoteObject.hashCode(), test.hashCode());
RemoteObject remoteObject = (RemoteObject) test;
@ -47,6 +48,13 @@ class RmiGlobalTest extends BaseTest {
// (return values and exceptions are returned, call is synchronous)
System.err.println("hashCode: " + test.hashCode());
System.err.println("toString: " + test);
// see what the "remote" toString() method is
final String s = remoteObject.toString();
remoteObject.enableToString(true);
assertFalse(s.equals(remoteObject.toString()));
test.moo();
test.moo("Cow");
assertEquals(remoteObjectID, test.id());

View File

@ -16,7 +16,10 @@ import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public
class RmiTest extends BaseTest {
@ -35,16 +38,16 @@ class RmiTest extends BaseTest {
//TestObject test = connection.getRemoteObject(id, TestObject.class);
RemoteObject remoteObject = (RemoteObject) test;
final String s = remoteObject.toString();
remoteObject.enableToString(true);
assertFalse(s.equals(remoteObject.toString()));
// Default behavior. RMI is transparent, method calls behave like normal
// (return values and exceptions are returned, call is synchronous)
System.err.println("hashCode: " + test.hashCode());
System.err.println("toString: " + test);
// see what the "remote" toString() method is
final String s = remoteObject.toString();
remoteObject.enableToString(true);
assertFalse(s.equals(remoteObject.toString()));
test.moo();
test.moo("Cow");
assertEquals(remoteObjectID, test.id());
@ -164,7 +167,6 @@ class RmiTest extends BaseTest {
KryoCryptoSerializationManager.DEFAULT = KryoCryptoSerializationManager.DEFAULT();
register(KryoCryptoSerializationManager.DEFAULT);
Configuration configuration = new Configuration();
configuration.tcpPort = tcpPort;
configuration.udpPort = udpPort;