ServerSocket socket = new ServerSocket(0);
TServerSocket transport = new TServerSocket(socket);
transport.listen();
TThreadPoolServer.Args args = new TThreadPoolServer.Args(transport);
args.processor(new Processor<Iface>(TraceWrap.service(new Service())));
final TServer tserver = new TThreadPoolServer(args);
Thread t = new Thread() {
public void run() {
tserver.serve();
}
};
t.start();
TTransport clientTransport = new TSocket(new Socket("localhost", socket.getLocalPort()));
TestService.Iface client = new TestService.Client(new TBinaryProtocol(clientTransport), new TBinaryProtocol(clientTransport));
client = TraceWrap.client(client);
assertFalse(client.checkTrace(null, "test"));
Span start = Trace.on("start");
assertTrue(client.checkTrace(null, "my test"));
start.stop();
assertNotNull(tracer.traces.get(start.traceId()));
String traces[] = {"my test", "checkTrace", "client:checkTrace", "start"};
assertTrue(tracer.traces.get(start.traceId()).size() == traces.length);
for (int i = 0; i < traces.length; i++)
assertEquals(traces[i], tracer.traces.get(start.traceId()).get(i).description);
tserver.stop();
t.join(100);
}