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 ;
25- import java .io .InputStream ;
2629import java .io .IOException ;
27- import org .testng .annotations .AfterGroups ;
28- import org .testng .annotations .BeforeGroups ;
29- import org .testng .annotations .Test ;
30+ import java .io .InputStream ;
31+
3032import static org .testng .Assert .*;
3133
3234/*
@@ -39,13 +41,9 @@ public class NullInputStream {
3941 private static InputStream openStream ;
4042 private static InputStream closedStream ;
4143
42- @ BeforeGroups ( groups = "open" )
43- public static void openStream () {
44+ @ BeforeClass
45+ public static void setup () {
4446 openStream = InputStream .nullInputStream ();
45- }
46-
47- @ BeforeGroups (groups ="closed" )
48- public static void openAndCloseStream () {
4947 closedStream = InputStream .nullInputStream ();
5048 try {
5149 closedStream .close ();
@@ -54,7 +52,7 @@ public static void openAndCloseStream() {
5452 }
5553 }
5654
57- @ AfterGroups ( groups = "open" )
55+ @ AfterClass
5856 public static void closeStream () {
5957 try {
6058 openStream .close ();
@@ -63,12 +61,12 @@ public static void closeStream() {
6361 }
6462 }
6563
66- @ Test ( groups = "open" )
64+ @ Test
6765 public static void testOpen () {
6866 assertNotNull (openStream , "InputStream.nullInputStream() returned null" );
6967 }
7068
71- @ Test ( groups = "open" )
69+ @ Test
7270 public static void testAvailable () {
7371 try {
7472 assertEquals (0 , openStream .available (), "available() != 0" );
@@ -77,7 +75,7 @@ public static void testAvailable() {
7775 }
7876 }
7977
80- @ Test ( groups = "open" )
78+ @ Test
8179 public static void testRead () {
8280 try {
8381 assertEquals (-1 , openStream .read (), "read() != -1" );
@@ -86,7 +84,7 @@ public static void testRead() {
8684 }
8785 }
8886
89- @ Test ( groups = "open" )
87+ @ Test
9088 public static void testReadBII () {
9189 try {
9290 assertEquals (-1 , openStream .read (new byte [1 ], 0 , 1 ),
@@ -96,7 +94,7 @@ public static void testReadBII() {
9694 }
9795 }
9896
99- @ Test ( groups = "open" )
97+ @ Test
10098 public static void testReadAllBytes () {
10199 try {
102100 assertEquals (0 , openStream .readAllBytes ().length ,
@@ -106,7 +104,7 @@ public static void testReadAllBytes() {
106104 }
107105 }
108106
109- @ Test ( groups = "open" )
107+ @ Test
110108 public static void testReadNBytes () {
111109 try {
112110 assertEquals (0 , openStream .readNBytes (new byte [1 ], 0 , 1 ),
@@ -116,7 +114,7 @@ public static void testReadNBytes() {
116114 }
117115 }
118116
119- @ Test ( groups = "open" )
117+ @ Test
120118 public static void testReadNBytesWithLength () {
121119 try {
122120 assertEquals (0 , openStream .readNBytes (-1 ).length ,
@@ -136,7 +134,7 @@ public static void testReadNBytesWithLength() {
136134 }
137135 }
138136
139- @ Test ( groups = "open" )
137+ @ Test
140138 public static void testSkip () {
141139 try {
142140 assertEquals (0 , openStream .skip (1 ), "skip() != 0" );
@@ -145,7 +143,7 @@ public static void testSkip() {
145143 }
146144 }
147145
148- @ Test ( groups = "open" )
146+ @ Test
149147 public static void testTransferTo () {
150148 try {
151149 assertEquals (0 , openStream .transferTo (new ByteArrayOutputStream (7 )),
@@ -155,7 +153,7 @@ public static void testTransferTo() {
155153 }
156154 }
157155
158- @ Test ( groups = "closed" )
156+ @ Test
159157 public static void testAvailableClosed () {
160158 try {
161159 closedStream .available ();
@@ -164,7 +162,7 @@ public static void testAvailableClosed() {
164162 }
165163 }
166164
167- @ Test ( groups = "closed" )
165+ @ Test
168166 public static void testReadClosed () {
169167 try {
170168 closedStream .read ();
@@ -173,7 +171,7 @@ public static void testReadClosed() {
173171 }
174172 }
175173
176- @ Test ( groups = "closed" )
174+ @ Test
177175 public static void testReadBIIClosed () {
178176 try {
179177 closedStream .read (new byte [1 ], 0 , 1 );
@@ -182,7 +180,7 @@ public static void testReadBIIClosed() {
182180 }
183181 }
184182
185- @ Test ( groups = "closed" )
183+ @ Test
186184 public static void testReadAllBytesClosed () {
187185 try {
188186 closedStream .readAllBytes ();
@@ -191,7 +189,7 @@ public static void testReadAllBytesClosed() {
191189 }
192190 }
193191
194- @ Test ( groups = "closed" )
192+ @ Test
195193 public static void testReadNBytesClosed () {
196194 try {
197195 closedStream .readNBytes (new byte [1 ], 0 , 1 );
@@ -200,7 +198,7 @@ public static void testReadNBytesClosed() {
200198 }
201199 }
202200
203- @ Test ( groups = "closed" )
201+ @ Test
204202 public static void testReadNBytesWithLengthClosed () {
205203 try {
206204 closedStream .readNBytes (1 );
@@ -209,7 +207,7 @@ public static void testReadNBytesWithLengthClosed() {
209207 }
210208 }
211209
212- @ Test ( groups = "closed" )
210+ @ Test
213211 public static void testSkipClosed () {
214212 try {
215213 closedStream .skip (1 );
@@ -218,7 +216,7 @@ public static void testSkipClosed() {
218216 }
219217 }
220218
221- @ Test ( groups = "closed" )
219+ @ Test
222220 public static void testTransferToClosed () {
223221 try {
224222 closedStream .transferTo (new ByteArrayOutputStream (7 ));
0 commit comments