Search in sources :

Example 11 with MimeEncoder

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

Example 12 with MimeEncoder

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);
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) MimeEncoder(com.adaptris.core.MimeEncoder) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 13 with MimeEncoder

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

Example 14 with MimeEncoder

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

Example 15 with MimeEncoder

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