@Override public void setUp() { sink = new TestCharSink(); }
public void testCopyTo_charSink() throws IOException { TestCharSink sink = new TestCharSink(); assertEquals(expected.length(), source.copyTo(sink)); assertExpectedString(sink.getString()); }
public void testClosesOnErrors_whenWriteThrows() { TestCharSink failSink = new TestCharSink(WRITE_THROWS); try { new TestCharSource(STRING).copyTo(failSink); fail(); } catch (IOException expected) { } assertTrue(failSink.wasStreamClosed()); }
public void testClosesOnErrors_copyingToCharSinkThatThrows() { for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) { TestCharSource okSource = new TestCharSource(STRING); try { okSource.copyTo(new TestCharSink(option)); fail(); } catch (IOException expected) { } // ensure reader was closed IF it was opened (depends on implementation whether or not it's // opened at all if sink.newWriter() throws). assertTrue( "stream not closed when copying to sink with option: " + option, !okSource.wasStreamOpened() || okSource.wasStreamClosed()); } }
public void testClosesOnErrors_whenReadThrows() { TestCharSource failSource = new TestCharSource(STRING, READ_THROWS); try { failSource.copyTo(new TestCharSink()); fail(); } catch (IOException expected) { } assertTrue(failSource.wasStreamClosed()); }
public void testClosesOnErrors_copyingFromCharSourceThatThrows() { for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) { TestCharSource failSource = new TestCharSource(STRING, option); TestCharSink okSink = new TestCharSink(); try { failSource.copyTo(okSink); fail(); } catch (IOException expected) { } // ensure writer was closed IF it was opened (depends on implementation whether or not it's // opened at all if source.newReader() throws). assertTrue( "stream not closed when copying from source with option: " + option, !okSink.wasStreamOpened() || okSink.wasStreamClosed()); } }
public void testClosesOnErrors_whenWritingFromReaderThatThrows() { TestCharSink okSink = new TestCharSink(); try { okSink.writeFrom(new TestReader(READ_THROWS)); fail(); } catch (IOException expected) { } assertTrue(okSink.wasStreamClosed()); } }
public void testCopyTo_charSink() throws IOException { TestCharSink sink = new TestCharSink(); assertFalse(sink.wasStreamOpened() || sink.wasStreamClosed()); assertEquals(STRING.length(), source.copyTo(sink)); assertTrue(source.wasStreamOpened() && source.wasStreamClosed()); assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed()); assertEquals(STRING, sink.getString()); }
@Override public void setUp() { sink = new TestCharSink(); }
public void testCopyTo_charSink() throws IOException { TestCharSink sink = new TestCharSink(); assertEquals(expected.length(), source.copyTo(sink)); assertExpectedString(sink.getString()); }
public void testClosesOnErrors_copyingToCharSinkThatThrows() { for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) { TestCharSource okSource = new TestCharSource(STRING); try { okSource.copyTo(new TestCharSink(option)); fail(); } catch (IOException expected) { } // ensure reader was closed IF it was opened (depends on implementation whether or not it's // opened at all if sink.newWriter() throws). assertTrue("stream not closed when copying to sink with option: " + option, !okSource.wasStreamOpened() || okSource.wasStreamClosed()); } }
public void testClosesOnErrors_whenWritingFromReaderThatThrows() { TestCharSink okSink = new TestCharSink(); try { okSink.writeFrom(new TestReader(READ_THROWS)); fail(); } catch (IOException expected) { } assertTrue(okSink.wasStreamClosed()); } }
public void testClosesOnErrors_copyingFromCharSourceThatThrows() { for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) { TestCharSource failSource = new TestCharSource(STRING, option); TestCharSink okSink = new TestCharSink(); try { failSource.copyTo(okSink); fail(); } catch (IOException expected) { } // ensure writer was closed IF it was opened (depends on implementation whether or not it's // opened at all if source.newReader() throws). assertTrue("stream not closed when copying from source with option: " + option, !okSink.wasStreamOpened() || okSink.wasStreamClosed()); } }
public void testClosesOnErrors_whenReadThrows() { TestCharSource failSource = new TestCharSource(STRING, READ_THROWS); try { failSource.copyTo(new TestCharSink()); fail(); } catch (IOException expected) { } assertTrue(failSource.wasStreamClosed()); }
public void testClosesOnErrors_whenWriteThrows() { TestCharSink failSink = new TestCharSink(WRITE_THROWS); try { new TestCharSource(STRING).copyTo(failSink); fail(); } catch (IOException expected) { } assertTrue(failSink.wasStreamClosed()); }
public void testCopyTo_charSink() throws IOException { TestCharSink sink = new TestCharSink(); assertFalse(sink.wasStreamOpened() || sink.wasStreamClosed()); assertEquals(STRING.length(), source.copyTo(sink)); assertTrue(source.wasStreamOpened() && source.wasStreamClosed()); assertTrue(sink.wasStreamOpened() && sink.wasStreamClosed()); assertEquals(STRING, sink.getString()); }