Java Code Examples for org.apache.camel.builder.RouteBuilder

The following examples show how to use org.apache.camel.builder.RouteBuilder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: wildfly-camel   Source File: ParameterBindingTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testParameterBinding() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").bean(OrderBean.class);
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        String result = producer.requestBodyAndHeader("direct:start", 100, "customerId", 200, String.class);
        Assert.assertEquals("Order 100 from customer 200", result);
    } finally {
        camelctx.close();
    }
}
 
Example 2
@Override
public RouteBuilder getRouteBuilder() {
    XPathBuilder xPathBuilder = new XPathBuilder("/order/item");

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("file:src/test/data/camel/splitter?noop=true")
            .split(xPathBuilder)
            .parallelProcessing()
            .setHeader("LineItemId")
            .xpath("/item/@id", String.class)
            .to("file:target/data/camel/splitter?fileName="
                    + "${in.header.LineItemId}-${date:now:yyyyMMddHHmmssSSSSS}.xml");
        }
    };
}
 
Example 3
Source Project: wildfly-camel   Source File: SOAPIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSoapUnmarshal() throws Exception {

    final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .unmarshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope.xml")) {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Element response = producer.requestBody("direct:start", input, Element.class);
        Assert.assertEquals("Customer", response.getLocalName());
    } finally {
        camelctx.close();
    }
}
 
Example 4
@Test
public void testJCacheLoadsCachingProviderEhcache() throws Exception {
	
    try (CamelContext camelctx = new DefaultCamelContext()) {
    	
        camelctx.addRoutes(new RouteBuilder() {
            public void configure() {
                from("jcache://test-cacheB?cachingProvider=org.ehcache.jsr107.EhcacheCachingProvider")
                .to("mock:resultB");
            }
        });
        
        // Just ensure we can start up without any class loading issues
        camelctx.start();
    }
}
 
Example 5
Source Project: wildfly-camel   Source File: CouchbaseIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testComponent() throws Exception {
    initCouchbaseServer();

    DefaultCamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            fromF("couchbase:http://%s/beer-sample?password=&designDocumentName=beer&viewName=brewery_beers&limit=10", TestUtils.getDockerHost())
            .to("mock:result");
        }
    });

    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mockEndpoint.expectedMessageCount(10);

    camelctx.start();
    try {
        mockEndpoint.assertIsSatisfied();
    } finally {
        camelctx.close();
    }
}
 
Example 6
Source Project: wildfly-camel   Source File: SJMSIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMessageConsumerRoute() throws Exception {

    CamelContext camelctx = createCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("sjms:queue:" + QUEUE_NAME + "?connectionFactory=#cfactory").
            transform(body().prepend("Hello ")).to("seda:end");
        }
    });

    camelctx.start();

    PollingConsumer consumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
    consumer.start();

    try {
        // Send a message to the queue
        ConnectionFactory cfactory = lookupConnectionFactory();
        Connection connection = cfactory.createConnection();
        try {
            sendMessage(connection, QUEUE_JNDI_NAME, "Kermit");
            String result = consumer.receive(3000).getIn().getBody(String.class);
            Assert.assertEquals("Hello Kermit", result);
        } finally {
            connection.close();
        }
    } finally {
        camelctx.close();
    }
}
 
Example 7
Source Project: camelinaction   Source File: AggregateABCGroupTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
                // do a little logging
                .log("Sending ${body} with correlation key ${header.myId}")
                // aggregate based on header correlation key
                // notice we do NOT need to use an AggregationStrategy as we
                // groupExchanges
                .aggregate(header("myId")).completionSize(3).groupExchanges()
                    // do a little logging for the published message
                    .log("Sending out ${body}")
                    // and send it to the mock
                    .to("mock:result");
        }
    };
}
 
Example 8
@Test
public void testEndpointRouteWithValidCredentials() throws Exception {
    deployer.deploy(SIMPLE_WAR);
    try {
        CamelContext camelctx = new DefaultCamelContext();
        camelctx.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start")
                        .to("cxf://" + getEndpointAddress("/simple", "cxfuser", "cxfpassword"));
            }
        });

        camelctx.start();
        try {
            ProducerTemplate producer = camelctx.createProducerTemplate();
            String result = producer.requestBody("direct:start", "Kermit", String.class);
            Assert.assertEquals("Hello Kermit", result);
        } finally {
            camelctx.close();
        }
    } finally {
        deployer.undeploy(SIMPLE_WAR);
    }
}
 
