use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.
the class SerializableMessageTranslatorTest method testSerialize_FileBackedMessage_TooLarge.
@Test
public void testSerialize_FileBackedMessage_TooLarge() throws Exception {
FileBackedMessage adaptrisMessage = (FileBackedMessage) new FileBackedMessageFactory().newMessage();
File sourceFile = TempFileUtils.createTrackedFile(this);
RandomAccessFile rf = new RandomAccessFile(sourceFile, "rw");
// 7Mb should be bigger than the default size.
rf.setLength(1024L * 7 * 1024L);
rf.close();
adaptrisMessage.initialiseFrom(sourceFile);
adaptrisMessage.addMetadata("MetaKey1", "MetaValue1");
adaptrisMessage.addMetadata("MetaKey2", "MetaValue2");
SerializableMessage serialisableAdaptrisMessage = new DefaultSerializableMessageTranslator().translate(adaptrisMessage);
assertEquals("MetaValue1", serialisableAdaptrisMessage.getMessageHeaders().get("MetaKey1"));
assertEquals("MetaValue2", serialisableAdaptrisMessage.getMessageHeaders().get("MetaKey2"));
assertEquals(adaptrisMessage.getUniqueId(), serialisableAdaptrisMessage.getUniqueId());
assertTrue(serialisableAdaptrisMessage.getContent().contains("Size=7 MB"));
}
use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.
the class RequestReplyProducerBaseTest method testMergeReply_IgnoreReplyMetadata.
@Test
public void testMergeReply_IgnoreReplyMetadata() throws Exception {
AdaptrisMessage reply = new FileBackedMessageFactory().newMessage("hello world");
AdaptrisMessage original = new FileBackedMessageFactory().newMessage();
reply.addMessageHeader("hello", "world");
reply.addObjectHeader("goodbye", "cruel world");
setIgnoreReplyMetadata(true);
AdaptrisMessage msg = mergeReply(reply, original);
assertSame(original, msg);
assertEquals("hello world", msg.getContent());
assertNull(msg.getContentEncoding());
assertFalse(msg.headersContainsKey("hello"));
assertFalse(msg.getObjectHeaders().containsKey("goodbye"));
// The reply should be "in-scope" for GC avoidance.
assertTrue(msg.getObjectHeaders().containsKey(reply.getUniqueId()));
}
use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.
the class RelaxedFtpConsumerTest method testSingleFileConsume_FilebackedMessageFactory.
@Test
public void testSingleFileConsume_FilebackedMessageFactory() throws Exception {
setFilesToConsume(new String[] { "/MySingleFile.txt" }, new String[] { "My file payload" }, new long[] { calendarOneYearAgo.getTimeInMillis() });
consumer.setMessageFactory(new FileBackedMessageFactory());
LifecycleHelper.init(consumer);
LifecycleHelper.start(consumer);
waitForConsumer(1, 3000);
assertEquals(1, messageListener.getMessages().size());
}
use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.
the class BasicActiveMqProducerTest method testBlobProduceAndConsumeWithFileMessageFactory.
@Test
public void testBlobProduceAndConsumeWithFileMessageFactory() throws Exception {
if (!ExternalResourcesHelper.isExternalServerAvailable()) {
log.debug("Blob Server not available; skipping test");
return;
}
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageTranslator(new BlobMessageTranslator());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
PtpProducer producer = new PtpProducer().withQueue((getName()));
producer.setMessageTranslator(new BlobMessageTranslator("blobUrl"));
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, addBlobUrlRef(EmbeddedActiveMq.createMessage(new FileBackedMessageFactory()), "blobUrl"), jms);
assertMessages(jms, 1, false);
}
use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.
the class FtpConsumerTest method testBasicConsume_WithFileBackedMessage.
@Test
public void testBasicConsume_WithFileBackedMessage() throws Exception {
int count = 1;
EmbeddedFtpServer helper = new EmbeddedFtpServer();
MockMessageListener listener = new MockMessageListener();
FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
StandaloneConsumer sc = null;
try {
FtpConsumer ftpConsumer = createForTests(listener);
ftpConsumer.setMessageFactory(new FileBackedMessageFactory());
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();
}
}
Aggregations