use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class FtpCase method testConsumeWithQuietPeriod.
@Test
public void testConsumeWithQuietPeriod() throws Exception {
Assume.assumeTrue(areTestsEnabled());
MockMessageListener listener = new MockMessageListener();
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.setWorkDirectory(DEFAULT_WORK_DIR);
ftpConsumer.setQuietInterval(new TimeInterval(3L, TimeUnit.SECONDS));
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
start(sc);
int count = 1;
try {
produce(new StandaloneProducer(createConnection(), createFtpProducer()), 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 FtpCase method testBasicConsumeWithOverride.
@Test
public void testBasicConsumeWithOverride() throws Exception {
Assume.assumeTrue(areTestsEnabled());
MockMessageListener listener = new MockMessageListener();
FtpConsumer ftpConsumer = new FtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationStringWithOverride());
ftpConsumer.setWorkDirectory(DEFAULT_WORK_DIR);
ftpConsumer.registerAdaptrisMessageListener(listener);
// Pass in a QuartzId so we don't print out the uname+password.
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?", "testBasicConsumeWithOverride"));
FileTransferConnection con = createConnection();
con.setDefaultUserName(null);
StandaloneConsumer sc = new StandaloneConsumer(con, ftpConsumer);
start(sc);
int count = 1;
try {
produce(new StandaloneProducer(createConnection(), createFtpProducer()), 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 FtpCase method testConsumeWithNonMatchingFilter.
@Test
public void testConsumeWithNonMatchingFilter() 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.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);
}
}
use of com.adaptris.core.QuartzCronPoller 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);
}
}
}
use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.
the class RelaxedFtpCase method testBasicConsume_WithTrailingSlash.
@Test
public void testBasicConsume_WithTrailingSlash() throws Exception {
if (areTestsEnabled()) {
MockMessageListener listener = new MockMessageListener();
RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
String destination = getDestinationString() + "/";
ftpConsumer.setFtpEndpoint(getDestinationString());
ftpConsumer.registerAdaptrisMessageListener(listener);
ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
start(sc);
int count = 1;
try {
RelaxedFtpProducer producer = createFtpProducer();
producer.setFtpEndpoint(destination);
produce(new StandaloneProducer(createConnection(), producer), count);
waitForMessages(listener, count);
assertMessages(listener.getMessages(), count);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
stop(sc);
}
}
}
Aggregations