@Test public void testResetOut() throws IOException { CachedOutputStream cos = new CachedOutputStream(); String result = initTestData(16); cos.write(result.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); cos.resetOut(out, true); String test = out.toString(); assertEquals("The test stream content isn't same ", test, result); cos.close(); }
@Test public void testDeleteTmpFile() throws IOException { CachedOutputStream cos = new CachedOutputStream(); // ensure output data size larger then 64k which will generate tmp file String result = initTestData(65); cos.write(result.getBytes()); // assert tmp file is generated File tempFile = cos.getTempFile(); assertNotNull(tempFile); assertTrue(tempFile.exists()); cos.close(); // assert tmp file is deleted after close the CachedOutputStream assertFalse(tempFile.exists()); }