Example 9
Source Project: wildfly-camel   Source File: LogProfileIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testWildFlyLogProfileGloabalLogConfig() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.getGlobalOptions().put(Exchange.LOG_EIP_NAME, LogProfileIntegrationTest.class.getName());

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .log("Goodbye ${body}");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        producer.requestBody("direct:start", "Kermit");
        assertLogFileContainsContent(".*LogProfileIntegrationTest.*Goodbye Kermit$");
    } finally {
        camelctx.close();
    }
}
 
Example 10
Source Project: wildfly-camel   Source File: SOAPIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSoapMarshal() throws Exception {

    final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .marshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope.xml")) {
        String expected = XMLUtils.compactXML(input);
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = new Customer("John", "Doe");
        String customerXML = producer.requestBody("direct:start", customer, String.class);
        Assert.assertEquals(expected, XMLUtils.compactXML(customerXML));
    } finally {
        camelctx.close();
    }
}
 
Example 11
Source Project: camelinaction2   Source File: FileCopierWithCamel.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    // create CamelContext
    CamelContext context = new DefaultCamelContext();

    // add our route to the CamelContext
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            from("file:data/inbox?noop=true").to("file:data/outbox");
        }
    });

    // start the route and let it do its work
    context.start();
    Thread.sleep(10000);

    // stop the CamelContext
    context.stop();
}
 
Example 12
Source Project: wildfly-camel   Source File: SOAPIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSoapV1_2Unmarshal() throws Exception {

    final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");
    format.setVersion("1.2");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .unmarshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope-1.2-unmarshal.xml")) {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Element response = producer.requestBody("direct:start", input, Element.class);
        Assert.assertEquals("Customer", response.getLocalName());
    } finally {
        camelctx.close();
    }
}
 
Example 13
Source Project: wildfly-camel   Source File: MustacheIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMustacheComponent() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to("mustache:classpath:template.mustache");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        Exchange response = template.request("direct:start", exchange -> {
            exchange.getIn().setHeader("greeting", "Hello");
            exchange.getIn().setHeader("name", "Kermit");
        });

        Assert.assertEquals("Hello Kermit!", response.getOut().getBody(String.class));
    } finally {
        camelctx.close();
    }
}
 
Example 14
Source Project: camel-k-runtime   Source File: RoutesLoaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("parameters")
public void testLoaders(String location, Class<? extends SourceLoader> type) throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI(location);
    SourceLoader loader = RoutesConfigurer.load(runtime, source);

    assertThat(loader).isInstanceOf(type);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).matches("timer:/*tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class);
}
 
Example 15
Source Project: wildfly-camel   Source File: MvelTransformTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleTransformFromModule() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("mvel:template.mvel");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        String result = producer.requestBody("direct:start", "Kermit", String.class);
        Assert.assertEquals("Hello Kermit", result);
    } finally {
        camelctx.close();
    }
}
 
Example 16
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            context.setTracing(true);

            errorHandler(defaultErrorHandler()
                    .maximumRedeliveries(5).redeliveryDelay(1000));

            onException(IOException.class).maximumRedeliveries(3)
                    .handled(true)
                    .to("mock:ftp");

            from("direct:file")
                    // simulate an error using a processor to throw the exception
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            throw new ConnectException("Simulated connection error");
                        }
                    })
                    .to("mock:http");
        }
    };
}
 
Example 17
Source Project: flowable-engine   Source File: CdiSimpleProcessTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
    service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1");
    service1.reset();
    service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2");
    service2.reset();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("flowable:camelProcess");
            from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody().exchangeProperties();
            from("direct:receive").to("flowable:camelProcess:receive");
            from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2");
        }
    });
}
 
Example 18
Source Project: wildfly-camel   Source File: DropboxIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDropboxProducer() throws Exception {
    Assume.assumeNotNull("DROPBOX_ACCESS_TOKEN is null", DROPBOX_ACCESS_TOKEN);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .toF("dropbox://get?accessToken=%s&clientIdentifier=CamelTesting&remotePath=/hello.txt", DROPBOX_ACCESS_TOKEN);
        }
    });

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        byte[] result = template.requestBody("direct:start", null, byte[].class);
        Assert.assertEquals("Hello Kermit\n", new String(result));
    } finally {
        camelctx.close();
    }
}
 
