1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
21
21
* questions.
22
22
*/
23
23
24
+ import org .testng .annotations .AfterClass ;
25
+ import org .testng .annotations .BeforeClass ;
26
+ import org .testng .annotations .Test ;
27
+
24
28
import java .io .ByteArrayOutputStream ;
25
29
import java .io .EOFException ;
26
- import java .io .InputStream ;
27
30
import 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
+
31
33
import static org .testng .Assert .*;
32
34
33
35
/*
@@ -40,13 +42,9 @@ public class NullInputStream {
40
42
private static InputStream openStream ;
41
43
private static InputStream closedStream ;
42
44
43
- @ BeforeGroups ( groups = "open" )
44
- public static void openStream () {
45
+ @ BeforeClass
46
+ public static void setup () {
45
47
openStream = InputStream .nullInputStream ();
46
- }
47
-
48
- @ BeforeGroups (groups ="closed" )
49
- public static void openAndCloseStream () {
50
48
closedStream = InputStream .nullInputStream ();
51
49
try {
52
50
closedStream .close ();
@@ -55,7 +53,7 @@ public static void openAndCloseStream() {
55
53
}
56
54
}
57
55
58
- @ AfterGroups ( groups = "open" )
56
+ @ AfterClass
59
57
public static void closeStream () {
60
58
try {
61
59
openStream .close ();
@@ -64,12 +62,12 @@ public static void closeStream() {
64
62
}
65
63
}
66
64
67
- @ Test ( groups = "open" )
65
+ @ Test
68
66
public static void testOpen () {
69
67
assertNotNull (openStream , "InputStream.nullInputStream() returned null" );
70
68
}
71
69
72
- @ Test ( groups = "open" )
70
+ @ Test
73
71
public static void testAvailable () {
74
72
try {
75
73
assertEquals (0 , openStream .available (), "available() != 0" );
@@ -78,7 +76,7 @@ public static void testAvailable() {
78
76
}
79
77
}
80
78
81
- @ Test ( groups = "open" )
79
+ @ Test
82
80
public static void testRead () {
83
81
try {
84
82
assertEquals (-1 , openStream .read (), "read() != -1" );
@@ -87,7 +85,7 @@ public static void testRead() {
87
85
}
88
86
}
89
87
90
- @ Test ( groups = "open" )
88
+ @ Test
91
89
public static void testReadBII () {
92
90
try {
93
91
assertEquals (-1 , openStream .read (new byte [1 ], 0 , 1 ),
@@ -97,7 +95,7 @@ public static void testReadBII() {
97
95
}
98
96
}
99
97
100
- @ Test ( groups = "open" )
98
+ @ Test
101
99
public static void testReadAllBytes () {
102
100
try {
103
101
assertEquals (0 , openStream .readAllBytes ().length ,
@@ -107,7 +105,7 @@ public static void testReadAllBytes() {
107
105
}
108
106
}
109
107
110
- @ Test ( groups = "open" )
108
+ @ Test
111
109
public static void testReadNBytes () {
112
110
try {
113
111
assertEquals (0 , openStream .readNBytes (new byte [1 ], 0 , 1 ),
@@ -117,7 +115,7 @@ public static void testReadNBytes() {
117
115
}
118
116
}
119
117
120
- @ Test ( groups = "open" )
118
+ @ Test
121
119
public static void testReadNBytesWithLength () {
122
120
try {
123
121
assertEquals (0 , openStream .readNBytes (-1 ).length ,
@@ -137,7 +135,7 @@ public static void testReadNBytesWithLength() {
137
135
}
138
136
}
139
137
140
- @ Test ( groups = "open" )
138
+ @ Test
141
139
public static void testSkip () {
142
140
try {
143
141
assertEquals (0 , openStream .skip (1 ), "skip() != 0" );
@@ -146,7 +144,7 @@ public static void testSkip() {
146
144
}
147
145
}
148
146
149
- @ Test ( groups = "open" )
147
+ @ Test
150
148
public static void testSkipNBytes () {
151
149
try {
152
150
openStream .skipNBytes (-1 );
@@ -156,12 +154,12 @@ public static void testSkipNBytes() {
156
154
}
157
155
}
158
156
159
- @ Test (groups = "open" , expectedExceptions = EOFException .class )
157
+ @ Test (expectedExceptions = EOFException .class )
160
158
public static void testSkipNBytesEOF () throws IOException {
161
159
openStream .skipNBytes (1 );
162
160
}
163
161
164
- @ Test ( groups = "open" )
162
+ @ Test
165
163
public static void testTransferTo () {
166
164
try {
167
165
assertEquals (0 , openStream .transferTo (new ByteArrayOutputStream (7 )),
@@ -171,7 +169,7 @@ public static void testTransferTo() {
171
169
}
172
170
}
173
171
174
- @ Test ( groups = "closed" )
172
+ @ Test
175
173
public static void testAvailableClosed () {
176
174
try {
177
175
closedStream .available ();
@@ -180,7 +178,7 @@ public static void testAvailableClosed() {
180
178
}
181
179
}
182
180
183
- @ Test ( groups = "closed" )
181
+ @ Test
184
182
public static void testReadClosed () {
185
183
try {
186
184
closedStream .read ();
@@ -189,7 +187,7 @@ public static void testReadClosed() {
189
187
}
190
188
}
191
189
192
- @ Test ( groups = "closed" )
190
+ @ Test
193
191
public static void testReadBIIClosed () {
194
192
try {
195
193
closedStream .read (new byte [1 ], 0 , 1 );
@@ -198,7 +196,7 @@ public static void testReadBIIClosed() {
198
196
}
199
197
}
200
198
201
- @ Test ( groups = "closed" )
199
+ @ Test
202
200
public static void testReadAllBytesClosed () {
203
201
try {
204
202
closedStream .readAllBytes ();
@@ -207,7 +205,7 @@ public static void testReadAllBytesClosed() {
207
205
}
208
206
}
209
207
210
- @ Test ( groups = "closed" )
208
+ @ Test
211
209
public static void testReadNBytesClosed () {
212
210
try {
213
211
closedStream .readNBytes (new byte [1 ], 0 , 1 );
@@ -216,7 +214,7 @@ public static void testReadNBytesClosed() {
216
214
}
217
215
}
218
216
219
- @ Test ( groups = "closed" )
217
+ @ Test
220
218
public static void testReadNBytesWithLengthClosed () {
221
219
try {
222
220
closedStream .readNBytes (1 );
@@ -225,7 +223,7 @@ public static void testReadNBytesWithLengthClosed() {
225
223
}
226
224
}
227
225
228
- @ Test ( groups = "closed" )
226
+ @ Test
229
227
public static void testSkipClosed () {
230
228
try {
231
229
closedStream .skip (1 );
@@ -234,7 +232,7 @@ public static void testSkipClosed() {
234
232
}
235
233
}
236
234
237
- @ Test ( groups = "closed" )
235
+ @ Test
238
236
public static void testSkipNBytesClosed () {
239
237
try {
240
238
closedStream .skipNBytes (1 );
@@ -243,7 +241,7 @@ public static void testSkipNBytesClosed() {
243
241
}
244
242
}
245
243
246
- @ Test ( groups = "closed" )
244
+ @ Test
247
245
public static void testTransferToClosed () {
248
246
try {
249
247
closedStream .transferTo (new ByteArrayOutputStream (7 ));
0 commit comments