@Test public void checkStatusFileCorrectlyCreated() { SQLSourceHelper sqlSourceHelper = new SQLSourceHelper(context, "Source Name"); // sqlSourceHelper.setCurrentIndex(10); sqlSourceHelper.updateStatusFile(); File file = new File("/tmp/flume/statusFileName.txt"); assertEquals(true, file.exists()); if (file.exists()) { file.delete(); file.getParentFile().delete(); } }
@Test public void checkStatusFileCorrectlyUpdated() throws Exception { File file = File.createTempFile("statusFileName", ".txt"); when(context.getString("status.file.path", "/var/lib/flume")).thenReturn(file.getParent()); when(context.getString("status.file.name")).thenReturn(file.getName()); SQLSourceHelper sqlSourceHelper = new SQLSourceHelper(context, "Source Name"); sqlSourceHelper.setCurrentIndex(10); sqlSourceHelper.updateStatusFile(); SQLSourceHelper sqlSourceHelper2 = new SQLSourceHelper(context, "Source Name"); assertEquals(10L, sqlSourceHelper2.getCurrentIndex()); }