Skip to content

Commit a7726ff

Browse files
committed
Suppress some SonarLint warnings
1 parent b725bb3 commit a7726ff

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/test/java/org/apache/commons/io/IOUtilsTestCase.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,22 @@ public void setUp() {
137137
}
138138
}
139139

140+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
140141
@Test public void testCloseQuietly_AllCloseableIOException() {
141142
final Closeable closeable = () -> {
142143
throw new IOException();
143144
};
144145
IOUtils.closeQuietly(closeable, null, closeable);
145146
}
146147

148+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
147149
@Test public void testCloseQuietly_CloseableIOException() {
148150
IOUtils.closeQuietly((Closeable) () -> {
149151
throw new IOException();
150152
});
151153
}
152154

155+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
153156
@Test public void testCloseQuietly_Selector() {
154157
Selector selector = null;
155158
try {
@@ -160,6 +163,7 @@ public void setUp() {
160163
}
161164
}
162165

166+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
163167
@Test public void testCloseQuietly_SelectorIOException() {
164168
final Selector selector = new SelectorAdapter() {
165169
@Override
@@ -170,11 +174,13 @@ public void close() throws IOException {
170174
IOUtils.closeQuietly(selector);
171175
}
172176

177+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
173178
@Test public void testCloseQuietly_SelectorNull() {
174179
final Selector selector = null;
175180
IOUtils.closeQuietly(selector);
176181
}
177182

183+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
178184
@Test public void testCloseQuietly_SelectorTwice() {
179185
Selector selector = null;
180186
try {
@@ -186,11 +192,13 @@ public void close() throws IOException {
186192
}
187193
}
188194

195+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
189196
@Test public void testCloseQuietly_ServerSocket() throws IOException {
190197
IOUtils.closeQuietly((ServerSocket) null);
191198
IOUtils.closeQuietly(new ServerSocket());
192199
}
193200

201+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
194202
@Test public void testCloseQuietly_ServerSocketIOException() throws IOException {
195203
IOUtils.closeQuietly(new ServerSocket() {
196204
@Override
@@ -200,11 +208,13 @@ public void close() throws IOException {
200208
});
201209
}
202210

211+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
203212
@Test public void testCloseQuietly_Socket() {
204213
IOUtils.closeQuietly((Socket) null);
205214
IOUtils.closeQuietly(new Socket());
206215
}
207216

217+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
208218
@Test public void testCloseQuietly_SocketIOException() {
209219
IOUtils.closeQuietly(new Socket() {
210220
@Override
@@ -230,7 +240,6 @@ public synchronized void close() throws IOException {
230240

231241
@Test public void testContentEquals_InputStream_InputStream() throws Exception {
232242
{
233-
final ByteArrayInputStream input1 = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
234243
assertTrue(IOUtils.contentEquals((InputStream) null, null));
235244
}
236245
{
@@ -1266,10 +1275,12 @@ private void testToString_URL(final String encoding) throws Exception {
12661275
assertTrue(exceptionOccurred);
12671276
}
12681277

1278+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
12691279
@Test public void testResourceToString_NullCharset() throws Exception {
12701280
IOUtils.resourceToString("/test-file-utf8.bin", null);
12711281
}
12721282

1283+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
12731284
@Test public void testResourceToString_NullCharset_WithClassLoader() throws Exception {
12741285
IOUtils.resourceToString("test-file-utf8.bin", null, ClassLoader.getSystemClassLoader());
12751286
}

src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void testInputSize1FilterSize1() throws IOException {
5959
codePoints.add(Integer.valueOf('a'));
6060
final CharacterSetFilterReader reader = new CharacterSetFilterReader(input, codePoints);
6161
assertEquals(-1, reader.read());
62+
reader.close();
6263
}
6364
}
6465

src/test/java/org/apache/commons/io/input/TailerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void tearDown() throws Exception {
6969
}
7070

7171
@Test
72+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
7273
public void testLongFile() throws Exception {
7374
final long delay = 50;
7475

@@ -84,7 +85,7 @@ public void testLongFile() throws Exception {
8485
final TestTailerListener listener = new TestTailerListener();
8586
tailer = new Tailer(file, listener, delay, false);
8687

87-
final long start = System.currentTimeMillis();
88+
// final long start = System.currentTimeMillis();
8889

8990
final Thread thread = new Thread(tailer);
9091
thread.start();
@@ -99,6 +100,7 @@ public void testLongFile() throws Exception {
99100
}
100101

101102
@Test
103+
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
102104
public void testBufferBreak() throws Exception {
103105
final long delay = 50;
104106

0 commit comments

Comments
 (0)