< prev index next >
test/jdk/java/io/InputStream/NullInputStream.java
Print this page
@@ -20,20 +20,21 @@
* 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 8139206
+ * @bug 4358774 6516099 8139206
* @run testng NullInputStream
* @summary Check for expected behavior of InputStream.nullInputStream().
*/
public class NullInputStream {
private static InputStream openStream;
@@ -144,10 +145,25 @@
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,10 +233,19 @@
} 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 >