use of com.yahoo.messagebus.network.local.LocalWire in project vespa by vespa-engine.
the class ServerThreadingTestCase method requireThatServerIsThreadSafe.
@Test
public void requireThatServerIsThreadSafe() throws Exception {
final LocalWire wire = new LocalWire();
final Client client = new Client(wire);
final Server server = new Server(wire);
for (int i = 0; i < NUM_REQUESTS; ++i) {
final Message msg = new SimpleMessage("foo");
msg.setRoute(Route.parse(server.delegate.connectionSpec()));
msg.pushHandler(client);
assertThat(client.session.send(msg).isAccepted(), is(true));
}
for (int i = 0; i < NUM_REQUESTS; ++i) {
final Reply reply = client.replies.poll(600, TimeUnit.SECONDS);
assertThat(reply, instanceOf(EmptyReply.class));
assertThat(reply.hasErrors(), is(false));
}
assertThat(client.close(), is(true));
assertThat(server.close(), is(true));
}
use of com.yahoo.messagebus.network.local.LocalWire in project vespa by vespa-engine.
the class ClientThreadingTestCase method requireThatClientIsThreadSafe.
@Test
@Ignore
public void requireThatClientIsThreadSafe() throws Exception {
final LocalWire wire = new LocalWire();
final Client client = new Client(wire);
final Server server = new Server(wire);
final List<Callable<Boolean>> lst = new LinkedList<>();
final Route route = Route.parse(server.session.getConnectionSpec());
for (int i = 0; i < NUM_THREADS; ++i) {
lst.add(new RequestTask(client, route));
}
final ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
for (final Future<Boolean> res : executor.invokeAll(lst, 60, TimeUnit.SECONDS)) {
assertThat(res.get(), is(true));
}
assertThat(client.close(), is(true));
assertThat(server.close(), is(true));
}
Aggregations