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)));
}
}
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());
}
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)));
}
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) {
;
}
}
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)));
}
Aggregations