use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testSetCreateDirs.
@Test
public void testSetCreateDirs() throws Exception {
String subdir = new GuidGenerator().safeUUID();
try {
FsConsumerImpl fs = createConsumer(subdir);
fs.setCreateDirs(null);
assertNull(fs.getCreateDirs());
assertFalse(fs.shouldCreateDirs());
fs.setCreateDirs(Boolean.TRUE);
assertNotNull(fs.getCreateDirs());
assertEquals(Boolean.TRUE, fs.getCreateDirs());
assertTrue(fs.shouldCreateDirs());
} finally {
FileUtils.deleteQuietly(new File(PROPERTIES.getProperty(BASE_KEY), subdir));
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testFileSorter.
@Test
public void testFileSorter() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsConsumerImpl consumer = createConsumer(subdir);
assertEquals(NoSorting.class, consumer.getFileSorter().getClass());
consumer.setFileSorter(new LastModifiedAscending());
assertEquals(LastModifiedAscending.class, consumer.getFileSorter().getClass());
try {
consumer.setFileSorter(null);
fail();
} catch (Exception expected) {
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class FsConsumerCase method testSetLogAllExceptions.
@Test
public void testSetLogAllExceptions() throws Exception {
String subdir = new GuidGenerator().safeUUID();
try {
FsConsumerImpl fs = createConsumer(subdir);
fs.setLogAllExceptions(null);
assertNull(fs.getLogAllExceptions());
assertTrue(fs.logAllExceptions());
fs.setLogAllExceptions(Boolean.FALSE);
assertNotNull(fs.getLogAllExceptions());
assertEquals(Boolean.FALSE, fs.getLogAllExceptions());
assertFalse(fs.logAllExceptions());
} finally {
FileUtils.deleteQuietly(new File(PROPERTIES.getProperty(BASE_KEY), subdir));
}
}
use of com.adaptris.util.GuidGenerator 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.util.GuidGenerator in project interlok by adaptris.
the class NonDeletingFsConsumerTest method testConsumeWithFilter.
@Test
public void testConsumeWithFilter() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
NonDeletingFsConsumer fs = createConsumer(subDir, "testConsumeWithFilter");
fs.setFilterExpression(".*\\.xml");
fs.setFileFilterImp(Perl5FilenameFilter.class.getName());
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 10;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
LifecycleHelper.init(sc);
createFiles(baseDir, ".xml", count);
createFiles(baseDir, ".tmp", count);
LifecycleHelper.start(sc);
waitForMessages(stub, count);
Perl5FilenameFilter wip = new Perl5FilenameFilter(".*\\.tmp");
assertEquals("TMP Files remain", count, baseDir.listFiles((FilenameFilter) wip).length);
assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
Aggregations