Example 19
Source Project: camelinaction2   Source File: BigFileSedaTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("file:target/inventory?noop=true")
                .log("Starting to process big file: ${header.CamelFileName}")
                .split(body().tokenize("\n")).streaming()
                    .bean(InventoryService.class, "csvToObject")
                    .to("seda:update")
                .end()
                .log("Done processing big file: ${header.CamelFileName}");

            from("seda:update?concurrentConsumers=20")
                .bean(InventoryService.class, "updateInventory");
        }
    };
}
 
Example 20
Source Project: wildfly-camel   Source File: JoltIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testJoltComponent() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to("jolt:classpath:/schema.json?inputType=JsonString&outputType=JsonString");
        }
    });

    camelctx.start();
    try {
        String input = TestUtils.getResourceValue(JoltIntegrationTest.class, "/input.json");
        String output = TestUtils.getResourceValue(JoltIntegrationTest.class, "/output.json");

        ProducerTemplate template = camelctx.createProducerTemplate();
        String result = template.requestBody("direct:start", input, String.class);

        Assert.assertEquals(output, result);
    } finally {
        camelctx.close();
    }
}
 
Example 21
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            ScheduledExecutorService threadPool = context.getExecutorServiceManager().newScheduledThreadPool(this, "MyThreadPool", 2);

            from("direct:start")
                .log("Sending ${body}")
                // aggregate based on xpath expression which extracts from the
                // arrived message body.
                // use class MyAggregationStrategy for aggregation
                .aggregate(xpath("/order/@customer"), new MyAggregationStrategy())
                    // complete either when we have 2 messages or after 5 sec timeout
                    .completionSize(2).completionTimeout(5000)
                    .timeoutCheckerExecutorService(threadPool)
                    // do a little logging for the published message
                    .log("Completed by ${exchangeProperty.CamelAggregatedCompletedBy}")
                    .log("Sending out ${body}")
                    // and send it to the mock
                    .to("mock:result");
        }
     };
}
 
Example 22
Source Project: wildfly-camel   Source File: FhirJsonIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFhirJsonMarshal() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .marshal().fhirJson("DSTU3");
        }
    });

    camelctx.start();
    try {
        Patient patient = createPatient();
        ProducerTemplate template = camelctx.createProducerTemplate();
        InputStream inputStream = template.requestBody("direct:start", patient, InputStream.class);
        IBaseResource result = FhirContext.forDstu3().newJsonParser().parseResource(new InputStreamReader(inputStream));
        Assert.assertTrue("Expected marshaled patient to be equal", patient.equalsDeep((Base)result));
    } finally {
        camelctx.close();
    }
}
 
Example 23
Source Project: syndesis   Source File: ODataReadRouteSplitResultsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testReferenceODataRouteKeyPredicateAndSubPredicate() throws Exception {
    String resourcePath = "Airports";
    String keyPredicate = "('KLAX')/Location";

    context = new SpringCamelContext(applicationContext);

    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, REF_SERVICE_URI)
                                                        .property(KEY_PREDICATE, keyPredicate));

    Step odataStep = createODataStep(odataConnector, resourcePath);
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, REF_SERVER_PEOPLE_DATA_KLAX_LOC);
}
 
Example 24
Source Project: wildfly-camel   Source File: XmlSecurityIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testXmlSigning() throws Exception {

    CamelContext camelctx = new DefaultCamelContext(new JndiBeanRepository());
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
                .to("xmlsecurity-sign://enveloping?keyAccessor=#accessor&schemaResourceUri=");
        }
    });

    try {
        camelctx.start();

        ProducerTemplate producer = camelctx.createProducerTemplate();
        String signedXml = producer.requestBody("direct:start", XML_PAYLOAD, String.class);

        // Make sure the XML was signed
        Assert.assertTrue(signedXml.contains("ds:SignatureValue"));
    } finally {
        camelctx.close();
    }
}
 
Example 25
Source Project: syndesis   Source File: ODataReadRouteSplitResultsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testODataRouteWithKeyPredicate() throws Exception {
    String keyPredicate = "1";
    Connector odataConnector = createODataConnector(new PropertyBuilder<String>()
                                                        .property(SERVICE_URI, defaultTestServer.servicePlainUri())
                                                        .property(KEY_PREDICATE, keyPredicate));

    Step odataStep = createODataStep(odataConnector, defaultTestServer.resourcePath());
    Integration odataIntegration = createIntegration(odataStep, mockStep);

    RouteBuilder routes = newIntegrationRouteBuilder(odataIntegration);
    context.addRoutes(routes);
    MockEndpoint result = initMockEndpoint();
    result.setMinimumExpectedMessageCount(1);

    context.start();

    result.assertIsSatisfied();
    testResult(result, 0, TEST_SERVER_DATA_1);
}
 
