use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.
the class MessagingTest method test.
@Test
public void test() throws Exception {
agentServer = new Server("agents").setBrokerURL(broker.getBrokerURL()).setSelfAddress(agentAddress).setProcessor(new OperationProcessor() {
@Override
public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
System.out.println(op);
promise.answer("OK");
}
}).start();
client = new CoordinatorClient().setProcessor(mock(OperationProcessor.class)).start().connectToAgentBroker(agentAddress, localIp());
final Future f = client.submit(agentAddress, new LogOperation("", Level.DEBUG));
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(f.isDone());
assertEquals("OK", f.get());
}
});
}
use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.
the class MessagingTest method sendCoordinator.
@Test
public void sendCoordinator() throws Exception {
agentServer = new Server("agents").setBrokerURL(broker.getBrokerURL()).setSelfAddress(agentAddress).setProcessor(new OperationProcessor() {
@Override
public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
}
}).start();
final OperationProcessor clientOperationProcessor = mock(OperationProcessor.class);
client = new CoordinatorClient().setProcessor(clientOperationProcessor);
client.getConnectionFactory().setMaxReconnectAttempts(1);
client.start().connectToAgentBroker(agentAddress, localIp());
agentServer.sendCoordinator(new LogOperation("Foo"));
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(clientOperationProcessor).process(any(LogOperation.class), eq(agentAddress), any(Promise.class));
}
});
}
Aggregations