try {
// create 1 file, with an ingest
createJournalFileFromString(getSimpleIngestString());
// create the JournalConsumer and run it.
JournalConsumer consumer =
new JournalConsumer(parameters, role, server);
startConsumerThread(consumer);
// the file should be processed and we being polling.
waitWhileThreadRuns(WAIT_INTERVAL);
assertEquals("The first file should have been processed.",
1,
delegate.getCallCount());
assertEquals("The first file should have been processed.",
0,
howManyFilesInDirectory(journalDirectory));
assertEquals("The first file should have been processed.",
1,
howManyFilesInDirectory(archiveDirectory));
// create a lock request and wait for the acceptance.
createLockRequest();
waitForLockAccepted();
// create another Journal file, but it won't be processed.
createJournalFileFromString(getSimpleIngestString());
waitWhileThreadRuns(WAIT_INTERVAL);
assertEquals("The second file should not have been processed.",
1,
delegate.getCallCount());
assertEquals("The second file should not have been processed.",
1,
howManyFilesInDirectory(journalDirectory));
assertEquals("The second file should not have been processed.",
1,
howManyFilesInDirectory(archiveDirectory));
int lockMessageIndex = assertLockMessageInLog();
// remove the lock and the file is processed.
removeLockRequest();
waitForLockReleased();
waitWhileThreadRuns(WAIT_INTERVAL);
consumer.shutdown();
assertEquals("Expected to see 2 ingests", 2, delegate
.getCallCount());
assertEquals("Journal files not all gone",
0,