use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class SftpConsumerTest method createConsumerExamples.
private List createConsumerExamples(FileTransferConnection conn, Poller... pollers) {
List<StandaloneConsumer> result = new ArrayList();
try {
for (Poller p : pollers) {
FtpConsumer ftp = new FtpConsumer();
ftp.setProcDirectory("/proc");
ftp.setFtpEndpoint("sftp://overrideuser@hostname:port/path/to/directory");
ftp.setFilterExpression("*.xml");
ftp.setPoller(p);
result.add(new StandaloneConsumer(conn, ftp));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return result;
}
use of com.adaptris.core.StandaloneConsumer 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.StandaloneConsumer 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);
}
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class RelaxedFtpCase method testConsume_OverrideUrl.
@Test
public void testConsume_OverrideUrl() throws Exception {
if (areTestsEnabled()) {
MockMessageListener listener = new MockMessageListener();
RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
ftpConsumer.setFtpEndpoint(getDestinationStringWithOverride());
ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
ftpConsumer.registerAdaptrisMessageListener(listener);
// Pass in a QuartzId so we don't print out the uname+password.
ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?", "testBasicConsumeWithOverride"));
FileTransferConnectionUsingPassword con = createConnection();
con.setDefaultPassword(null);
con.setDefaultUserName(null);
StandaloneConsumer sc = new StandaloneConsumer(con, ftpConsumer);
start(sc);
int count = 1;
try {
produce(new StandaloneProducer(createConnection(), createFtpProducer()), count);
waitForMessages(listener, count);
assertMessages(listener.getMessages(), count);
} finally {
stop(sc);
}
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class RelaxedFtpConsumerTest method setUp.
@Before
public void setUp() throws Exception {
consumer = new RelaxedFtpConsumer();
MockitoAnnotations.initMocks(this);
consumeDestination = "myDestination";
consumer.setFtpEndpoint(consumeDestination);
consumer.registerConnection(mockFtpConnection);
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.SECONDS)));
consumer.setReacquireLockBetweenMessages(true);
messageListener = new MockMessageListener(10);
standaloneConsumer = new StandaloneConsumer(consumer);
standaloneConsumer.registerAdaptrisMessageListener(messageListener);
standaloneConsumer.setConnection(mockFtpConnection);
when(mockFtpConnection.retrieveConnection(FileTransferConnection.class)).thenReturn(mockFtpConnection);
when(mockFtpConnection.connect(consumeDestination)).thenReturn(mockFileTransferClient);
when(mockFtpConnection.getDirectoryRoot(consumeDestination)).thenReturn(DIR_ROOT);
calendarNow = new GregorianCalendar();
calendarOneYearAgo = new GregorianCalendar();
calendarOneYearAgo.add(Calendar.DAY_OF_YEAR, -1);
}
Aggregations