Example 26
Source Project: wildfly-camel   Source File: AvroDataFormatTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMarshalUnmarshal() throws Exception {

    DataFormat avro = new AvroDataFormat(getSchema());
    GenericRecord input = new GenericData.Record(getSchema());
    input.put("name", "Kermit");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").marshal(avro).unmarshal(avro);
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        GenericRecord result = producer.requestBody("direct:start", input, GenericRecord.class);
        Assert.assertEquals("Kermit", result.get("name").toString());
    } finally {
        camelctx.close();
    }
}
 
Example 27
Source Project: wildfly-camel   Source File: SOAPIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSoapV1_2Marshal() throws Exception {

    final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
    format.setContextPath("org.wildfly.camel.test.jaxb.model");

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .marshal(format);
        }
    });

    camelctx.start();
    try (InputStream input = getClass().getResourceAsStream("/envelope-1.2-marshal.xml")) {
        String expected = camelctx.getTypeConverter().mandatoryConvertTo(String.class, input);
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = new Customer("John", "Doe");
        String customerXML = producer.requestBody("direct:start", customer, String.class);
        Assert.assertEquals(expected, XMLUtils.compactXML(customerXML));
    } finally {
        camelctx.close();
    }
}
 
Example 28
private static CamelContext startCamel() throws Exception {
   SimpleRegistry registry = new SimpleRegistry();
   registry.put("FromDecoder", new MessageDecoder());
   registry.put("FromEncoder", new MessageEncoder());
   registry.put("ToDecoder", new MessageDecoder());
   registry.put("ToEncoder", new MessageEncoder());

   final CamelContext context = new DefaultCamelContext(registry);

   context.addRoutes(new RouteBuilder() {

      @Override
      public void configure() throws Exception {
          createNettyRoute();
      }

      protected void createNettyRoute() {
         from(
               "netty:tcp://localhost:55559?encoder=#FromEncoder&"
                     + "decoder=#FromDecoder&"
                     + "disconnectOnNoReply=false&"
                     + "serverClosedChannelExceptionCaughtLogLevel=WARN&"
                     + "keepAlive=true")
         .to(
               "netty:tcp://localhost:55560?encoder=#ToEncoder&"
                     + "decoder=#ToDecoder&" + "disconnectOnNoReply=false&"
                     + "serverClosedChannelExceptionCaughtLogLevel=WARN&"
                     + "keepAlive=true")
         .setId("myRoute");
      }

   });
   context.start();
   return context;
}
 
Example 29
Source Project: activiti6-boot2   Source File: AsyncProcessRevisitedTest.java    License: Apache License 2.0 5 votes vote down vote up
public void setUp() throws Exception {
  camelContext.addRoutes(new RouteBuilder() {

    @Override
    public void configure() throws Exception {
      from("activiti:asyncCamelProcessRevisited:serviceTaskAsync1").to("bean:sleepBean?method=sleep").to("seda:continueAsync1");
      from("seda:continueAsync1").to("activiti:asyncCamelProcessRevisited:receive1");

      from("activiti:asyncCamelProcessRevisited:serviceTaskAsync2").to("bean:sleepBean?method=sleep").to("bean:sleepBean?method=sleep").to("seda:continueAsync2");
      from("seda:continueAsync2").to("activiti:asyncCamelProcessRevisited:receive2");
    }
  });
}
 
Example 30
Source Project: wildfly-camel   Source File: UnivocityIntegrationTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMarshalUnmarshalCSV() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            UniVocityCsvDataFormat dataFormat = new UniVocityCsvDataFormat();
            from("direct:marshal").marshal(dataFormat);
            from("direct:unmarshal").unmarshal(dataFormat);
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Map<String, String> input = asMap("A", "1", "B", "2", "C", "3");
        String res1 = producer.requestBody("direct:marshal", input, String.class);
        Assert.assertEquals(join("1,2,3"), res1);

        List<?> res2 = producer.requestBody("direct:unmarshal", res1, List.class);
        Assert.assertEquals("Expected one row", 1, res2.size());
        Assert.assertEquals(Arrays.asList("1" ,"2", "3"), res2.get(0));
    } finally {
        camelctx.close();
    }
}