public void testCloseQuietly_inputStreamWithEatenException() throws IOException { TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[1]), TestOption.CLOSE_THROWS); Closeables.closeQuietly(in); assertTrue(in.closed()); }
public void testClose_closeableWithThrownException() throws IOException { // make sure that the exception is thrown if 'swallowException' is false // when the mock does throw an exception. setupCloseable(true); doClose(mockCloseable, false); }
private void doClose(Closeable closeable, boolean swallowException, boolean expectThrown) throws IOException { try { Closeables.close(closeable, swallowException); if (expectThrown) { fail("Didn't throw exception."); } } catch (IOException e) { if (!expectThrown) { fail("Threw exception"); } } verify(closeable).close(); } }
private void doClose(Closeable closeable, boolean swallowException) throws IOException { doClose(closeable, swallowException, !swallowException); }
private void doClose(Closeable closeable, boolean swallowException) throws IOException { doClose(closeable, swallowException, !swallowException); }
public void testClose_closeableClean() throws IOException { // make sure that no exception is thrown regardless of value of // 'swallowException' when the mock does not throw an exception. setupCloseable(false); doClose(mockCloseable, false, false); setupCloseable(false); doClose(mockCloseable, true, false); }
public void testCloseQuietly_readerWithEatenException() throws IOException { TestReader in = new TestReader(TestOption.CLOSE_THROWS); Closeables.closeQuietly(in); assertTrue(in.closed()); }
private void doClose(Closeable closeable, boolean swallowException, boolean expectThrown) throws IOException { try { Closeables.close(closeable, swallowException); if (expectThrown) { fail("Didn't throw exception."); } } catch (IOException e) { if (!expectThrown) { fail("Threw exception"); } } verify(closeable).close(); } }
public void testClose_closeableWithEatenException() throws IOException { // make sure that no exception is thrown if 'swallowException' is true // when the mock does throw an exception. setupCloseable(true); doClose(mockCloseable, true); }
public void testCloseQuietly_inputStreamWithEatenException() throws IOException { TestInputStream in = new TestInputStream( new ByteArrayInputStream(new byte[1]), TestOption.CLOSE_THROWS); Closeables.closeQuietly(in); assertTrue(in.closed()); }
public void testClose_closeableWithThrownException() throws IOException { // make sure that the exception is thrown if 'swallowException' is false // when the mock does throw an exception. setupCloseable(true); doClose(mockCloseable, false); }
public void testCloseQuietly_readerWithEatenException() throws IOException { TestReader in = new TestReader(TestOption.CLOSE_THROWS); Closeables.closeQuietly(in); assertTrue(in.closed()); }
public void testClose_closeableClean() throws IOException { // make sure that no exception is thrown regardless of value of // 'swallowException' when the mock does not throw an exception. setupCloseable(false); doClose(mockCloseable, false, false); setupCloseable(false); doClose(mockCloseable, true, false); }
public void testClose_closeableWithEatenException() throws IOException { // make sure that no exception is thrown if 'swallowException' is true // when the mock does throw an exception. setupCloseable(true); doClose(mockCloseable, true); }