// Public ---------------------------------------------------------------------------------------
public void testInvokerThreadSafety() throws Exception
{
Connector serverConnector = new Connector();
InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
serverConnector.create();
SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
serverConnector.addInvocationHandler("JMS", invocationHandler);
serverConnector.start();
// Create n clients each firing requests in their own thread, using the same locator
try
{
final int NUM_CLIENTS = 3;
Thread[] threads = new Thread[NUM_CLIENTS];
Invoker[] invokers = new Invoker[NUM_CLIENTS];
Object obj = new Object();
for (int i = 0; i < NUM_CLIENTS; i++)
{
invokers[i] = new Invoker(serverLocator, obj);
threads[i] = new Thread(invokers[i]);
threads[i].start();
}
synchronized (obj)
{
obj.wait();
}
for (int i = 0; i < NUM_CLIENTS; i++)
{
if (invokers[i].failed)
{
fail();
for (int j = 0; j < NUM_CLIENTS; j++)
{
threads[j].interrupt();
}
}
}
for (int i = 0; i < NUM_CLIENTS; i++)
{
threads[i].join();
}
for (int i = 0; i < NUM_CLIENTS; i++)
{
if (invokers[i].failed)
{
fail();
}
}
}
finally
{
serverConnector.stop();
serverConnector.destroy();
}
}