Methods Summary |
---|
void | checkClosedLinks()
boolean thrown = false;
try {
to.send(LinkMessage.newStringMessage("Hello, world!"));
} catch (ClosedLinkException cle) {
thrown = true;
}
assertTrue("send should throw CLE", thrown);
thrown = false;
try {
LinkMessage msg = from.receive();
} catch (ClosedLinkException cle) {
thrown = true;
}
assertTrue("receive should throw CLE", thrown);
|
public void | runTests()Runs all tests.
declare("testKillReceive");
setUp();
testKillReceive();
tearDown();
declare("testKillSend");
setUp();
testKillSend();
tearDown();
declare("testStrandMessage");
setUp();
testStrandMessage();
tearDown();
|
void | setUp()
us = Isolate.currentIsolate();
them = new Isolate("com.sun.midp.links.Echo", null);
them.start();
to = Link.newLink(us, them);
from = Link.newLink(them, us);
LinkPortal.setLinks(them, new Link[] { to, from });
|
void | tearDown()
us = them = null;
to = from = null;
|
void | testKillReceive()
Receiver receiver = new Receiver(from);
assertFalse("receiver blocked", receiver.done);
them.exit(0);
them.waitForExit();
receiver.await();
assertTrue("receiver got IIOE",
receiver.exception instanceof InterruptedIOException);
checkClosedLinks();
|
void | testKillSend()
to.send(LinkMessage.newStringMessage("one"));
Sender sender = new Sender(to, LinkMessage.newStringMessage("two"));
assertFalse("sender blocked", sender.done);
them.exit(0);
them.waitForExit();
sender.await();
assertTrue("sender got IIOE",
sender.exception instanceof InterruptedIOException);
checkClosedLinks();
|
void | testStrandMessage()Tests have the sender strand a message in a link.
byte[] data = new byte[20];
to.send(LinkMessage.newDataMessage(data));
// wait until echo is blocked sending reply back to us
Utils.sleep(100);
them.exit(0);
them.waitForExit();
checkClosedLinks();
|