use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class FtpConsumerTest method testBasicConsume_NoDebug.
@Test
public void testBasicConsume_NoDebug() 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);
FtpConnection consumeConnection = create(server);
consumeConnection.setAdditionalDebug(false);
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.stubs.MockMessageListener in project interlok by adaptris.
the class FtpConsumerTest method testConsume_WithProcDirectory.
@Test
public void testConsume_WithProcDirectory() throws Exception {
int count = 1;
EmbeddedFtpServer helper = new EmbeddedFtpServer();
MockMessageListener listener = new MockMessageListener(100);
FileSystem filesystem = helper.createFilesystem_DirsOnly();
for (int i = 0; i < count; i++) {
filesystem.add(new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt", PAYLOAD));
}
FakeFtpServer server = helper.createAndStart(filesystem);
StandaloneConsumer sc = null;
try {
FtpConsumer ftpConsumer = createForTests(listener);
ftpConsumer.setProcDirectory(DEFAULT_PROC_DIR_CANONICAL);
FtpConnection consumeConnection = create(server);
sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
start(sc);
waitForMessages(listener, count);
Thread.sleep(500);
helper.assertMessages(listener.getMessages(), count);
assertEquals(count, filesystem.listFiles(DEFAULT_PROC_DIR_CANONICAL).size());
} catch (Exception e) {
throw e;
} finally {
stop(sc);
server.stop();
}
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class ActiveMqJmsPollingConsumerTest method testTopic_ProduceConsume.
@Test
public void testTopic_ProduceConsume() throws Exception {
int msgCount = 5;
String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
Sometime poller = new Sometime();
JmsPollingConsumer consumer = createConsumer(activeMqBroker, testName.getMethodName(), rfc6167, poller);
final StandaloneConsumer receiver = new StandaloneConsumer(consumer);
try {
MockMessageListener jms = new MockMessageListener();
receiver.registerAdaptrisMessageListener(jms);
startAndStop(receiver);
start(receiver);
start(sender);
for (int i = 0; i < msgCount; i++) {
sender.doService(createMessage());
}
waitForMessages(jms, msgCount);
assertMessages(jms, msgCount);
} finally {
shutdownQuietly(sender, receiver);
}
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class ActiveMqJmsPollingConsumerTest method testTopic_NoSubscriptionId.
@Test
public void testTopic_NoSubscriptionId() throws Exception {
String rfc6167 = "jms:topic:" + testName.getMethodName();
final StandaloneConsumer consumer = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
try {
consumer.registerAdaptrisMessageListener(new MockMessageListener());
// This won't fail, but... there will be errors in the log file...
start(consumer);
} finally {
shutdownQuietly(null, consumer);
}
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class ActiveMqJmsSyncConsumerTest method testTopic_ProduceConsume.
@Test
public void testTopic_ProduceConsume() throws Exception {
int msgCount = 5;
String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
Sometime poller = new Sometime();
JmsSyncConsumer consumer = createConsumer(testName.getMethodName(), rfc6167, poller);
final StandaloneConsumer receiver = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
try {
MockMessageListener jms = new MockMessageListener();
receiver.registerAdaptrisMessageListener(jms);
startAndStop(receiver);
start(receiver);
start(sender);
for (int i = 0; i < msgCount; i++) {
sender.doService(createMessage());
}
waitForMessages(jms, msgCount);
assertMessages(jms, msgCount);
} finally {
shutdownQuietly(sender, receiver);
}
}
Aggregations