use of org.apache.camel.Exchange in project nhin-d by DirectProject.
the class TestRecoveryMonitorRoute method postProcessTest.
@Override
public void postProcessTest() throws Exception {
super.postProcessTest();
final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("shortRecoveryIntervalAggregationDAO");
dao.purgeAll();
assertEquals(0, dao.getAggregationKeys().size());
assertEquals(0, dao.getAggregationCompletedKeys().size());
// pre populate some recovery data
// send original message
final String originalMessageId = UUID.randomUUID().toString();
final Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com,ah4626@direct.securehealthemail.com", "");
final Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(originalMessage);
final ConcurrentJPAAggregationRepository repo = (ConcurrentJPAAggregationRepository) context.getRegistry().lookup("monitoringRepo");
repo.add(context, originalMessageId, exchange);
repo.remove(context, originalMessageId, exchange);
// lock the row to create a delay and ensure we recover
// exchange ids that return null at some point
repo.recover(context, exchange.getExchangeId());
}
use of org.apache.camel.Exchange in project nhin-d by DirectProject.
the class TestTimedOutMonitorRoute method testTimeoutReliableMessage_conditionNotComplete_assertTimedOut.
@Test
public void testTimeoutReliableMessage_conditionNotComplete_assertTimedOut() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeReliableMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", "", "");
template.sendBody("direct:start", originalMessage);
// no MDN sent... messages should timeout after 2 seconds
// sleep 3 seconds to make sure it completes
Thread.sleep(3000);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
Exchange exchange = exchanges.iterator().next();
// make sure there is only 1 message in the exchange
@SuppressWarnings("unchecked") Collection<Tx> messages = exchange.getIn().getBody(Collection.class);
assertEquals(1, messages.size());
assertEquals("timeout", exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY));
}
use of org.apache.camel.Exchange in project nhin-d by DirectProject.
the class TestTimedOutMonitorRoute method testTimeoutReliableMessage_conditionNotComplete_assertTimedOutAndAggregatedTimeoutDecayed.
@Test
public void testTimeoutReliableMessage_conditionNotComplete_assertTimedOutAndAggregatedTimeoutDecayed() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeReliableMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", "", "");
template.sendBody("direct:start", originalMessage);
// sleep .5 second then send the next part of the message
Thread.sleep(500);
// send MDN processed to original message
Tx mdnMessage = TestUtils.makeReliableMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Processed);
template.sendBody("direct:start", mdnMessage);
// no MDN sent... messages should timeout after 1 second from now
// sleep 2 seconds to make sure it completes
Thread.sleep(2000);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
Exchange exchange = exchanges.iterator().next();
// make sure there are 2 messages in the exchange
@SuppressWarnings("unchecked") Collection<Tx> messages = exchange.getIn().getBody(Collection.class);
assertEquals(2, messages.size());
assertEquals("timeout", exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY));
// make sure the aggregated timeout decayed properly... it should now be < 500 ms
assertTrue((Long) exchange.getProperty(Exchange.AGGREGATED_TIMEOUT) < 500);
}
use of org.apache.camel.Exchange in project nhin-d by DirectProject.
the class TestTimedOutMonitorRoute method testTimeoutNonReliableMessage_conditionNotComplete_assertTimedOut.
@Test
public void testTimeoutNonReliableMessage_conditionNotComplete_assertTimedOut() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "");
template.sendBody("direct:start", originalMessage);
// no MDN sent... messages should timeout after 2 seconds
// sleep 3 seconds to make sure it completes
Thread.sleep(3000);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
Exchange exchange = exchanges.iterator().next();
assertEquals("timeout", exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY));
}
use of org.apache.camel.Exchange 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));
}
Aggregations