try { FileInputStream fis = new FileInputStream(testFile); assertTrue(fis.available() == testBytes.length);  byte[] resultBytes = new byte[testBytes.length]; assertTrue(fis.read(resultBytes) == testBytes.length);  assertTrue(Arrays.equals(resultBytes, testBytes)); assertTrue(fis.read(resultBytes) == -1);  try { fis.close(); } catch (IOException e) {  } } catch (FileNotFoundException e) { fail("Unexpected FileNotFoundException"); } catch (IOException e) { fail("Unexpected IOException"); }
verifyResultFile(testFile);
    public void testAboveThreshold() {        File testFile = new File("testAboveThreshold.dat");        // Ensure that the test starts from a clean base.        testFile.delete();        DeferredFileOutputStream dfos =                new DeferredFileOutputStream(testBytes.length - 5, testFile);        try        {            dfos.write(testBytes, 0, testBytes.length);            dfos.close();        }        catch (IOException e) {            fail("Unexpected IOException");        }        assertFalse(dfos.isInMemory());        assertNull(dfos.getData());        // Verify that the data is consistent.        try        {            FileInputStream fis = new FileInputStream(testFile);            assertTrue(fis.available() == testBytes.length);            byte[] resultBytes = new byte[testBytes.length];            assertTrue(fis.read(resultBytes) == testBytes.length);            assertTrue(Arrays.equals(resultBytes, testBytes));            assertTrue(fis.read(resultBytes) == -1);            try            {                fis.close();            }            catch (IOException e) {                // Ignore an exception on close            }        }        catch (FileNotFoundException e) {            fail("Unexpected FileNotFoundException");        }        catch (IOException e) {            fail("Unexpected IOException");        }        // Ensure that the test starts from a clean base.        testFile.delete();    }