Java 类org.apache.camel.processor.interceptor.DefaultTraceFormatter 实例源码

项目:Camel    文件:TraceInterceptorWithOutBodyTraceTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            // START SNIPPET: tracingOutExchanges
            Tracer tracer = new Tracer();
            tracer.setTraceOutExchanges(true);

            // we configure the default trace formatter where we can
            // specify which fields we want in the output
            DefaultTraceFormatter formatter = new DefaultTraceFormatter();
            formatter.setShowOutBody(true);
            formatter.setShowOutBodyType(true);

            // set to use our formatter
            tracer.setFormatter(formatter);

            getContext().addInterceptStrategy(tracer);
            // END SNIPPET: tracingOutExchanges

            from("direct:start").
                transform().body().
                to("mock:a").
                to("mock:b");
        }
    };
}
项目:switchyard    文件:DomainCamelContextConfigurationTest.java   
@Test
public void testConfiguration() throws Exception {
    Assert.assertNotNull(_camelContext.getProperty("abc"));
    Assert.assertEquals("xyz", _camelContext.getProperty("abc"));
    Assert.assertEquals("foobar-camel-context", _camelContext.getName());
    Assert.assertEquals(true, _camelContext.isUseMDCLogging());
    Assert.assertEquals(ManagementStatisticsLevel.RoutesOnly
            , _camelContext.getManagementStrategy().getStatisticsLevel());
    Assert.assertEquals(false, _camelContext.isAllowUseOriginalMessage());
    Assert.assertEquals(true, _camelContext.isStreamCaching());
    DataFormatDefinition dfd = _camelContext.getDataFormats().get("transform-json");
    Assert.assertNotNull(dfd);
    Assert.assertEquals("json-jackson", dfd.getDataFormatName());
    Assert.assertTrue(dfd instanceof JsonDataFormat);

    MockEndpoint mock = _camelContext.getEndpoint("mock:output", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("foobar-input");
    _camelContext.createProducerTemplate().sendBody("direct:input", "foobar-input");
    mock.assertIsSatisfied();

    // CamelContext should be able to find CDI beans produced by this class from registry.
    Assert.assertEquals(true, _camelContext.isTracing());
    DefaultTraceFormatter formatter =
            (DefaultTraceFormatter) ((Tracer)_camelContext.getDefaultTracer()).getFormatter();
    Assert.assertEquals(false, formatter.isShowBody());
    Assert.assertEquals(false, formatter.isShowBreadCrumb());
    Assert.assertEquals(100, formatter.getMaxChars());

    @SuppressWarnings("deprecation")
    ErrorHandlerBuilder builder = _camelContext.getErrorHandlerBuilder();
    Assert.assertEquals(ErrorHandlerBuilderRef.class, builder.getClass());
    Assert.assertEquals("foobarErrorHandler", ((ErrorHandlerBuilderRef)builder).getRef());
}
项目:switchyard    文件:DomainCamelContextConfigurationTest.java   
@Produces @Named("traceFormatter")
public DefaultTraceFormatter getTraceFormatter() {
    DefaultTraceFormatter formatter = new DefaultTraceFormatter();
    formatter.setShowBody(false);
    formatter.setShowBreadCrumb(false);
    formatter.setMaxChars(100);
    return formatter;
}
项目:metasfresh    文件:AbstractEDITest.java   
public void enableTracing()
{
    try
    {
        final InputStream in = getClass().getResourceAsStream("/tracing.log.properties");
        if (in != null)
        {
            LogManager.getLogManager().readConfiguration(in);
        }
    }
    catch (final Exception e)
    {
        throw new RuntimeCamelException(e);
    }

    context.setTracing(true);
    // context.setDelayer(Long.valueOf(1000*1));

    final Tracer tracer = new Tracer();

    final DefaultTraceFormatter formatter = new DefaultTraceFormatter();
    formatter.setShowOutBody(true);
    formatter.setShowOutBodyType(true);
    formatter.setShowException(true);
    // formatter.setShowBreadCrumb(false);
    // formatter.setShowNode(false);
    tracer.setFormatter(formatter);

    tracer.setLogLevel(LoggingLevel.DEBUG);

    context.addInterceptStrategy(tracer);

    Logger.getLogger("org.apache.commons.httpclient.HttpClient")
            .setLevel(Level.WARNING); // logging is not needed
    Logger.getLogger("org.apache.commons.httpclient.Wire")
            .setLevel(Level.WARNING); // logging is not needed
    Logger.getLogger("org.apache.commons.httpclient.HttpConnection")
            .setLevel(Level.WARNING); // logging is not needed
    Logger.getLogger("org.apache.commons.httpclient.HttpMethodBase")
            .setLevel(Level.WARNING); // logging is not needed
    Logger.getLogger("org.apache.camel.impl.converter.BaseTypeConverterRegistry")
            .setLevel(Level.WARNING); // logging is not needed
}