Search in sources :

Example 91 with AdaptrisMessage

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);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 92 with AdaptrisMessage

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);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) BodyPartIterator(com.adaptris.util.text.mime.BodyPartIterator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) IgnoreOriginalMimeAggregator(com.adaptris.core.services.aggregator.IgnoreOriginalMimeAggregator) Test(org.junit.Test)

Example 93 with AdaptrisMessage

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());
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 94 with AdaptrisMessage

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());
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 95 with AdaptrisMessage

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());
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1495 Test (org.junit.Test)1362 ServiceException (com.adaptris.core.ServiceException)171 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)158 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)156 StandaloneProducer (com.adaptris.core.StandaloneProducer)125 Channel (com.adaptris.core.Channel)122 MetadataElement (com.adaptris.core.MetadataElement)94 File (java.io.File)89 TimeInterval (com.adaptris.util.TimeInterval)77 CoreException (com.adaptris.core.CoreException)67 Session (javax.jms.Session)62 StandardWorkflow (com.adaptris.core.StandardWorkflow)57 GuidGenerator (com.adaptris.util.GuidGenerator)56 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)50 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)49 Message (javax.jms.Message)47 XPath (com.adaptris.util.text.xml.XPath)45 ServiceList (com.adaptris.core.ServiceList)43 Document (org.w3c.dom.Document)40