Search in sources :

Example 11 with AssertTask

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());
        }
    });
}
Also used : LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) SimulatorOperation(com.hazelcast.simulator.protocol.operation.SimulatorOperation) Future(java.util.concurrent.Future) AssertTask(com.hazelcast.simulator.utils.AssertTask) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) JMSException(javax.jms.JMSException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 12 with AssertTask

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));
        }
    });
}
Also used : LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) SimulatorOperation(com.hazelcast.simulator.protocol.operation.SimulatorOperation) AssertTask(com.hazelcast.simulator.utils.AssertTask) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) JMSException(javax.jms.JMSException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

AssertTask (com.hazelcast.simulator.utils.AssertTask)12 Verify (com.hazelcast.simulator.test.annotations.Verify)7 Test (org.junit.Test)5 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)2 LogOperation (com.hazelcast.simulator.protocol.operation.LogOperation)2 SimulatorOperation (com.hazelcast.simulator.protocol.operation.SimulatorOperation)2 SuccessTest (com.hazelcast.simulator.tests.SuccessTest)2 MapOperationCounter (com.hazelcast.simulator.tests.map.helpers.MapOperationCounter)2 DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)2 ExecutionException (java.util.concurrent.ExecutionException)2 JMSException (javax.jms.JMSException)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 DistributedObject (com.hazelcast.core.DistributedObject)1 TestCase (com.hazelcast.simulator.common.TestCase)1 StubPromise (com.hazelcast.simulator.protocol.StubPromise)1 StopException (com.hazelcast.simulator.test.StopException)1 TestContext (com.hazelcast.simulator.test.TestContext)1 TestException (com.hazelcast.simulator.test.TestException)1 DummyTest (com.hazelcast.simulator.tests.DummyTest)1 FailingTest (com.hazelcast.simulator.tests.FailingTest)1