Search in sources :

Example 11 with CamelContext

use of org.apache.camel.CamelContext in project Activiti by Activiti.

the class SimpleProcessTest method testRunProcessByKey.

@Deployment(resources = { "process/example.bpmn20.xml" })
public void testRunProcessByKey() throws Exception {
    CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    MockEndpoint me = (MockEndpoint) ctx.getEndpoint("mock:service1");
    me.expectedBodiesReceived("ala");
    tpl.sendBodyAndProperty("direct:start", Collections.singletonMap("var1", "ala"), ActivitiProducer.PROCESS_KEY_PROPERTY, "key1");
    String instanceId = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("key1").singleResult().getProcessInstanceId();
    tpl.sendBodyAndProperty("direct:receive", null, ActivitiProducer.PROCESS_KEY_PROPERTY, "key1");
    assertProcessEnded(instanceId);
    me.assertIsSatisfied();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Deployment(org.activiti.engine.test.Deployment)

Example 12 with CamelContext

use of org.apache.camel.CamelContext in project Activiti by Activiti.

the class SimpleProcessTest method testRunProcess.

@Deployment(resources = { "process/example.bpmn20.xml" })
public void testRunProcess() throws Exception {
    CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    service1.expectedBodiesReceived("ala");
    Exchange exchange = ctx.getEndpoint("direct:start").createExchange();
    exchange.getIn().setBody(Collections.singletonMap("var1", "ala"));
    tpl.send("direct:start", exchange);
    String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
    tpl.sendBodyAndProperty("direct:receive", null, ActivitiProducer.PROCESS_ID_PROPERTY, instanceId);
    assertProcessEnded(instanceId);
    service1.assertIsSatisfied();
    Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class);
    assertEquals("ala", m.get("var1"));
    assertEquals("var2", m.get("var2"));
}
Also used : CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Deployment(org.activiti.engine.test.Deployment)

Example 13 with CamelContext

use of org.apache.camel.CamelContext in project Activiti by Activiti.

the class SimpleSpringProcessTest method testRunProcess.

@Deployment(resources = { "process/example.bpmn20.xml" })
public void testRunProcess() throws Exception {
    CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    service1.expectedBodiesReceived("ala");
    Exchange exchange = ctx.getEndpoint("direct:start").createExchange();
    exchange.getIn().setBody(Collections.singletonMap("var1", "ala"));
    tpl.send("direct:start", exchange);
    String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
    tpl.sendBodyAndProperty("direct:receive", null, ActivitiProducer.PROCESS_ID_PROPERTY, instanceId);
    assertProcessEnded(instanceId);
    service1.assertIsSatisfied();
    Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class);
    assertEquals("ala", m.get("var1"));
    assertEquals("var2", m.get("var2"));
}
Also used : CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Deployment(org.activiti.engine.test.Deployment)

Example 14 with CamelContext

use of org.apache.camel.CamelContext in project nhin-d by DirectProject.

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_emptyDetails_assertNullId.

@Test
public void testEvaluate_emptyDetails_assertNullId() {
    MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
    Tx tx = new Tx(TxMessageType.IMF, new HashMap<String, TxDetail>());
    CamelContext context = mock(CamelContext.class);
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    assertNull(exp.evaluate(exchange, String.class));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 15 with CamelContext

use of org.apache.camel.CamelContext in project nhin-d by DirectProject.

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_IMFMessage_noMsgId_assertNullId.

@Test
public void testEvaluate_IMFMessage_noMsgId_assertNullId() {
    MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.FROM.getType(), new TxDetail(TxDetailType.FROM, "me@test.com"));
    Tx tx = new Tx(TxMessageType.IMF, details);
    CamelContext context = mock(CamelContext.class);
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    assertNull(exp.evaluate(exchange, String.class));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

CamelContext (org.apache.camel.CamelContext)1478 Test (org.junit.Test)691 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)684 RouteBuilder (org.apache.camel.builder.RouteBuilder)448 ProducerTemplate (org.apache.camel.ProducerTemplate)434 ConnectionFactory (javax.jms.ConnectionFactory)220 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)210 Exchange (org.apache.camel.Exchange)109 HashMap (java.util.HashMap)93 Endpoint (org.apache.camel.Endpoint)52 DefaultExchange (org.apache.camel.impl.DefaultExchange)50 IOException (java.io.IOException)46 Map (java.util.Map)45 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)44 CountDownLatch (java.util.concurrent.CountDownLatch)42 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)42 ArrayList (java.util.ArrayList)41 Processor (org.apache.camel.Processor)40 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)37 CamelExecutionException (org.apache.camel.CamelExecutionException)33