use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class FsMessageConsumerTest method testBug2233_ResetWipFilesOnNonExistentDirectory.
@Test
public void testBug2233_ResetWipFilesOnNonExistentDirectory() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setCreateDirs(true);
fs.setResetWipFiles(true);
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
LifecycleHelper.init(sc);
LifecycleHelper.close(sc);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class FsMessageConsumerTest method testConsumeBug3304OversizedFiles.
@Test
public void testConsumeBug3304OversizedFiles() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
if (fs instanceof LargeFsConsumer) {
// The large FS consumer should (by definition) handle large files
return;
}
fs.setReacquireLockBetweenMessages(true);
AtomicBoolean pollFired = new AtomicBoolean(false);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)).withPollerCallback(e -> {
pollFired.set(true);
}));
fs.fsWorker = new SizeLimitedWorker();
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 1;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
LifecycleHelper.init(sc);
File largeFile = File.createTempFile("3304", null, baseDir);
RandomAccessFile raf = new RandomAccessFile(largeFile, "rw");
// Set the size to be 10Mb.
raf.setLength(0x00100000 * 10);
LifecycleHelper.prepare(sc);
LifecycleHelper.start(sc);
waitForPollCallback(pollFired);
assertTrue(stub.getMessages().size() == 0);
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class FsMessageConsumerTest method testBug1675ConsumeWithSpacesInDir.
@Test
public void testBug1675ConsumeWithSpacesInDir() throws Exception {
String uniqueName = new GuidGenerator().safeUUID();
String subDir = uniqueName + "Directory WithSpaces";
String subDirEncoded = uniqueName + "Directory%20WithSpaces";
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDirEncoded);
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);
LifecycleHelper.start(sc);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
} catch (Exception e) {
log.debug(e.getMessage(), e);
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class FsMessageConsumerTest method testBug2100_OriginalNameContainsWip.
@Test
public void testBug2100_OriginalNameContainsWip() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setReacquireLockBetweenMessages(true);
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);
LifecycleHelper.start(sc);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
for (AdaptrisMessage msg : stub.getMessages()) {
assertFalse("original name should not contain '.wip'", msg.getMetadataValue(CoreConstants.ORIGINAL_NAME_KEY).endsWith(".wip"));
}
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class FsMessageConsumerTest method testConsumeIgnoresWip.
@Test
public void testConsumeIgnoresWip() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener();
FsConsumer fs = createConsumer(subDir);
fs.setResetWipFiles(false);
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);
baseDir.mkdirs();
createFiles(baseDir, ".xml", count);
createFiles(baseDir, ".xml.wip", count);
start(sc);
waitForMessages(stub, count);
Perl5FilenameFilter wip = new Perl5FilenameFilter(".*\\.wip");
assertEquals(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