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
- import java .io .InputStream ;
26
29
import 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
+
30
32
import static org .testng .Assert .*;
31
33
32
34
/*
@@ -39,13 +41,9 @@ public class NullInputStream {
39
41
private static InputStream openStream ;
40
42
private static InputStream closedStream ;
41
43
42
- @ BeforeGroups ( groups = "open" )
43
- public static void openStream () {
44
+ @ BeforeClass
45
+ public static void setup () {
44
46
openStream = InputStream .nullInputStream ();
45
- }
46
-
47
- @ BeforeGroups (groups ="closed" )
48
- public static void openAndCloseStream () {
49
47
closedStream = InputStream .nullInputStream ();
50
48
try {
51
49
closedStream .close ();
@@ -54,7 +52,7 @@ public static void openAndCloseStream() {
54
52
}
55
53
}
56
54
57
- @ AfterGroups ( groups = "open" )
55
+ @ AfterClass
58
56
public static void closeStream () {
59
57
try {
60
58
openStream .close ();
@@ -63,12 +61,12 @@ public static void closeStream() {
63
61
}
64
62
}
65
63
66
- @ Test ( groups = "open" )
64
+ @ Test
67
65
public static void testOpen () {
68
66
assertNotNull (openStream , "InputStream.nullInputStream() returned null" );
69
67
}
70
68
71
- @ Test ( groups = "open" )
69
+ @ Test
72
70
public static void testAvailable () {
73
71
try {
74
72
assertEquals (0 , openStream .available (), "available() != 0" );
@@ -77,7 +75,7 @@ public static void testAvailable() {
77
75
}
78
76
}
79
77
80
- @ Test ( groups = "open" )
78
+ @ Test
81
79
public static void testRead () {
82
80
try {
83
81
assertEquals (-1 , openStream .read (), "read() != -1" );
@@ -86,7 +84,7 @@ public static void testRead() {
86
84
}
87
85
}
88
86
89
- @ Test ( groups = "open" )
87
+ @ Test
90
88
public static void testReadBII () {
91
89
try {
92
90
assertEquals (-1 , openStream .read (new byte [1 ], 0 , 1 ),
@@ -96,7 +94,7 @@ public static void testReadBII() {
96
94
}
97
95
}
98
96
99
- @ Test ( groups = "open" )
97
+ @ Test
100
98
public static void testReadAllBytes () {
101
99
try {
102
100
assertEquals (0 , openStream .readAllBytes ().length ,
@@ -106,7 +104,7 @@ public static void testReadAllBytes() {
106
104
}
107
105
}
108
106
109
- @ Test ( groups = "open" )
107
+ @ Test
110
108
public static void testReadNBytes () {
111
109
try {
112
110
assertEquals (0 , openStream .readNBytes (new byte [1 ], 0 , 1 ),
@@ -116,7 +114,7 @@ public static void testReadNBytes() {
116
114
}
117
115
}
118
116
119
- @ Test ( groups = "open" )
117
+ @ Test
120
118
public static void testReadNBytesWithLength () {
121
119
try {
122
120
assertEquals (0 , openStream .readNBytes (-1 ).length ,
@@ -136,7 +134,7 @@ public static void testReadNBytesWithLength() {
136
134
}
137
135
}
138
136
139
- @ Test ( groups = "open" )
137
+ @ Test
140
138
public static void testSkip () {
141
139
try {
142
140
assertEquals (0 , openStream .skip (1 ), "skip() != 0" );
@@ -145,7 +143,7 @@ public static void testSkip() {
145
143
}
146
144
}
147
145
148
- @ Test ( groups = "open" )
146
+ @ Test
149
147
public static void testTransferTo () {
150
148
try {
151
149
assertEquals (0 , openStream .transferTo (new ByteArrayOutputStream (7 )),
@@ -155,7 +153,7 @@ public static void testTransferTo() {
155
153
}
156
154
}
157
155
158
- @ Test ( groups = "closed" )
156
+ @ Test
159
157
public static void testAvailableClosed () {
160
158
try {
161
159
closedStream .available ();
@@ -164,7 +162,7 @@ public static void testAvailableClosed() {
164
162
}
165
163
}
166
164
167
- @ Test ( groups = "closed" )
165
+ @ Test
168
166
public static void testReadClosed () {
169
167
try {
170
168
closedStream .read ();
@@ -173,7 +171,7 @@ public static void testReadClosed() {
173
171
}
174
172
}
175
173
176
- @ Test ( groups = "closed" )
174
+ @ Test
177
175
public static void testReadBIIClosed () {
178
176
try {
179
177
closedStream .read (new byte [1 ], 0 , 1 );
@@ -182,7 +180,7 @@ public static void testReadBIIClosed() {
182
180
}
183
181
}
184
182
185
- @ Test ( groups = "closed" )
183
+ @ Test
186
184
public static void testReadAllBytesClosed () {
187
185
try {
188
186
closedStream .readAllBytes ();
@@ -191,7 +189,7 @@ public static void testReadAllBytesClosed() {
191
189
}
192
190
}
193
191
194
- @ Test ( groups = "closed" )
192
+ @ Test
195
193
public static void testReadNBytesClosed () {
196
194
try {
197
195
closedStream .readNBytes (new byte [1 ], 0 , 1 );
@@ -200,7 +198,7 @@ public static void testReadNBytesClosed() {
200
198
}
201
199
}
202
200
203
- @ Test ( groups = "closed" )
201
+ @ Test
204
202
public static void testReadNBytesWithLengthClosed () {
205
203
try {
206
204
closedStream .readNBytes (1 );
@@ -209,7 +207,7 @@ public static void testReadNBytesWithLengthClosed() {
209
207
}
210
208
}
211
209
212
- @ Test ( groups = "closed" )
210
+ @ Test
213
211
public static void testSkipClosed () {
214
212
try {
215
213
closedStream .skip (1 );
@@ -218,7 +216,7 @@ public static void testSkipClosed() {
218
216
}
219
217
}
220
218
221
- @ Test ( groups = "closed" )
219
+ @ Test
222
220
public static void testTransferToClosed () {
223
221
try {
224
222
closedStream .transferTo (new ByteArrayOutputStream (7 ));
0 commit comments