int redirectPort = getPort() + 1;
Redirector rd = new Redirector(getHost(),getPort(),redirectPort);
((TestServerEndpoint) se).redirect(redirectPort);
Thread t = new Thread(rd);
t.start();
BasicJeriExporter exporter = new BasicJeriExporter(se,
new BasicILFactory());
TestService stub = (TestService) exporter.export(service);
//Connect to the mux server
Socket s = new Socket(getHost(),getPort());
InputStream is = s.getInputStream();
OutputStream os = s.getOutputStream();
//Send client connection header
ClientConnectionHeader cHeader = new ClientConnectionHeader();
cHeader.send(os);
//Receive ServerConnection header and verify format
ServerConnectionHeader sHeader = new ServerConnectionHeader();
try {
sHeader.receive(is,getTimeout());
} catch (ProtocolException e) {
e.printStackTrace();
throw new TestException(e.getMessage(),e);
}
//Make a remote call that returns something
stub.doSomething();
exporter.unexport(true);
rd.stop();
//Extract and analyze the messages sent by the mux server
try {
analyzeServerDataBytes(rd.getServerConversation());
} catch (ProtocolException e) {
e.printStackTrace();
throw new TestException(e.getMessage(),e);
}
//Ping the server
PingMessage pm = new PingMessage().setCookie((short)0x5544);
pm.send(os);
//Receive a ping ack from server and verify that the correct cookie
//is included
se = getServerEndpoint();
service = new TestServiceImpl();
exporter = new BasicJeriExporter(se,
new BasicILFactory());
stub = (TestService) exporter.export(service);
//Connect to the mux server
s = new Socket(getHost(),getPort());
is = s.getInputStream();
os = s.getOutputStream();
PingAckMessage pam = new PingAckMessage().setCookie((short)0x5544);