use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class FtpRecursiveConsumerTest method testConsumeWithEncoder.
@Test
public void testConsumeWithEncoder() throws Exception {
int count = 1;
EmbeddedFtpServer helper = new EmbeddedFtpServer();
MockMessageListener listener = new MockMessageListener(100);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
byte[] bytes = new MimeEncoder().encode(msg);
FileSystem filesystem = helper.createFilesystem_DirsOnly();
for (int i = 0; i < count; i++) {
FileEntry entry = new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt");
entry.setContents(bytes);
filesystem.add(entry);
}
FakeFtpServer server = helper.createAndStart(filesystem);
StandaloneConsumer sc = null;
try {
FtpRecursiveConsumer ftpConsumer = createForTests(listener);
ftpConsumer.setEncoder(new MimeEncoder());
FtpConnection consumeConnection = create(server);
sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
start(sc);
waitForMessages(listener, count);
helper.assertMessages(listener.getMessages(), count);
} catch (Exception e) {
throw e;
} finally {
stop(sc);
server.stop();
}
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_WithEncoder.
@Test
public void testQueueProduceAndConsume_WithEncoder() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setEncoder(new MimeEncoder());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
PtpProducer producer = new PtpProducer().withQueue((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 LargeFsMessageProducerTest method testProduce_WithUnsupportedEncoder.
@Test
public void testProduce_WithUnsupportedEncoder() throws Exception {
LargeFsProducer producer = create();
producer.setEncoder(new MimeEncoder());
try {
start(producer);
AdaptrisMessage msg = new FileBackedMessageFactory().newMessage("dummy");
producer.produce(msg);
FileBackedMimeEncoder encoder = new FileBackedMimeEncoder();
encoder.setRetainUniqueId(true);
File writtenFile = new File(destDir, msg.getUniqueId());
// Won't work.
AdaptrisMessage result = encoder.readMessage(writtenFile);
fail();
} catch (Exception expected) {
} finally {
stop(producer);
}
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_File_WorkflowNotFound.
@Test
public void testMBean_Retry_File_WorkflowNotFound() throws Exception {
Adapter adapter = createAdapter(getName());
Channel c = createChannel(getName());
StandardWorkflow wf = createWorkflow(getName());
MockMessageProducer mock = new MockMessageProducer();
wf.setProducer(mock);
c.getWorkflowList().add(wf);
adapter.getChannelList().add(c);
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
adapter.setFailedMessageRetrier(retrier);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@BLAHBLAH");
File fileToRetry = writeFile(msg, new MimeEncoder());
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
assertFalse(jmxBean.retryMessage(fileToRetry));
assertEquals(0, mock.messageCount());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_File_NotFoundException.
@Test
public void testMBean_Retry_File_NotFoundException() throws Exception {
Adapter adapter = createAdapter(getName());
Channel c = createChannel(getName());
StandardWorkflow wf = createWorkflow(getName());
MockMessageProducer mock = new MockMessageProducer();
wf.setProducer(mock);
c.getWorkflowList().add(wf);
adapter.getChannelList().add(c);
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
adapter.setFailedMessageRetrier(retrier);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@BLAHBLAH");
File fileToRetry = writeFile(msg, new MimeEncoder());
fileToRetry.delete();
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
try {
jmxBean.retryMessage(fileToRetry);
fail();
} catch (IOException expected) {
}
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
Aggregations