/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ @Override public void close() { out = new ClosedOutputStream(); }
/** * Test the <code>flush()</code> method. * @throws Exception */ @Test public void testFlush() throws Exception { try (ClosedOutputStream cos = new ClosedOutputStream()) { cos.flush(); fail("flush()"); } catch (final IOException e) { // expected } }
/** * Test the <code>write(b)</code> method. * @throws Exception */ @Test public void testRead() throws Exception { try (ClosedOutputStream cos = new ClosedOutputStream()) { cos.write('x'); fail("write(b)"); } catch (final IOException e) { // expected } }
@Test public void testOtherException() throws Exception { final IOException exception = new IOException("test exception"); final OutputStream closed = new ClosedOutputStream(); final TaggedOutputStream stream = new TaggedOutputStream(closed); assertFalse(stream.isCauseOf(exception)); assertFalse(stream.isCauseOf( new TaggedIOException(exception, UUID.randomUUID()))); try { stream.throwIfCauseOf(exception); } catch (final IOException e) { fail("Unexpected exception thrown"); } try { stream.throwIfCauseOf( new TaggedIOException(exception, UUID.randomUUID())); } catch (final IOException e) { fail("Unexpected exception thrown"); } stream.close(); }
/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ public void close() { out = new ClosedOutputStream(); }
/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ @Override public void close() { out = new ClosedOutputStream(); }
/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ @Override public void close() { out = new ClosedOutputStream(); }
/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ public void close() { out = new ClosedOutputStream(); }
/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ @Override public void close() { out = new ClosedOutputStream(); }
/** * Replaces the underlying output stream with a {@link ClosedOutputStream} * sentinel. The original output stream will remain open, but this proxy * will appear closed. */ @Override public void close() { out = new ClosedOutputStream(); }