DU extends CachingGetSpaceUsed { @VisibleForTesting public DU(File path, long interval, long jitter, long initialUsed) throws IOException { super(path, interval, jitter, initialUsed); this.duShell = new DUShell(); } @VisibleForTesting  DU(File path, long interval, long jitter, long initialUsed);  DU(CachingGetSpaceUsed.Builder builder); static void main(String[] args);  }
@Test public void testDU() throws IOException, InterruptedException { final int writtenSize = 32*1024; final int slack = 4*1024; File file = new File(DU_DIR, "data"); createFile(file, writtenSize); Thread.sleep(5000); DU du = new DU(file, 10000, 0, -1); du.init(); long duSize = du.getUsed(); du.close(); assertTrue("Invalid on-disk size", duSize >= writtenSize && writtenSize <= (duSize + slack)); du = new DU(file, 0, 1, -1); du.init(); duSize = du.getUsed(); du.close(); assertTrue("Invalid on-disk size", duSize >= writtenSize && writtenSize <= (duSize + slack)); du = new DU(file, 10000, 0, -1); du.init(); duSize = du.getUsed(); assertTrue("Invalid on-disk size", duSize >= writtenSize && writtenSize <= (duSize + slack)); }