Search in sources :

Example 86 with MockMessageProducer

use of com.adaptris.core.stubs.MockMessageProducer in project interlok by adaptris.

the class BasicMessageSplitterServiceTest method testDoServiceWithoutCopyMetadata.

@Test
public void testDoServiceWithoutCopyMetadata() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    MessageSplitterServiceImp service = createServiceImpl(new SimpleRegexpMessageSplitter("\\|"), producer);
    AdaptrisMessage msg = createMessage(REGEXP_DATA);
    ((SimpleRegexpMessageSplitter) service.getSplitter()).setCopyMetadata(false);
    ExampleServiceCase.execute(service, msg);
    List<AdaptrisMessage> producedMessages = producer.getMessages();
    assertTrue(producedMessages.size() == 4);
    assertEquals("splitCount metadata", 4, Integer.parseInt(msg.getMetadataValue(MessageSplitterServiceImp.KEY_SPLIT_MESSAGE_COUNT)));
    int count = 0;
    for (AdaptrisMessage m : producedMessages) {
        count++;
        assertTrue(null == m.getMetadataValue(METADATA_KEY));
        assertEquals(count, Integer.parseInt(m.getMetadataValue(KEY_CURRENT_SPLIT_MESSAGE_COUNT)));
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 87 with MockMessageProducer

use of com.adaptris.core.stubs.MockMessageProducer in project interlok by adaptris.

the class XpathDocumentCopierTest method setUp.

@Before
public void setUp() throws Exception {
    producer = new MockMessageProducer();
    service = createBasic(new XpathDocumentCopier(XPATH_DOCUMENT_COUNT));
    service.setProducer(producer);
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) Before(org.junit.Before)

Example 88 with MockMessageProducer

use of com.adaptris.core.stubs.MockMessageProducer in project interlok by adaptris.

the class XpathSplitterTest method setUp.

@Before
public void setUp() throws Exception {
    producer = new MockMessageProducer();
    service = createBasic(new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8));
    service.setProducer(producer);
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) Before(org.junit.Before)

Example 89 with MockMessageProducer

use of com.adaptris.core.stubs.MockMessageProducer in project interlok by adaptris.

the class ExampleEventHandlerCase method doAssertions.

protected void doAssertions(T eh, int msgCount, Class expectedEventClass) throws Exception {
    AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller();
    MockMessageProducer producer = getProducer(eh);
    waitForMessages(producer, msgCount);
    assertEquals("Should have " + msgCount + " produced message", msgCount, producer.getMessages().size());
    for (Iterator i = producer.getMessages().iterator(); i.hasNext(); ) {
        AdaptrisMessage m = (AdaptrisMessage) i.next();
        Object o = cm.unmarshal(m.getContent());
        assertEquals("Classname", expectedEventClass, o.getClass());
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Iterator(java.util.Iterator)

Example 90 with MockMessageProducer

use of com.adaptris.core.stubs.MockMessageProducer in project interlok by adaptris.

the class FailedMessageRetrierCase method createWorkflow.

protected StandardWorkflow createWorkflow(String uniqueId) throws Exception {
    AdaptrisMessageConsumer consumer = new MockMessageConsumer();
    AdaptrisMessageProducer producer = new MockMessageProducer();
    StandardWorkflow workflow = new StandardWorkflow();
    workflow.setUniqueId(uniqueId);
    workflow.setConsumer(consumer);
    workflow.setProducer(producer);
    Channel channel = new MockChannel();
    channel.setUniqueId(null);
    channel.getWorkflowList().add(workflow);
    channel.prepare();
    return workflow;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessageConsumer(com.adaptris.core.AdaptrisMessageConsumer) AdaptrisMessageProducer(com.adaptris.core.AdaptrisMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer)

Aggregations

MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)321 Test (org.junit.Test)306 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)156 MockChannel (com.adaptris.core.stubs.MockChannel)126 Channel (com.adaptris.core.Channel)125 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)73 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)69 StandaloneProducer (com.adaptris.core.StandaloneProducer)68 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)65 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)56 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)52 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)50 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)44 StandardWorkflow (com.adaptris.core.StandardWorkflow)40 TimeInterval (com.adaptris.util.TimeInterval)40 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)35 ServiceList (com.adaptris.core.ServiceList)33 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)33 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)27