Search in sources :

Example 81 with MockMessageProducer

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

the class BasicMessageSplitterServiceTest method testDoServiceWithoutCopyObjectMetadata.

@Test
public void testDoServiceWithoutCopyObjectMetadata() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    MessageSplitterServiceImp service = createServiceImpl(new SimpleRegexpMessageSplitter("\\|"), producer);
    AdaptrisMessage msg = createMessage(REGEXP_DATA);
    ((SimpleRegexpMessageSplitter) service.getSplitter()).setCopyMetadata(true);
    Object obj = "ABCDEFG";
    msg.getObjectHeaders().put(obj, obj);
    execute(service, msg);
    List<AdaptrisMessage> producedMessages = producer.getMessages();
    assertEquals(4, producedMessages.size());
    assertEquals("splitCount metadata", 4, Integer.parseInt(msg.getMetadataValue(MessageSplitterServiceImp.KEY_SPLIT_MESSAGE_COUNT)));
    int count = 0;
    for (AdaptrisMessage m : producedMessages) {
        count++;
        assertEquals(METADATA_VALUE, m.getMetadataValue(METADATA_KEY));
        assertFalse(m.getObjectHeaders().containsKey(obj));
        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 82 with MockMessageProducer

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

the class BasicMessageSplitterServiceTest method testSetIgnoreSplitFailures.

@Test
public void testSetIgnoreSplitFailures() throws Exception {
    MessageSplitterServiceImp service = createServiceImpl(new LineCountSplitter(), new MockMessageProducer());
    assertNull(service.getIgnoreSplitMessageFailures());
    assertFalse(service.ignoreSplitMessageFailures());
    service.setIgnoreSplitMessageFailures(Boolean.TRUE);
    assertNotNull(service.ignoreSplitMessageFailures());
    assertEquals(Boolean.TRUE, service.getIgnoreSplitMessageFailures());
    assertTrue(service.ignoreSplitMessageFailures());
    service.setIgnoreSplitMessageFailures(null);
    assertNull(service.getIgnoreSplitMessageFailures());
    assertFalse(service.ignoreSplitMessageFailures());
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) Test(org.junit.Test)

Example 83 with MockMessageProducer

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

the class BasicMessageSplitterServiceTest method testServiceWithLineCountSplitter.

@Test
public void testServiceWithLineCountSplitter() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    MessageSplitterServiceImp service = createServiceImpl(new LineCountSplitter(), producer);
    AdaptrisMessage msg = createMessage(createLineCountMessageInput());
    msg.addMetadata(METADATA_KEY, METADATA_VALUE);
    execute(service, msg);
    assertEquals("Number of messages", 10, producer.getMessages().size());
    assertEquals("splitCount metadata", 10, Integer.parseInt(msg.getMetadataValue(MessageSplitterServiceImp.KEY_SPLIT_MESSAGE_COUNT)));
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 84 with MockMessageProducer

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

the class BasicMessageSplitterServiceTest method testServiceSetters.

@Test
public void testServiceSetters() {
    BasicMessageSplitterService service = new BasicMessageSplitterService();
    assertEquals(NullConnection.class, service.getConnection().getClass());
    assertEquals(NullMessageProducer.class, service.getProducer().getClass());
    try {
        service.setConnection(null);
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        ;
    }
    assertEquals(NullConnection.class, service.getConnection().getClass());
    service.setConnection(new MockConnection());
    assertEquals(MockConnection.class, service.getConnection().getClass());
    try {
        service.setProducer(null);
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        ;
    }
    assertEquals(NullMessageProducer.class, service.getProducer().getClass());
    service.setProducer(new MockMessageProducer());
    assertEquals(MockMessageProducer.class, service.getProducer().getClass());
    try {
        service.setSplitter(null);
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        ;
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 85 with MockMessageProducer

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

the class BasicMessageSplitterServiceTest method testServiceWithRegexpSplitter.

@Test
public void testServiceWithRegexpSplitter() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    MessageSplitterServiceImp service = createServiceImpl(new SimpleRegexpMessageSplitter("\\|"), producer);
    AdaptrisMessage msg = createMessage(REGEXP_DATA);
    execute(service, msg);
    List<AdaptrisMessage> producedMessages = producer.getMessages();
    assertEquals(4, producedMessages.size());
    assertEquals("splitCount metadata", 4, Integer.parseInt(msg.getMetadataValue(MessageSplitterServiceImp.KEY_SPLIT_MESSAGE_COUNT)));
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

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