Search in sources :

Example 6 with ContainerTestMessage

use of com.nokia.dempsy.container.mocks.ContainerTestMessage in project Dempsy by Dempsy.

the class TestMpContainer method testMtInvokeOutput.

@Test
public void testMtInvokeOutput() throws Exception {
    final int numInstances = 20;
    final int concurrency = 5;
    container.setConcurrency(concurrency);
    for (int i = 0; i < numInstances; i++) inputQueue.put(serializer.serialize(new ContainerTestMessage("foo" + i)));
    for (int i = 0; i < numInstances; i++) assertNotNull(outputQueue.poll(baseTimeoutMillis, TimeUnit.MILLISECONDS));
    assertEquals("number of MP instances", numInstances, container.getProcessorCount());
    assertTrue("queue is empty", outputQueue.isEmpty());
    container.outputPass();
    for (int i = 0; i < numInstances; i++) assertNotNull(serializer.deserialize((byte[]) outputQueue.poll(1000, TimeUnit.MILLISECONDS)));
    assertEquals("no more messages in queue", 0, outputQueue.size());
}
Also used : ContainerTestMessage(com.nokia.dempsy.container.mocks.ContainerTestMessage) Test(org.junit.Test)

Aggregations

ContainerTestMessage (com.nokia.dempsy.container.mocks.ContainerTestMessage)6 Test (org.junit.Test)6 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 BlockingQueueAdaptor (com.nokia.dempsy.messagetransport.blockingqueue.BlockingQueueAdaptor)2 MetricGetters (com.nokia.dempsy.monitoring.coda.MetricGetters)2 OutputMessage (com.nokia.dempsy.container.mocks.OutputMessage)1 HashSet (java.util.HashSet)1