use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneObjectMetadataParamInOut.
@Test
public void testOneObjectMetadataParamInOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_inout"));
JdbcObjectMetadataParameter inOutParameter = new JdbcObjectMetadataParameter();
inOutParameter.setMetadataKey("xSomeAmount");
inOutParameter.setName("xSomeAmount");
inOutParameter.setType(ParameterValueType.INTEGER);
AdaptrisMessage message = createMessage();
message.addObjectHeader("xSomeAmount", 100);
InOutParameters inOutParameters = new InOutParameters();
inOutParameters.add(inOutParameter);
spp.setInOutParameters(inOutParameters);
Map<Object, Object> objectMetadata = message.getObjectHeaders();
assertEquals(1, objectMetadata.size());
assertTrue("100".equals(objectMetadata.get("xSomeAmount").toString()));
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals(1, objectMetadata.size());
assertTrue("105".equals(objectMetadata.get("xSomeAmount").toString()));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class AggregatingJmsConsumeServiceTest method testService_MultipleMessages.
@Test
public void testService_MultipleMessages() throws Exception {
AggregatingQueueConsumer consumer = new AggregatingQueueConsumer();
consumer.setMessageAggregator(new IgnoreOriginalMimeAggregator());
AggregatingJmsConsumeService service = createService(activeMqBroker, consumer, getName());
try {
sendDataMessage(activeMqBroker, getName());
sendDataMessage(activeMqBroker, getName());
start(service);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(PAYLOAD);
msg.addMetadata(DEFAULT_FILTER_KEY, "JMSCorrelationID = '0001'");
service.doService(msg);
BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
assertEquals(2, input.size());
} finally {
stop(service);
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class MessageMetricsInterceptorTest method testDoesNotCreateMoreHistoryThanSpecified.
@Test
public void testDoesNotCreateMoreHistoryThanSpecified() throws Exception {
LifecycleHelper.init(metricsInterceptor);
LifecycleHelper.start(metricsInterceptor);
AdaptrisMessage message = DefaultMessageFactory.getDefaultInstance().newMessage();
// A minus time will expire the time slice immediately after the first message
metricsInterceptor.setTimesliceDuration(new TimeInterval(-1L, TimeUnit.SECONDS));
assertEquals(0, metricsInterceptor.getStats().size());
submitMessage(message);
assertEquals(1, metricsInterceptor.getStats().size());
metricsInterceptor.setTimesliceDuration(new TimeInterval(500L, TimeUnit.MILLISECONDS));
submitMessage(message);
submitMessage(message);
assertEquals(2, metricsInterceptor.getStats().size());
waitFor(1);
submitMessage(message);
submitMessage(message);
submitMessage(message);
// Should still only be 2 time slices
assertEquals(2, metricsInterceptor.getStats().size());
assertEquals(2, ((MessageStatistic) metricsInterceptor.getStats().get(0)).getTotalMessageCount());
assertEquals(3, ((MessageStatistic) metricsInterceptor.getStats().get(1)).getTotalMessageCount());
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class MessageMetricsInterceptorTest method testInterceptor.
@Test
public void testInterceptor() throws Exception {
LifecycleHelper.init(metricsInterceptor);
LifecycleHelper.start(metricsInterceptor);
AdaptrisMessage message = DefaultMessageFactory.getDefaultInstance().newMessage();
assertEquals(0, metricsInterceptor.getStats().size());
submitMessage(message);
// Make sure there is 1 message in the cache
assertEquals(1, metricsInterceptor.getStats().size());
assertEquals(1, ((MessageStatistic) metricsInterceptor.getStats().get(0)).getTotalMessageCount());
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class MessageMetricsInterceptorTest method testInterceptor_WithException.
@Test
public void testInterceptor_WithException() throws Exception {
LifecycleHelper.init(metricsInterceptor);
LifecycleHelper.start(metricsInterceptor);
AdaptrisMessage message = DefaultMessageFactory.getDefaultInstance().newMessage();
message.getObjectHeaders().put(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception());
assertEquals(0, metricsInterceptor.getStats().size());
submitMessage(message);
assertEquals(1, metricsInterceptor.getStats().size());
assertEquals(1, ((MessageStatistic) metricsInterceptor.getStats().get(0)).getTotalMessageCount());
assertEquals(1, ((MessageStatistic) metricsInterceptor.getStats().get(0)).getTotalMessageErrorCount());
}
Aggregations