Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Output:
- class test.RouteTesting$SimpleBean
- 313 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is starting
- 315 [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX is enabled
- 687 [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 190 type converters
- 894 [main] INFO org.apache.camel.impl.DefaultCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
- 969 [main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route1 started and consuming from: Endpoint[direct://test]
- 981 [main] INFO org.apache.camel.impl.DefaultCamelContext - Total 1 routes, of which 1 is started.
- 985 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) started in 0.673 seconds
- 1006 [main] INFO route1 - test = false, test2 = false, simpleBean = java.lang.Object@578da21f
- 1008 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is shutting down
- 1008 [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
- 1013 [Camel (camel-1) thread #1 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Route: route1 shutdown complete, was consuming from: Endpoint[direct://test]
- 1014 [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
- 1021 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) uptime 0.713 seconds
- 1021 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is shutdown in 0.013 seconds
- Class:
- package test;
- import org.apache.camel.CamelContext;
- import org.apache.camel.Exchange;
- import org.apache.camel.LoggingLevel;
- import org.apache.camel.Processor;
- import org.apache.camel.ProducerTemplate;
- import org.apache.camel.builder.RouteBuilder;
- import org.apache.camel.impl.DefaultCamelContext;
- import org.junit.Test;
- public class RouteTesting {
- @Test
- public void test() throws Exception {
- System.out.println(SimpleBean.class);
- final CamelContext context = new DefaultCamelContext();
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:test").process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader("simpleBean", new Object());
- }
- }).setHeader("test").simple("${in.headers.simpleBean} == null", Boolean.class).setHeader("test2").simple("${in.headers.simpleBean} != null", Boolean.class).log(LoggingLevel.INFO, "test = ${in.headers.test}, test2 = ${in.headers.test2}, simpleBean = ${in.headers.simpleBean}").to("mock:stuff");
- }
- });
- context.start();
- final ProducerTemplate template = context.createProducerTemplate();
- template.sendBody("direct:test", "body");
- context.stop();
- }
- public static class SimpleBean {
- private String prop;
- public String getProp() {
- return prop;
- }
- public void setProp(String prop) {
- this.prop = prop;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment