Tests setting and getting of actual data.
String serviceID = "Test service";
Isolate is = Isolate.currentIsolate();
Link reqC2SLink = Link.newLink(is, is);
Link reqS2CLink = Link.newLink(is, is);
SystemServiceConnectionLinks requestLinksAMS =
new SystemServiceConnectionLinks(reqS2CLink, reqC2SLink);
SystemServiceConnectionLinks requestLinksClient =
new SystemServiceConnectionLinks(reqC2SLink, reqS2CLink);
// precreated connection between service and client
Link conSendLink = Link.newLink(is, is);
Link conRecLink = Link.newLink(is, is);
SystemServiceConnectionLinks links =
new SystemServiceConnectionLinks(conRecLink, conSendLink);
// start listening for requests
SystemServiceRequestListenerImpl l =
new SystemServiceRequestListenerImpl(serviceID, links);
ServiceRequestHandlerThread sp =
new ServiceRequestHandlerThread(requestLinksAMS, l);
// request service
SystemServiceRequestProtocolClient protocol =
new SystemServiceRequestProtocolClient(requestLinksClient);
LinkMessage emptyMsg = LinkMessage.newStringMessage("");
reqC2SLink.send(emptyMsg);
protocol.requestService(serviceID);
// check that service request went without errors
Object result = sp.await();
assertTrue("links sent without error", result == null);
assertTrue("links received without error", l.linksPassed == true);
// check that connection returned as result of request
// is expected one
SystemServiceConnectionLinks con =
protocol.getSystemServiceConnectionLinks();
assertNotSame("link not same",
conSendLink, con.getSendLink());
assertTrue("links equal",
conSendLink.equals(con.getSendLink()));
assertNotSame("link not same",
conRecLink, con.getReceiveLink());
assertTrue("links equal",
conRecLink.equals(con.getReceiveLink()));