use of com.adaptris.core.stubs.StubMessageFactory in project interlok by adaptris.
the class DecodingServiceTest method testSetMessageFactory.
@Test
public void testSetMessageFactory() throws Exception {
DecodingService s = new DecodingService();
assertNull(s.getMessageFactory());
s = new DecodingService(new MockEncoder());
assertNull(s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
s = new DecodingService(new MockEncoder());
AdaptrisMessageFactory amf = new StubMessageFactory();
s.setMessageFactory(amf);
try {
LifecycleHelper.init(s);
assertEquals(amf, s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
assertEquals(amf, s.getEncoder().currentMessageFactory());
} finally {
LifecycleHelper.close(s);
}
}
use of com.adaptris.core.stubs.StubMessageFactory in project interlok by adaptris.
the class EncodingServiceTest method testSetMessageFactory.
@Test
public void testSetMessageFactory() throws Exception {
EncodingService s = new EncodingService();
assertNull(s.getMessageFactory());
s = new EncodingService(new MockEncoder());
assertNull(s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
s = new EncodingService(new MockEncoder());
AdaptrisMessageFactory amf = new StubMessageFactory();
s.setMessageFactory(amf);
try {
LifecycleHelper.init(s);
assertEquals(amf, s.getMessageFactory());
assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
assertEquals(amf, s.getEncoder().currentMessageFactory());
} finally {
LifecycleHelper.close(s);
}
}
use of com.adaptris.core.stubs.StubMessageFactory in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_CustomMessageFactory.
@Test
public void testQueueProduceAndConsume_CustomMessageFactory() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageFactory(new StubMessageFactory());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
assertEquals(AdaptrisMessageStub.class, jms.getMessages().get(0).getClass());
}
use of com.adaptris.core.stubs.StubMessageFactory in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_CustomMessageFactory.
@Test
public void testTopicProduceAndConsume_CustomMessageFactory() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageFactory(new StubMessageFactory());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
assertEquals(AdaptrisMessageStub.class, jms.getMessages().get(0).getClass());
}
use of com.adaptris.core.stubs.StubMessageFactory in project interlok by adaptris.
the class XpathSplitterTest method testSplit_AlternativeMessageFactory.
@Test
public void testSplit_AlternativeMessageFactory() throws Exception {
AdaptrisMessage msg = new StubMessageFactory().newMessage(XML_MESSAGE, ENCODING_UTF8);
String obj = "ABCDEFG";
msg.addObjectHeader(obj, obj);
XpathMessageSplitter splitter = new XpathMessageSplitter(ENVELOPE_DOCUMENT);
int count = 0;
try (CloseableIterable<AdaptrisMessage> closeable = splitter.splitMessage(msg)) {
for (AdaptrisMessage m : closeable) {
assertEquals(StubMessageFactory.class, m.getFactory().getClass());
count++;
}
}
assertEquals("Number of messages", 3, count);
}
Aggregations