Search in sources :

Example 16 with CamelContext

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

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_DSNMessage_parentMsgIdExists_assertMessageIdEvaluated.

@Test
public void testEvaluate_DSNMessage_parentMsgIdExists_assertMessageIdEvaluated() {
    MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
    String msgId = UUID.randomUUID().toString();
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.PARENT_MSG_ID.getType(), new TxDetail(TxDetailType.PARENT_MSG_ID, msgId));
    Tx tx = new Tx(TxMessageType.DSN, details);
    CamelContext context = mock(CamelContext.class);
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    assertEquals(msgId, 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)

Example 17 with CamelContext

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

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_MDNMessage_noParentMsgId_assertNullId.

@Test
public void testEvaluate_MDNMessage_noParentMsgId_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.MDN, 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)

Example 18 with CamelContext

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

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_DNSMessage_noParentMsgId_assertNullId.

@Test
public void testEvaluate_DNSMessage_noParentMsgId_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.MDN, 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)

Example 19 with CamelContext

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

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_MDNMessage_parentMsgIdExists_assertMessageIdEvaluated.

@Test
public void testEvaluate_MDNMessage_parentMsgIdExists_assertMessageIdEvaluated() {
    MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
    String msgId = UUID.randomUUID().toString();
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.PARENT_MSG_ID.getType(), new TxDetail(TxDetailType.PARENT_MSG_ID, msgId));
    Tx tx = new Tx(TxMessageType.MDN, details);
    CamelContext context = mock(CamelContext.class);
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    assertEquals(msgId, 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)

Example 20 with CamelContext

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

the class BasicTxAggregator_aggregateTest method testAggregate_singleEntryExchanged_addSingleTx.

@Test
public void testAggregate_singleEntryExchanged_addSingleTx() {
    TxTimeoutCondition timoutCondition = mock(TxTimeoutCondition.class);
    TxCompletionCondition condition = mock(TxCompletionCondition.class);
    BasicTxAggregator aggr = new BasicTxAggregator(condition, timoutCondition);
    CamelContext context = mock(CamelContext.class);
    DefaultExchange oldExchange = new DefaultExchange(context);
    Tx tx = mock(Tx.class);
    Collection<Tx> oldTxs = new ArrayList<Tx>();
    oldTxs.add(tx);
    oldExchange.getIn().setBody(oldTxs);
    DefaultExchange newExchange = new DefaultExchange(context);
    tx = mock(Tx.class);
    newExchange.getIn().setBody(tx);
    Exchange ex = aggr.aggregate(oldExchange, newExchange);
    @SuppressWarnings("unchecked") Collection<Tx> txs = ex.getIn().getBody(Collection.class);
    assertEquals(2, txs.size());
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) TxTimeoutCondition(org.nhindirect.monitor.condition.TxTimeoutCondition) ArrayList(java.util.ArrayList) 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