< prev index next >

test/jdk/java/io/InputStream/NullInputStream.java

Print this page

        

*** 20,39 **** * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.IOException; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import static org.testng.Assert.*; /* * @test ! * @bug 4358774 8139206 * @run testng NullInputStream * @summary Check for expected behavior of InputStream.nullInputStream(). */ public class NullInputStream { private static InputStream openStream; --- 20,40 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.ByteArrayOutputStream; + import java.io.EOFException; import java.io.InputStream; import java.io.IOException; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import static org.testng.Assert.*; /* * @test ! * @bug 4358774 6516099 8139206 * @run testng NullInputStream * @summary Check for expected behavior of InputStream.nullInputStream(). */ public class NullInputStream { private static InputStream openStream;
*** 144,153 **** --- 145,169 ---- fail("Unexpected IOException"); } } @Test(groups = "open") + public static void testSkipNBytes() { + try { + openStream.skipNBytes(-1); + openStream.skipNBytes(0); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open", expectedExceptions = EOFException.class) + public static void testSkipNBytesEOF() throws IOException { + openStream.skipNBytes(1); + } + + @Test(groups = "open") public static void testTransferTo() { try { assertEquals(0, openStream.transferTo(new ByteArrayOutputStream(7)), "transferTo() != 0"); } catch (IOException ioe) {
*** 217,226 **** --- 233,251 ---- } catch (IOException e) { } } @Test(groups = "closed") + public static void testSkipNBytesClosed() { + try { + closedStream.skipNBytes(1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") public static void testTransferToClosed() { try { closedStream.transferTo(new ByteArrayOutputStream(7)); fail("Expected IOException not thrown"); } catch (IOException e) {
< prev index next >