< prev index next >

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

Print this page

        

*** 29,39 **** import org.testng.annotations.Test; import static org.testng.Assert.*; /* * @test ! * @bug 4358774 * @run testng NullInputStream * @summary Check for expected behavior of InputStream.nullInputStream(). */ public class NullInputStream { private static InputStream openStream; --- 29,39 ---- 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;
*** 105,124 **** fail("Unexpected IOException"); } } @Test(groups = "open") ! public static void testreadNBytes() { try { assertEquals(0, openStream.readNBytes(new byte[1], 0, 1), "readNBytes(byte[],int,int) != 0"); } catch (IOException ioe) { fail("Unexpected IOException"); } } @Test(groups = "open") public static void testSkip() { try { assertEquals(0, openStream.skip(1), "skip() != 0"); } catch (IOException ioe) { fail("Unexpected IOException"); --- 105,144 ---- fail("Unexpected IOException"); } } @Test(groups = "open") ! public static void testReadNBytes() { try { assertEquals(0, openStream.readNBytes(new byte[1], 0, 1), "readNBytes(byte[],int,int) != 0"); } catch (IOException ioe) { fail("Unexpected IOException"); } } @Test(groups = "open") + public static void testReadNBytesWithLength() { + try { + assertEquals(0, openStream.readNBytes(-1).length, + "readNBytes(-1) != 0"); + fail("Expected IllegalArgumentException not thrown"); + } catch (IllegalArgumentException iae) { + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + try { + assertEquals(0, openStream.readNBytes(0).length, + "readNBytes(0, false) != 0"); + assertEquals(0, openStream.readNBytes(1).length, + "readNBytes(1, false) != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") public static void testSkip() { try { assertEquals(0, openStream.skip(1), "skip() != 0"); } catch (IOException ioe) { fail("Unexpected IOException");
*** 179,188 **** --- 199,217 ---- } catch (IOException e) { } } @Test(groups = "closed") + public static void testReadNBytesWithLengthClosed() { + try { + closedStream.readNBytes(1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") public static void testSkipClosed() { try { closedStream.skip(1); fail("Expected IOException not thrown"); } catch (IOException e) {
< prev index next >