public class MuxServerTest extends AbstractMuxTest {
public void run() throws Exception {
//Setup server side mux connection
ServerEndpoint se = getServerEndpoint();
TestService service = new TestServiceImpl();
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());