FtpConsumer extends FtpConsumerImpl { String wipSuffix() { return getWipSuffix() != null ? getWipSuffix() : DEFAULT_WIP_SUFFIX; } FtpConsumer(); @Override void init(); String getProcDirectory(); String getWorkDirectory(); void setProcDirectory(String s); void setWorkDirectory(String s); String getWipSuffix(); void setWipSuffix(String s);  }
@Test public void testWipSuffix() throws Exception { FtpConsumer ftpConsumer = new FtpConsumer(); assertNull(ftpConsumer.getWipSuffix()); assertEquals("_wip", ftpConsumer.wipSuffix()); ftpConsumer.setWipSuffix("ABCDE"); assertEquals("ABCDE", ftpConsumer.getWipSuffix()); assertEquals("ABCDE", ftpConsumer.wipSuffix()); ftpConsumer.setWipSuffix(null); assertNull(ftpConsumer.getWipSuffix()); assertEquals("_wip", ftpConsumer.wipSuffix()); }
@Test public void testConsume_IgnoresWipFiles() throws Exception { int count = 1; EmbeddedFtpServer helper = new EmbeddedFtpServer(); MockMessageListener listener = new MockMessageListener(100); FtpConsumer ftpConsumer = createForTests(listener, "testConsume_IgnoresWipFiles"); FileSystem filesystem = helper.createFilesystem_DirsOnly(); for (int i = 0; i < count; i++) { filesystem.add(new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt", PAYLOAD)); } filesystem.add(new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + "shouldBeIgnored.txt" + ftpConsumer.wipSuffix(), PAYLOAD)); FakeFtpServer server = helper.createAndStart(filesystem); StandaloneConsumer sc = null; try { FtpConnection consumeConnection = create(server); sc = new StandaloneConsumer(consumeConnection, ftpConsumer); start(sc); waitForMessages(listener, count); helper.assertMessages(listener.getMessages(), count); Thread.sleep(2000); assertTrue(filesystem.listFiles(DEFAULT_WORK_DIR_CANONICAL).size() > 0); } catch (Exception e) { throw e; } finally { stop(sc); server.stop(); } }