This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit a7726ff70338bf4ac40b66cc1012cf05a86c367d Author: Sebb <s...@apache.org> AuthorDate: Thu Jul 30 12:43:22 2020 +0100 Suppress some SonarLint warnings --- src/test/java/org/apache/commons/io/IOUtilsTestCase.java | 13 ++++++++++++- .../commons/io/input/CharacterSetFilterReaderTest.java | 1 + src/test/java/org/apache/commons/io/input/TailerTest.java | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java index 4a50246..4dfc9c8 100644 --- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java @@ -137,6 +137,7 @@ public class IOUtilsTestCase { } } + @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 class IOUtilsTestCase { 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 class IOUtilsTestCase { } } + @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 class IOUtilsTestCase { 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 class IOUtilsTestCase { } } + @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 class IOUtilsTestCase { }); } + @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 class IOUtilsTestCase { @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 @@ public class IOUtilsTestCase { 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()); } diff --git a/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java b/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java index dc92449..680021b 100644 --- a/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java @@ -59,6 +59,7 @@ public class CharacterSetFilterReaderTest { codePoints.add(Integer.valueOf('a')); final CharacterSetFilterReader reader = new CharacterSetFilterReader(input, codePoints); assertEquals(-1, reader.read()); + reader.close(); } } diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java index 3755456..3864cd2 100644 --- a/src/test/java/org/apache/commons/io/input/TailerTest.java +++ b/src/test/java/org/apache/commons/io/input/TailerTest.java @@ -69,6 +69,7 @@ public class TailerTest { } @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 class TailerTest { 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 class TailerTest { } @Test + @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case" public void testBufferBreak() throws Exception { final long delay = 50;