Search in sources :

Example 1 with DefaultRuntimeEndpointRegistry

use of org.apache.camel.impl.engine.DefaultRuntimeEndpointRegistry in project camel-karaf by apache.

the class ContextListCommandTest method testEndpointStats.

@Test
public void testEndpointStats() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.setRuntimeEndpointRegistry(new DefaultRuntimeEndpointRegistry());
    context.setNameStrategy(new ExplicitCamelContextNameStrategy("foobar"));
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("mock:result");
        }
    });
    context.start();
    context.createProducerTemplate().sendBody("direct:start", "Hello World");
    CamelController controller = new DummyCamelController(context);
    OutputStream os = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(os);
    EndpointStatisticCommand command = new EndpointStatisticCommand("foobar", false, null);
    command.execute(controller, ps, null);
    String out = os.toString();
    assertNotNull(out);
    LOG.info("\n\n{}\n", out);
    assertTrue(out.contains("direct://start"));
    assertTrue(out.contains("mock://result"));
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultRuntimeEndpointRegistry(org.apache.camel.impl.engine.DefaultRuntimeEndpointRegistry) PrintStream(java.io.PrintStream) ExplicitCamelContextNameStrategy(org.apache.camel.impl.engine.ExplicitCamelContextNameStrategy) RouteBuilder(org.apache.camel.builder.RouteBuilder) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 CamelContext (org.apache.camel.CamelContext)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 DefaultRuntimeEndpointRegistry (org.apache.camel.impl.engine.DefaultRuntimeEndpointRegistry)1 ExplicitCamelContextNameStrategy (org.apache.camel.impl.engine.ExplicitCamelContextNameStrategy)1 Test (org.junit.Test)1