Search in sources :

Example 6 with MimeEncoder

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()));
}
Also used : MimeEncoder(com.adaptris.core.MimeEncoder) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 7 with MimeEncoder

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()));
}
Also used : MimeEncoder(com.adaptris.core.MimeEncoder) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 8 with MimeEncoder

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;
}
Also used : MimeEncoder(com.adaptris.core.MimeEncoder)

Example 9 with MimeEncoder

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());
}
Also used : MimeEncoder(com.adaptris.core.MimeEncoder) Test(org.junit.Test)

Example 10 with MimeEncoder

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);
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) QuartzCronPoller(com.adaptris.core.QuartzCronPoller) MimeEncoder(com.adaptris.core.MimeEncoder) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Aggregations

MimeEncoder (com.adaptris.core.MimeEncoder)21 Test (org.junit.Test)18 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)13 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)7 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)7 StandaloneProducer (com.adaptris.core.StandaloneProducer)6 File (java.io.File)5 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)4 FileSystem (org.mockftpserver.fake.filesystem.FileSystem)4 Adapter (com.adaptris.core.Adapter)3 Channel (com.adaptris.core.Channel)3 DefaultFailedMessageRetrier (com.adaptris.core.DefaultFailedMessageRetrier)3 DefaultFailedMessageRetrierJmxMBean (com.adaptris.core.DefaultFailedMessageRetrierJmxMBean)3 StandardWorkflow (com.adaptris.core.StandardWorkflow)3 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)3 ObjectName (javax.management.ObjectName)3 CoreException (com.adaptris.core.CoreException)2 QuartzCronPoller (com.adaptris.core.QuartzCronPoller)2 TimeInterval (com.adaptris.util.TimeInterval)2 FileEntry (org.mockftpserver.fake.filesystem.FileEntry)2