Suppress some SonarLint warnings
MODIFY
src/test/java/org/apache/commons/io/IOUtilsTestCase.java
src/test/java/org/apache/commons/io/IOUtilsTestCase.java
@@ -137,6 +137,7 @@ public void setUp() {
}
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_AllCloseableIOException() {
final Closeable closeable = () -> {
throw new IOException();
@@ -144,12 +145,14 @@ public void setUp() {
IOUtils.closeQuietly(closeable, null, closeable);
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_CloseableIOException() {
IOUtils.closeQuietly((Closeable) () -> {
throw new IOException();
});
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_Selector() {
Selector selector = null;
try {
@@ -160,6 +163,7 @@ public void setUp() {
}
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_SelectorIOException() {
final Selector selector = new SelectorAdapter() {
@Override
@@ -170,11 +174,13 @@ public void close() throws IOException {
IOUtils.closeQuietly(selector);
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_SelectorNull() {
final Selector selector = null;
IOUtils.closeQuietly(selector);
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_SelectorTwice() {
Selector selector = null;
try {
@@ -186,11 +192,13 @@ public void close() throws IOException {
}
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_ServerSocket() throws IOException {
IOUtils.closeQuietly((ServerSocket) null);
IOUtils.closeQuietly(new ServerSocket());
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_ServerSocketIOException() throws IOException {
IOUtils.closeQuietly(new ServerSocket() {
@Override
@@ -200,11 +208,13 @@ public void close() throws IOException {
});
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_Socket() {
IOUtils.closeQuietly((Socket) null);
IOUtils.closeQuietly(new Socket());
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testCloseQuietly_SocketIOException() {
IOUtils.closeQuietly(new Socket() {
@Override
@@ -230,7 +240,6 @@ public synchronized void close() throws IOException {
@Test public void testContentEquals_InputStream_InputStream() throws Exception {
{
- final ByteArrayInputStream input1 = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
assertTrue(IOUtils.contentEquals((InputStream) null, null));
}
{
@@ -1266,10 +1275,12 @@ private void testToString_URL(final String encoding) throws Exception {
assertTrue(exceptionOccurred);
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testResourceToString_NullCharset() throws Exception {
IOUtils.resourceToString("/test-file-utf8.bin", null);
}
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
@Test public void testResourceToString_NullCharset_WithClassLoader() throws Exception {
IOUtils.resourceToString("test-file-utf8.bin", null, ClassLoader.getSystemClassLoader());
}

MODIFY
src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java
src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java
@@ -59,6 +59,7 @@ public void testInputSize1FilterSize1() throws IOException {
codePoints.add(Integer.valueOf('a'));
final CharacterSetFilterReader reader = new CharacterSetFilterReader(input, codePoints);
assertEquals(-1, reader.read());
+ reader.close();
}
}

MODIFY
src/test/java/org/apache/commons/io/input/TailerTest.java
src/test/java/org/apache/commons/io/input/TailerTest.java
@@ -69,6 +69,7 @@ public void tearDown() throws Exception {
}
@Test
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
public void testLongFile() throws Exception {
final long delay = 50;
@@ -84,7 +85,7 @@ public void testLongFile() throws Exception {
final TestTailerListener listener = new TestTailerListener();
tailer = new Tailer(file, listener, delay, false);
- final long start = System.currentTimeMillis();
+ // final long start = System.currentTimeMillis();
final Thread thread = new Thread(tailer);
thread.start();
@@ -99,6 +100,7 @@ public void testLongFile() throws Exception {
}
@Test
+ @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
public void testBufferBreak() throws Exception {
final long delay = 50;

Suppress some SonarLint warnings