public void testCopyToStream_doesNotCloseThatStream() throws IOException { TestOutputStream out = new TestOutputStream(ByteStreams.nullOutputStream()); assertFalse(out.closed()); source.copyTo(out); assertFalse(out.closed()); }
@Override public void close() throws IOException { outputStreamClosed = true; super.close(); } }
@Override public void close() throws IOException { closed = true; super.close(); throwIf(CLOSE_THROWS); }
public TestWriter(TestOption... options) throws IOException { this(new TestOutputStream(ByteStreams.nullOutputStream(), options)); }
public boolean closed() { return out.closed(); } }
public void testClosesOnErrors_copyingToOutputStreamThatThrows() { TestByteSource okSource = new TestByteSource(bytes); try { OutputStream out = new TestOutputStream(ByteStreams.nullOutputStream(), WRITE_THROWS); okSource.copyTo(out); fail(); } catch (IOException expected) { } assertTrue(okSource.wasStreamClosed()); }
public boolean closed() { return out.closed(); } }
public TestOutputStream(OutputStream out, Iterable<TestOption> options) throws IOException { super(checkNotNull(out)); this.options = ImmutableSet.copyOf(options); throwIf(OPEN_THROWS); }
public void testCopyToStream_doesNotCloseThatStream() throws IOException { TestOutputStream out = new TestOutputStream(ByteStreams.nullOutputStream()); assertFalse(out.closed()); source.copyTo(out); assertFalse(out.closed()); }
public TestWriter(TestOption... options) throws IOException { this(new TestOutputStream(ByteStreams.nullOutputStream(), options)); }
@Override public void close() throws IOException { outputStreamClosed = true; super.close(); } }
private void throwIf(TestOption option) throws IOException { throwIf(options.contains(option)); }
public void testClosesOnErrors_copyingToOutputStreamThatThrows() { TestByteSource okSource = new TestByteSource(bytes); try { OutputStream out = new TestOutputStream(ByteStreams.nullOutputStream(), WRITE_THROWS); okSource.copyTo(out); fail(); } catch (IOException expected) { } assertTrue(okSource.wasStreamClosed()); }
@Override public void close() throws IOException { closed = true; super.close(); throwIf(CLOSE_THROWS); }
private void throwIf(TestOption option) throws IOException { throwIf(options.contains(option)); }
public TestOutputStream(OutputStream out, Iterable<TestOption> options) throws IOException { super(checkNotNull(out)); this.options = ImmutableSet.copyOf(options); throwIf(OPEN_THROWS); }