use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class FtpProducerTest method testProduce_WithEncoder.
@Test
public void testProduce_WithEncoder() throws Exception {
EmbeddedFtpServer helper = new EmbeddedFtpServer();
FileSystem filesystem = helper.createFilesystem_DirsOnly();
FakeFtpServer server = helper.createAndStart(filesystem);
try {
FtpProducer ftpProducer = createForTests();
FtpConnection produceConnection = create(server);
ftpProducer.setEncoder(new MimeEncoder());
StandaloneProducer sp = new StandaloneProducer(produceConnection, ftpProducer);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
ServiceCase.execute(sp, msg);
assertEquals(1, filesystem.listFiles(DEFAULT_WORK_DIR_CANONICAL).size());
} finally {
server.stop();
}
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_WithEncoder.
@Test
public void testTopicProduceAndConsume_WithEncoder() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setEncoder(new MimeEncoder());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
PasProducer producer = new PasProducer().withTopic(getName());
producer.setEncoder(new MimeEncoder());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class DecodingServiceTest method testMimeEncoder_OverrideHeader.
@Test
public void testMimeEncoder_OverrideHeader() throws Exception {
DecodingService service = new DecodingService(new MimeEncoder());
service.setOverrideMetadata(true);
AdaptrisMessage msg = createMimeMessage();
msg.addMetadata(TEST_METADATA_KEY, OVERRIDE_HEADER_VALUE);
assertTrue(msg.headersContainsKey(TEST_METADATA_KEY));
assertEquals(OVERRIDE_HEADER_VALUE, msg.getMetadataValue(TEST_METADATA_KEY));
execute(service, msg);
assertTrue(msg.headersContainsKey(TEST_METADATA_KEY));
assertTrue(msg.headersContainsKey(TEST_METADATA_KEY_2));
assertEquals(TEST_METADATA_VALUE, msg.getMetadataValue(TEST_METADATA_KEY));
assertEquals(TEST_METADATA_VALUE_2, msg.getMetadataValue(TEST_METADATA_KEY_2));
assertEquals(TEST_PAYLOAD, new String(msg.getPayload()));
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class DecodingServiceTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
DecodingService decodingService = new DecodingService();
decodingService.setEncoder(new MimeEncoder());
decodingService.setOverrideMetadata(false);
return decodingService;
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class EncodingServiceTest method testMimeEncoder.
@Test
public void testMimeEncoder() throws Exception {
EncodingService service = new EncodingService(new MimeEncoder());
AdaptrisMessage msg = createSimpleMessage();
execute(service, msg);
MimeEncoder me = new MimeEncoder();
AdaptrisMessage encodedMessage = me.decode(msg.getPayload());
assertTrue(encodedMessage.headersContainsKey(TEST_METADATA_KEY));
assertTrue(encodedMessage.headersContainsKey(TEST_METADATA_KEY_2));
assertEquals(TEST_METADATA_VALUE, encodedMessage.getMetadataValue(TEST_METADATA_KEY));
assertEquals(TEST_METADATA_VALUE_2, encodedMessage.getMetadataValue(TEST_METADATA_KEY_2));
assertEquals(TEST_PAYLOAD, new String(encodedMessage.getPayload()));
}
Aggregations