Guest User

Camel Header testing

a guest
Dec 4th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. Output:
  2. class test.RouteTesting$SimpleBean
  3. 313 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is starting
  4. 315 [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX is enabled
  5. 687 [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 190 type converters
  6. 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
  7. 969 [main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route1 started and consuming from: Endpoint[direct://test]
  8. 981 [main] INFO org.apache.camel.impl.DefaultCamelContext - Total 1 routes, of which 1 is started.
  9. 985 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) started in 0.673 seconds
  10. 1006 [main] INFO route1 - test = false, test2 = false, simpleBean = java.lang.Object@578da21f
  11. 1008 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is shutting down
  12. 1008 [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
  13. 1013 [Camel (camel-1) thread #1 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Route: route1 shutdown complete, was consuming from: Endpoint[direct://test]
  14. 1014 [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
  15. 1021 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) uptime 0.713 seconds
  16. 1021 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.12.2 (CamelContext: camel-1) is shutdown in 0.013 seconds
  17.  
  18. Class:
  19. package test;
  20.  
  21. import org.apache.camel.CamelContext;
  22. import org.apache.camel.Exchange;
  23. import org.apache.camel.LoggingLevel;
  24. import org.apache.camel.Processor;
  25. import org.apache.camel.ProducerTemplate;
  26. import org.apache.camel.builder.RouteBuilder;
  27. import org.apache.camel.impl.DefaultCamelContext;
  28. import org.junit.Test;
  29.  
  30. public class RouteTesting {
  31.  
  32. @Test
  33. public void test() throws Exception {
  34. System.out.println(SimpleBean.class);
  35. final CamelContext context = new DefaultCamelContext();
  36. context.addRoutes(new RouteBuilder() {
  37.  
  38. @Override
  39. public void configure() throws Exception {
  40. from("direct:test").process(new Processor() {
  41.  
  42. @Override
  43. public void process(Exchange exchange) throws Exception {
  44. exchange.getIn().setHeader("simpleBean", new Object());
  45. }
  46. }).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");
  47. }
  48. });
  49.  
  50. context.start();
  51.  
  52. final ProducerTemplate template = context.createProducerTemplate();
  53. template.sendBody("direct:test", "body");
  54.  
  55. context.stop();
  56. }
  57.  
  58. public static class SimpleBean {
  59. private String prop;
  60.  
  61. public String getProp() {
  62. return prop;
  63. }
  64.  
  65. public void setProp(String prop) {
  66. this.prop = prop;
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment