11/*
2- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2121 * questions.
2222 */
2323
24+ import org .testng .annotations .AfterClass ;
25+ import org .testng .annotations .BeforeClass ;
26+ import org .testng .annotations .Test ;
27+
2428import java .io .ByteArrayOutputStream ;
2529import java .io .EOFException ;
26- import java .io .InputStream ;
2730import java .io .IOException ;
28- import org .testng .annotations .AfterGroups ;
29- import org .testng .annotations .BeforeGroups ;
30- import org .testng .annotations .Test ;
31+ import java .io .InputStream ;
32+
3133import static org .testng .Assert .*;
3234
3335/*
@@ -40,13 +42,9 @@ public class NullInputStream {
4042 private static InputStream openStream ;
4143 private static InputStream closedStream ;
4244
43- @ BeforeGroups ( groups = "open" )
44- public static void openStream () {
45+ @ BeforeClass
46+ public static void setup () {
4547 openStream = InputStream .nullInputStream ();
46- }
47-
48- @ BeforeGroups (groups ="closed" )
49- public static void openAndCloseStream () {
5048 closedStream = InputStream .nullInputStream ();
5149 try {
5250 closedStream .close ();
@@ -55,7 +53,7 @@ public static void openAndCloseStream() {
5553 }
5654 }
5755
58- @ AfterGroups ( groups = "open" )
56+ @ AfterClass
5957 public static void closeStream () {
6058 try {
6159 openStream .close ();
@@ -64,12 +62,12 @@ public static void closeStream() {
6462 }
6563 }
6664
67- @ Test ( groups = "open" )
65+ @ Test
6866 public static void testOpen () {
6967 assertNotNull (openStream , "InputStream.nullInputStream() returned null" );
7068 }
7169
72- @ Test ( groups = "open" )
70+ @ Test
7371 public static void testAvailable () {
7472 try {
7573 assertEquals (0 , openStream .available (), "available() != 0" );
@@ -78,7 +76,7 @@ public static void testAvailable() {
7876 }
7977 }
8078
81- @ Test ( groups = "open" )
79+ @ Test
8280 public static void testRead () {
8381 try {
8482 assertEquals (-1 , openStream .read (), "read() != -1" );
@@ -87,7 +85,7 @@ public static void testRead() {
8785 }
8886 }
8987
90- @ Test ( groups = "open" )
88+ @ Test
9189 public static void testReadBII () {
9290 try {
9391 assertEquals (-1 , openStream .read (new byte [1 ], 0 , 1 ),
@@ -97,7 +95,7 @@ public static void testReadBII() {
9795 }
9896 }
9997
100- @ Test ( groups = "open" )
98+ @ Test
10199 public static void testReadAllBytes () {
102100 try {
103101 assertEquals (0 , openStream .readAllBytes ().length ,
@@ -107,7 +105,7 @@ public static void testReadAllBytes() {
107105 }
108106 }
109107
110- @ Test ( groups = "open" )
108+ @ Test
111109 public static void testReadNBytes () {
112110 try {
113111 assertEquals (0 , openStream .readNBytes (new byte [1 ], 0 , 1 ),
@@ -117,7 +115,7 @@ public static void testReadNBytes() {
117115 }
118116 }
119117
120- @ Test ( groups = "open" )
118+ @ Test
121119 public static void testReadNBytesWithLength () {
122120 try {
123121 assertEquals (0 , openStream .readNBytes (-1 ).length ,
@@ -137,7 +135,7 @@ public static void testReadNBytesWithLength() {
137135 }
138136 }
139137
140- @ Test ( groups = "open" )
138+ @ Test
141139 public static void testSkip () {
142140 try {
143141 assertEquals (0 , openStream .skip (1 ), "skip() != 0" );
@@ -146,7 +144,7 @@ public static void testSkip() {
146144 }
147145 }
148146
149- @ Test ( groups = "open" )
147+ @ Test
150148 public static void testSkipNBytes () {
151149 try {
152150 openStream .skipNBytes (-1 );
@@ -156,12 +154,12 @@ public static void testSkipNBytes() {
156154 }
157155 }
158156
159- @ Test (groups = "open" , expectedExceptions = EOFException .class )
157+ @ Test (expectedExceptions = EOFException .class )
160158 public static void testSkipNBytesEOF () throws IOException {
161159 openStream .skipNBytes (1 );
162160 }
163161
164- @ Test ( groups = "open" )
162+ @ Test
165163 public static void testTransferTo () {
166164 try {
167165 assertEquals (0 , openStream .transferTo (new ByteArrayOutputStream (7 )),
@@ -171,7 +169,7 @@ public static void testTransferTo() {
171169 }
172170 }
173171
174- @ Test ( groups = "closed" )
172+ @ Test
175173 public static void testAvailableClosed () {
176174 try {
177175 closedStream .available ();
@@ -180,7 +178,7 @@ public static void testAvailableClosed() {
180178 }
181179 }
182180
183- @ Test ( groups = "closed" )
181+ @ Test
184182 public static void testReadClosed () {
185183 try {
186184 closedStream .read ();
@@ -189,7 +187,7 @@ public static void testReadClosed() {
189187 }
190188 }
191189
192- @ Test ( groups = "closed" )
190+ @ Test
193191 public static void testReadBIIClosed () {
194192 try {
195193 closedStream .read (new byte [1 ], 0 , 1 );
@@ -198,7 +196,7 @@ public static void testReadBIIClosed() {
198196 }
199197 }
200198
201- @ Test ( groups = "closed" )
199+ @ Test
202200 public static void testReadAllBytesClosed () {
203201 try {
204202 closedStream .readAllBytes ();
@@ -207,7 +205,7 @@ public static void testReadAllBytesClosed() {
207205 }
208206 }
209207
210- @ Test ( groups = "closed" )
208+ @ Test
211209 public static void testReadNBytesClosed () {
212210 try {
213211 closedStream .readNBytes (new byte [1 ], 0 , 1 );
@@ -216,7 +214,7 @@ public static void testReadNBytesClosed() {
216214 }
217215 }
218216
219- @ Test ( groups = "closed" )
217+ @ Test
220218 public static void testReadNBytesWithLengthClosed () {
221219 try {
222220 closedStream .readNBytes (1 );
@@ -225,7 +223,7 @@ public static void testReadNBytesWithLengthClosed() {
225223 }
226224 }
227225
228- @ Test ( groups = "closed" )
226+ @ Test
229227 public static void testSkipClosed () {
230228 try {
231229 closedStream .skip (1 );
@@ -234,7 +232,7 @@ public static void testSkipClosed() {
234232 }
235233 }
236234
237- @ Test ( groups = "closed" )
235+ @ Test
238236 public static void testSkipNBytesClosed () {
239237 try {
240238 closedStream .skipNBytes (1 );
@@ -243,7 +241,7 @@ public static void testSkipNBytesClosed() {
243241 }
244242 }
245243
246- @ Test ( groups = "closed" )
244+ @ Test
247245 public static void testTransferToClosed () {
248246 try {
249247 closedStream .transferTo (new ByteArrayOutputStream (7 ));
0 commit comments