use of com.nokia.dempsy.container.mocks.OutputMessage in project Dempsy by Dempsy.
the class TestMpContainer method testInvokeOutput.
@Test
public void testInvokeOutput() throws Exception {
inputQueue.add(serializer.serialize(new ContainerTestMessage("foo")));
outputQueue.poll(1000, TimeUnit.MILLISECONDS);
inputQueue.add(serializer.serialize(new ContainerTestMessage("bar")));
outputQueue.poll(1000, TimeUnit.MILLISECONDS);
assertEquals("number of MP instances", 2, container.getProcessorCount());
assertTrue("queue is empty", outputQueue.isEmpty());
container.outputPass();
OutputMessage out1 = (OutputMessage) serializer.deserialize((byte[]) outputQueue.poll(1000, TimeUnit.MILLISECONDS));
OutputMessage out2 = (OutputMessage) serializer.deserialize((byte[]) outputQueue.poll(1000, TimeUnit.MILLISECONDS));
assertTrue("messages received", (out1 != null) && (out2 != null));
assertEquals("no more messages in queue", 0, outputQueue.size());
// order of messages is not guaranteed, so we need to aggregate keys
HashSet<String> messageKeys = new HashSet<String>();
messageKeys.add(out1.getKey());
messageKeys.add(out2.getKey());
assertTrue("first MP sent output", messageKeys.contains("foo"));
assertTrue("second MP sent output", messageKeys.contains("bar"));
}
Aggregations