super.setUp();
context.addComponent("my", new MyQueueComponent());
}
public void testQueueSize() throws Exception {
PollingConsumer consumer = context.getEndpoint(uri).createPollingConsumer();
consumer.start();
assertNotNull(consumer);
EventDrivenPollingConsumer edpc = assertIsInstanceOf(EventDrivenPollingConsumer.class, consumer);
assertEquals(0, edpc.getQueueSize());
assertEquals(10, edpc.getQueueCapacity());
assertFalse(edpc.isBlockWhenFull());
for (int i = 0; i < 10; i++) {
template.sendBody(uri, "Message " + i);
}
assertEquals(10, edpc.getQueueSize());
try {
template.sendBody(uri, "Message 10");
fail("Should have thrown exception");
} catch (CamelExecutionException e) {
// queue should be full
assertIsInstanceOf(IllegalStateException.class, e.getCause());
}
Exchange out = consumer.receive(5000);
assertNotNull(out);
assertEquals("Message 0", out.getIn().getBody());
assertEquals(9, edpc.getQueueSize());
assertEquals(10, edpc.getQueueCapacity());