use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class FtpCase method testConsume_WithEncoder.
@Test
public void testConsume_WithEncoder() throws Exception {
Assume.assumeTrue(areTestsEnabled());
MockMessageListener listener = new MockMessageListener();
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setQuietInterval(new TimeInterval(300l, TimeUnit.MILLISECONDS));
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 = 10;
try {
FileTransferConnection produceConnection = createConnection();
produceConnection.setCacheConnection(true);
FtpProducer 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);
}
}
use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class FtpCase method testConsume_CachedConnection.
@Test
public void testConsume_CachedConnection() throws Exception {
Assume.assumeTrue(areTestsEnabled());
MockMessageListener listener = new MockMessageListener();
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setQuietInterval(new TimeInterval(300l, TimeUnit.MILLISECONDS));
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
FileTransferConnection consumeConnection = createConnection();
consumeConnection.setCacheConnection(true);
StandaloneConsumer sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
start(sc);
int count = 10;
try {
FileTransferConnection produceConnection = createConnection();
produceConnection.setCacheConnection(true);
produce(new StandaloneProducer(produceConnection, createFtpProducer()), count);
waitForMessages(listener, count);
assertMessages(listener.getMessages(), count);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
stop(sc);
}
}
use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class FtpCase method testConsumeWithFilter.
@Test
public void testConsumeWithFilter() throws Exception {
Assume.assumeTrue(areTestsEnabled());
MockMessageListener listener = new MockMessageListener();
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.setWorkDirectory(DEFAULT_WORK_DIR);
ftpConsumer.setFileFilterImp(GlobFilenameFilter.class.getCanonicalName());
ftpConsumer.setFilterExpression(".txt");
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
start(sc);
int count = 1;
try {
FtpProducer ftpProducer = createFtpProducer();
MetadataFileNameCreator mfc = new MetadataFileNameCreator();
mfc.setDefaultName(new GuidGenerator().getUUID() + ".txt");
mfc.setMetadataKey(new GuidGenerator().getUUID());
ftpProducer.setFilenameCreator(mfc);
produce(new StandaloneProducer(createConnection(), ftpProducer), count);
Awaitility.await().atMost(Duration.ofSeconds(5)).with().pollInterval(Duration.ofMillis(100)).until(() -> listener.getMessages().size() >= count);
assertMessages(listener.getMessages(), count);
} finally {
stop(sc);
}
}
use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class RelaxedFtpCase method testConsume_EncryptedPassword.
@Test
public void testConsume_EncryptedPassword() throws Exception {
if (areTestsEnabled()) {
MockMessageListener listener = new MockMessageListener();
RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
start(sc);
int count = 1;
try {
FileTransferConnectionUsingPassword conn = createConnection();
String pw = conn.getDefaultPassword();
String decodedPw = Password.decode(pw);
if (pw.equals(decodedPw)) {
// The password was never encrypted!
conn.setDefaultPassword(Password.encode(conn.getDefaultPassword(), Password.PORTABLE_PASSWORD));
}
produce(new StandaloneProducer(conn, createFtpProducer()), count);
waitForMessages(listener, count);
assertMessages(listener.getMessages(), count);
} finally {
stop(sc);
}
}
}
use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class RelaxedFtpCase method testConsumeWithNonMatchingFilter.
@Test
public void testConsumeWithNonMatchingFilter() throws Exception {
if (areTestsEnabled()) {
MockMessageListener listener = new MockMessageListener();
RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
ftpConsumer.setFileFilterImp(GlobFilenameFilter.class.getCanonicalName());
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setFilterExpression(".xml");
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
start(sc);
int count = 1;
try {
produce(new StandaloneProducer(createConnection(), createFtpProducer()), count);
try {
Thread.sleep(1500);
} catch (Exception e) {
;
}
assertMessages(listener.getMessages(), 0);
} finally {
stop(sc);
}
}
}
Aggregations