use of org.apache.camel.Producer in project camel by apache.
the class TimerEndpointTest method testCreateProducer.
@Test
public void testCreateProducer() throws Exception {
Producer producer = endpoint.createProducer();
assertThat(producer, is(notNullValue()));
assertThat(producer, is(instanceOf(TimerProducer.class)));
}
use of org.apache.camel.Producer in project camel by apache.
the class MinaFiltersTest method testFilter.
private void testFilter(final String uri) throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from(uri).to("mock:result");
}
});
MockEndpoint mock = this.getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
Endpoint endpoint = context.getEndpoint(uri);
Exchange exchange = endpoint.createExchange();
Producer producer = endpoint.createProducer();
producer.start();
// set input and execute it
exchange.getIn().setBody("Hello World");
producer.process(exchange);
assertMockEndpointsSatisfied();
assertEquals("The filter should have been called twice (producer and consumer)", 2, TestFilter.called);
producer.stop();
}
use of org.apache.camel.Producer in project camel by apache.
the class MinaLoggerOptionTest method testNoLoggerOption.
@Test
public void testNoLoggerOption() throws Exception {
final String uri = "mina:tcp://localhost:{{port}}?textline=true&sync=false";
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from(uri).to("mock:result");
}
});
MockEndpoint mock = this.getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
Endpoint endpoint = context.getEndpoint(uri);
Exchange exchange = endpoint.createExchange();
Producer producer = endpoint.createProducer();
producer.start();
// set input and execute it
exchange.getIn().setBody("Hello World");
producer.process(exchange);
Field field = producer.getClass().getDeclaredField("session");
field.setAccessible(true);
IoSession session = (IoSession) field.get(producer);
assertFalse("There should NOT default be a logger filter", session.getFilterChain().contains("logger"));
producer.stop();
assertMockEndpointsSatisfied();
}
use of org.apache.camel.Producer in project camel by apache.
the class MinaLoggerOptionTest method testLoggerOptionFalse.
@Test
public void testLoggerOptionFalse() throws Exception {
final String uri = "mina:tcp://localhost:{{port}}?textline=true&minaLogger=false&sync=false";
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from(uri).to("mock:result");
}
});
MockEndpoint mock = this.getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
Endpoint endpoint = context.getEndpoint(uri);
Exchange exchange = endpoint.createExchange();
Producer producer = endpoint.createProducer();
producer.start();
// set input and execute it
exchange.getIn().setBody("Hello World");
producer.process(exchange);
Field field = producer.getClass().getDeclaredField("session");
field.setAccessible(true);
IoSession session = (IoSession) field.get(producer);
assertFalse("There should NOT be a logger filter", session.getFilterChain().contains("logger"));
producer.stop();
assertMockEndpointsSatisfied();
}
use of org.apache.camel.Producer in project camel by apache.
the class CounterEndpointTest method testCreateProducer.
@Test
public void testCreateProducer() throws Exception {
Producer producer = endpoint.createProducer();
assertThat(producer, is(notNullValue()));
assertThat(producer, is(instanceOf(CounterProducer.class)));
}
Aggregations