test/jdk/java/io/InputStream/NullInputStream.java
changeset 52860 8dd8965df7f6
parent 48696 917868f73209
equal deleted inserted replaced
52859:413c28945e0f 52860:8dd8965df7f6
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 import java.io.ByteArrayOutputStream;
    24 import java.io.ByteArrayOutputStream;
       
    25 import java.io.EOFException;
    25 import java.io.InputStream;
    26 import java.io.InputStream;
    26 import java.io.IOException;
    27 import java.io.IOException;
    27 import org.testng.annotations.AfterGroups;
    28 import org.testng.annotations.AfterGroups;
    28 import org.testng.annotations.BeforeGroups;
    29 import org.testng.annotations.BeforeGroups;
    29 import org.testng.annotations.Test;
    30 import org.testng.annotations.Test;
    30 import static org.testng.Assert.*;
    31 import static org.testng.Assert.*;
    31 
    32 
    32 /*
    33 /*
    33  * @test
    34  * @test
    34  * @bug 4358774 8139206
    35  * @bug 4358774 6516099 8139206
    35  * @run testng NullInputStream
    36  * @run testng NullInputStream
    36  * @summary Check for expected behavior of InputStream.nullInputStream().
    37  * @summary Check for expected behavior of InputStream.nullInputStream().
    37  */
    38  */
    38 public class NullInputStream {
    39 public class NullInputStream {
    39     private static InputStream openStream;
    40     private static InputStream openStream;
   144             fail("Unexpected IOException");
   145             fail("Unexpected IOException");
   145         }
   146         }
   146     }
   147     }
   147 
   148 
   148     @Test(groups = "open")
   149     @Test(groups = "open")
       
   150     public static void testSkipNBytes() {
       
   151         try {
       
   152             openStream.skipNBytes(-1);
       
   153             openStream.skipNBytes(0);
       
   154         } catch (IOException ioe) {
       
   155             fail("Unexpected IOException");
       
   156         }
       
   157     }
       
   158 
       
   159     @Test(groups = "open", expectedExceptions = EOFException.class)
       
   160     public static void testSkipNBytesEOF() throws IOException {
       
   161         openStream.skipNBytes(1);
       
   162     }
       
   163 
       
   164     @Test(groups = "open")
   149     public static void testTransferTo() {
   165     public static void testTransferTo() {
   150         try {
   166         try {
   151             assertEquals(0, openStream.transferTo(new ByteArrayOutputStream(7)),
   167             assertEquals(0, openStream.transferTo(new ByteArrayOutputStream(7)),
   152                 "transferTo() != 0");
   168                 "transferTo() != 0");
   153         } catch (IOException ioe) {
   169         } catch (IOException ioe) {
   217         } catch (IOException e) {
   233         } catch (IOException e) {
   218         }
   234         }
   219     }
   235     }
   220 
   236 
   221     @Test(groups = "closed")
   237     @Test(groups = "closed")
       
   238     public static void testSkipNBytesClosed() {
       
   239         try {
       
   240             closedStream.skipNBytes(1);
       
   241             fail("Expected IOException not thrown");
       
   242         } catch (IOException e) {
       
   243         }
       
   244     }
       
   245 
       
   246     @Test(groups = "closed")
   222     public static void testTransferToClosed() {
   247     public static void testTransferToClosed() {
   223         try {
   248         try {
   224             closedStream.transferTo(new ByteArrayOutputStream(7));
   249             closedStream.transferTo(new ByteArrayOutputStream(7));
   225             fail("Expected IOException not thrown");
   250             fail("Expected IOException not thrown");
   226         } catch (IOException e) {
   251         } catch (IOException e) {