use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class TranscodingServiceCase method createMimeMessage.
protected AdaptrisMessage createMimeMessage() throws Exception {
AdaptrisMessage tempMessage = createSimpleMessage();
MimeEncoder mimeEncoder = new MimeEncoder();
byte[] payload = mimeEncoder.encode(tempMessage);
return AdaptrisMessageFactory.getDefaultInstance().newMessage(payload);
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class LargeFsConsumerTest method testConsume_WithUnsupportedEncoder.
@Test
public void testConsume_WithUnsupportedEncoder() throws Exception {
String subDir = GUID.safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setResetWipFiles(false);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
fs.setEncoder(new MimeEncoder());
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 10;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
baseDir.mkdirs();
createMimeFiles(baseDir, ".xml", count);
start(sc);
waitForMessages(stub, count);
assertEquals(count, stub.getMessages().size());
assertIgnoreSize(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
} finally {
stop(sc);
// FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class FtpConsumerTest 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 {
FtpConsumer 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 DefaultFailedMessageRetrierJmxTest method testMBean_Retry_File.
@Test
public void testMBean_Retry_File() 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() + "@" + getName());
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);
assertTrue(jmxBean.retryMessage(fileToRetry));
waitForMessages(mock, 1);
assertEquals(1, mock.messageCount());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.MimeEncoder in project interlok by adaptris.
the class RelaxedFtpCase method testConsume_WithEncoder.
@Test
public void testConsume_WithEncoder() throws Exception {
if (areTestsEnabled()) {
MockMessageListener listener = new MockMessageListener();
RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
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 = 1;
try {
FileTransferConnection produceConnection = createConnection();
produceConnection.setCacheConnection(true);
RelaxedFtpProducer 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