use of org.apache.camel.ConsumerTemplate in project camel by apache.
the class ConsumerTemplateAlreadyExistTest method testShouldBeSingleton.
@Test
public void testShouldBeSingleton() {
ConsumerTemplate lookup = context.getRegistry().lookupByNameAndType("myConsumerTemplate", ConsumerTemplate.class);
assertNotNull("Should lookup producer template", lookup);
ConsumerTemplate lookup2 = context.getRegistry().lookupByNameAndType("myConsumerTemplate", ConsumerTemplate.class);
assertNotNull("Should lookup producer template", lookup);
assertSame("Should be same instances (singleton)", lookup, lookup2);
}
use of org.apache.camel.ConsumerTemplate in project camel by apache.
the class ConsumerTemplateMaximumCacheSizeTest method testTemplateMaximumCache.
@Test
public void testTemplateMaximumCache() throws Exception {
assertNotNull("Should have injected a consumer template", template);
ConsumerTemplate lookup = context.getRegistry().lookupByNameAndType("template", ConsumerTemplate.class);
assertNotNull("Should lookup consumer template", lookup);
assertEquals(50, template.getMaximumCacheSize());
assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
// test that we cache at most 50 producers to avoid it eating to much memory
for (int i = 0; i < 53; i++) {
Endpoint e = context.getEndpoint("direct:queue:" + i);
template.receiveNoWait(e);
}
// the eviction is async so force cleanup
template.cleanUp();
assertEquals("Size should be 50", 50, template.getCurrentCacheSize());
template.stop();
// should be 0
assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
}
use of org.apache.camel.ConsumerTemplate in project camel by apache.
the class ProducerTemplateMixedAutoRegisterTwoCamelContextsTest method testHasNoConsumerTemplateCamel1.
@Test
public void testHasNoConsumerTemplateCamel1() {
ConsumerTemplate lookup = context1.getRegistry().lookupByNameAndType("consumerTemplate", ConsumerTemplate.class);
assertNull("Should NOT lookup consumer template", lookup);
}
use of org.apache.camel.ConsumerTemplate in project camel by apache.
the class JettyMulticastJmsFileTest method testJettyMulticastJmsFile.
@Test
public void testJettyMulticastJmsFile() throws Exception {
TestSupport.deleteDirectory("target/jetty");
ProducerTemplate template = camelContext.createProducerTemplate();
String out = template.requestBody(URL, "Hello World", String.class);
assertEquals("Bye World", out);
template.stop();
ConsumerTemplate consumer = camelContext.createConsumerTemplate();
String in = consumer.receiveBody("jms:queue:foo", 5000, String.class);
assertEquals("Hello World", in);
String in2 = consumer.receiveBody("file://target/jetty?noop=true&readLock=none", 5000, String.class);
assertEquals("Hello World", in2);
consumer.stop();
}
use of org.apache.camel.ConsumerTemplate in project camel by apache.
the class ConsumerTemplateAutoRegisterTest method testHasTemplate.
@Test
public void testHasTemplate() {
assertNotNull("Should have injected a consumer template", template);
assertNotNull("The template context should not be null", ((DefaultConsumerTemplate) template).getCamelContext());
ConsumerTemplate lookup = context.getRegistry().lookupByNameAndType("consumerTemplate", ConsumerTemplate.class);
assertNotNull("Should lookup consumer template", lookup);
}
Aggregations