use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class DecodingServiceTest method testMimeEncoder.
@Test
public void testMimeEncoder() throws Exception {
DecodingService service = new DecodingService(new MimeEncoder());
AdaptrisMessage msg = createMimeMessage();
assertFalse(msg.headersContainsKey(TEST_METADATA_KEY));
assertFalse(msg.headersContainsKey(TEST_METADATA_KEY_2));
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 testMimeEncoder_DoNotOverrideHeader.
@Test
public void testMimeEncoder_DoNotOverrideHeader() throws Exception {
DecodingService service = new DecodingService(new MimeEncoder());
service.setOverrideMetadata(false);
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(OVERRIDE_HEADER_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 EncodingServiceTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
EncodingService encodingService = new EncodingService();
encodingService.setEncoder(new MimeEncoder());
return encodingService;
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class AggregatingFtpConsumerTest method testEncoder.
@Test
public void testEncoder() throws Exception {
AggregatingFtpConsumer consumer = new AggregatingFtpConsumer();
assertNull(consumer.getEncoder());
consumer.setEncoder(new MimeEncoder());
assertNotNull(consumer.getEncoder());
assertEquals(MimeEncoder.class, consumer.getEncoder().getClass());
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class FtpCase method testConsume_WithEncoder.
@Test
public void testConsume_WithEncoder() throws Exception {
Assume.assumeTrue(areTestsEnabled());
MockMessageListener listener = new MockMessageListener();
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setQuietInterval(new TimeInterval(300l, TimeUnit.MILLISECONDS));
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
ftpConsumer.setEncoder(new MimeEncoder());
FileTransferConnection consumeConnection = createConnection();
consumeConnection.setCacheConnection(true);
StandaloneConsumer sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
start(sc);
int count = 10;
try {
FileTransferConnection produceConnection = createConnection();
produceConnection.setCacheConnection(true);
FtpProducer producer = createFtpProducer();
producer.setEncoder(new MimeEncoder());
produce(new StandaloneProducer(produceConnection, producer), count);
waitForMessages(listener, count);
assertMessages(listener.getMessages(), count);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
stop(sc);
}
}
Aggregations