use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class MyBlockingQueue method verifyXmlEndpoint.
@Test
@Ignore("@ApplicationScoped bean proxy cannot be casted to endpoint implementation")
public void verifyXmlEndpoint() {
assertThat("Endpoint type is incorrect!", endpoint, is(instanceOf(SedaEndpoint.class)));
SedaEndpoint seda = (SedaEndpoint) endpoint;
assertThat("Endpoint queue is incorrect!", seda.getQueue(), is(instanceOf(MyBlockingQueue.class)));
assertThat("Endpoint concurrent consumers count is incorrect!", seda.getConcurrentConsumers(), is(equalTo(10)));
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class ManagedRouteAddFromRouteTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
// put a message pre-early on the seda queue, to trigger the route, which
// then would add a 2nd route during CamelContext startup. This is a test
// to ensure the foo route is not started too soon, and thus adding the 2nd
// route works as expected
SedaEndpoint seda = context.getEndpoint("seda:start", SedaEndpoint.class);
seda.getQueue().put(new DefaultExchange(context));
from("seda:start").routeId("foo").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
RouteBuilder child = new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:bar").routeId("bar").to("mock:bar");
}
};
context.addRoutes(child);
}
}).to("mock:result");
}
};
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class AdviceWithMockEndpointsWithSkipTest method testAdvisedMockEndpointsWithSkip.
// START SNIPPET: e1
public void testAdvisedMockEndpointsWithSkip() throws Exception {
// advice the first route using the inlined AdviceWith route builder
// which has extended capabilities than the regular route builder
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// mock sending to direct:foo and skip send to it
mockEndpointsAndSkip("direct:foo");
}
});
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:direct:foo").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
// the message was not send to the direct:foo route and thus not sent to the seda endpoint
SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class);
assertEquals(0, seda.getCurrentQueueSize());
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class ContextScopedOnExceptionLoadBalancerStopRouteTest method testErrorOkError.
public void testErrorOkError() throws Exception {
getMockEndpoint("mock:error").expectedBodiesReceived("Kaboom");
getMockEndpoint("mock:start").expectedBodiesReceived("Kaboom", "World", "Kaboom");
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
getMockEndpoint("mock:exception").expectedBodiesReceived("Kaboom", "Kaboom");
template.sendBody("direct:start", "Kaboom");
template.sendBody("direct:start", "World");
// give time for route to stop
Thread.sleep(1000);
assertEquals(ServiceStatus.Stopped, context.getRouteStatus("errorRoute"));
template.sendBody("direct:start", "Kaboom");
assertMockEndpointsSatisfied();
// should be 1 on the seda queue
SedaEndpoint seda = getMandatoryEndpoint("seda:error", SedaEndpoint.class);
SedaEndpoint seda2 = getMandatoryEndpoint("seda:error2", SedaEndpoint.class);
int size = seda.getQueue().size();
int size2 = seda2.getQueue().size();
assertTrue("There should be 1 exchange on the seda or seda2 queue", size == 1 || size2 == 1);
}
Aggregations