diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java index ddfc8e2fe4..e0473b2b5a 100644 --- a/src/java/org/apache/poi/util/StringUtil.java +++ b/src/java/org/apache/poi/util/StringUtil.java @@ -27,9 +27,6 @@ import java.util.Map; */ @Internal public class StringUtil { - - private static final POILogger logger = POILogFactory - .getLogger(StringUtil.class); protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); public static final Charset UTF16LE = Charset.forName("UTF-16LE"); public static final Charset UTF8 = Charset.forName("UTF-8"); diff --git a/src/testcases/org/apache/poi/POIDataSamples.java b/src/testcases/org/apache/poi/POIDataSamples.java index f57d13dae0..4b764c2ee3 100644 --- a/src/testcases/org/apache/poi/POIDataSamples.java +++ b/src/testcases/org/apache/poi/POIDataSamples.java @@ -156,7 +156,7 @@ public final class POIDataSamples { /** * * @param sampleFileName the name of the test file - * @return + * @return Verifies that the file with the given name exists in the test-data directory * @throws RuntimeException if the file was not found */ public File getFile(String sampleFileName) { diff --git a/src/testcases/org/apache/poi/POITestCase.java b/src/testcases/org/apache/poi/POITestCase.java index 4aec492a4c..7861030a1f 100644 --- a/src/testcases/org/apache/poi/POITestCase.java +++ b/src/testcases/org/apache/poi/POITestCase.java @@ -19,7 +19,6 @@ package org.apache.poi; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertThat; diff --git a/src/testcases/org/apache/poi/TestPOITestCase.java b/src/testcases/org/apache/poi/TestPOITestCase.java index 4b3155e019..796f51335f 100644 --- a/src/testcases/org/apache/poi/TestPOITestCase.java +++ b/src/testcases/org/apache/poi/TestPOITestCase.java @@ -17,10 +17,6 @@ package org.apache.poi; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.util.Collections; import java.util.Locale; import java.util.Map; diff --git a/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java b/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java index 506df67494..33cf09ad75 100644 --- a/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java +++ b/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java @@ -73,6 +73,7 @@ public final class TestNumberComparer { public void testSpecificExampleA() { double a = 0.06-0.01; double b = 0.05; + //noinspection ConstantConditions assertFalse(a == b); assertEquals(0, NumberComparer.compare(a, b)); } @@ -84,6 +85,7 @@ public final class TestNumberComparer { public void testSpecificExampleB() { double a = 1+1.0028-0.9973; double b = 1.0055; + //noinspection ConstantConditions assertFalse(a == b); assertEquals(0, NumberComparer.compare(a, b)); } diff --git a/src/testcases/org/apache/poi/util/TestHexDump.java b/src/testcases/org/apache/poi/util/TestHexDump.java index a9d55ae619..5611636959 100644 --- a/src/testcases/org/apache/poi/util/TestHexDump.java +++ b/src/testcases/org/apache/poi/util/TestHexDump.java @@ -251,11 +251,8 @@ public class TestHexDump { public void testMain() throws Exception { File file = TempFile.createTempFile("HexDump", ".dat"); try { - FileOutputStream out = new FileOutputStream(file); - try { + try (FileOutputStream out = new FileOutputStream(file)) { IOUtils.copy(new ByteArrayInputStream("teststring".getBytes(LocaleUtil.CHARSET_1252)), out); - } finally { - out.close(); } assertTrue(file.exists()); assertTrue(file.length() > 0); diff --git a/src/testcases/org/apache/poi/util/TestIntList.java b/src/testcases/org/apache/poi/util/TestIntList.java index abf50158bc..092f8af359 100644 --- a/src/testcases/org/apache/poi/util/TestIntList.java +++ b/src/testcases/org/apache/poi/util/TestIntList.java @@ -256,6 +256,7 @@ public final class TestIntList extends TestCase { IntList list = new IntList(); assertEquals(list, list); + //noinspection ObjectEqualsNull assertTrue(!list.equals(null)); IntList list2 = new IntList(200); diff --git a/src/testcases/org/apache/poi/util/TestPOILogger.java b/src/testcases/org/apache/poi/util/TestPOILogger.java index 7a28600173..7f6e6a06e5 100644 --- a/src/testcases/org/apache/poi/util/TestPOILogger.java +++ b/src/testcases/org/apache/poi/util/TestPOILogger.java @@ -42,17 +42,17 @@ public final class TestPOILogger extends POILogger { POILogger log = POILogFactory.getLogger( "foo" ); assertTrue(log instanceof TestPOILogger); - TestPOILogger tlog = (TestPOILogger)log; + TestPOILogger tLog = (TestPOILogger)log; log.log(POILogger.WARN, "Test = ", 1); - assertEquals("Test = 1", tlog.lastLog); + assertEquals("Test = 1", tLog.lastLog); log.log(POILogger.ERROR, "Test ", 1,2,new Exception("bla")); - assertEquals("Test 12", tlog.lastLog); - assertNotNull(tlog.lastEx); + assertEquals("Test 12", tLog.lastLog); + assertNotNull(tLog.lastEx); log.log(POILogger.ERROR, "log\nforging", "\nevil","\nlog"); - assertEquals("log forging evil log", tlog.lastLog); + assertEquals("log forging evil log", tLog.lastLog); } finally { POILogFactory._loggerClassName = oldLCN; } diff --git a/src/testcases/org/apache/poi/util/TestStringUtil.java b/src/testcases/org/apache/poi/util/TestStringUtil.java index 76f934f148..184cf12cf4 100644 --- a/src/testcases/org/apache/poi/util/TestStringUtil.java +++ b/src/testcases/org/apache/poi/util/TestStringUtil.java @@ -137,7 +137,9 @@ public class TestStringUtil { try { i.next(); fail(); - } catch(ArrayIndexOutOfBoundsException e) {} + } catch(ArrayIndexOutOfBoundsException e) { + // expected here + } i = new StringsIterator(new String[] {"1"}); @@ -148,7 +150,9 @@ public class TestStringUtil { try { i.next(); fail(); - } catch(ArrayIndexOutOfBoundsException e) {} + } catch(ArrayIndexOutOfBoundsException e) { + // expected here + } i = new StringsIterator(new String[] {"1","2","3"}); @@ -163,7 +167,9 @@ public class TestStringUtil { try { i.next(); fail(); - } catch(ArrayIndexOutOfBoundsException e) {} + } catch(ArrayIndexOutOfBoundsException e) { + // expected here + } } diff --git a/src/testcases/org/apache/poi/util/TestTempFile.java b/src/testcases/org/apache/poi/util/TestTempFile.java index e893f00c52..8aac52cbb8 100644 --- a/src/testcases/org/apache/poi/util/TestTempFile.java +++ b/src/testcases/org/apache/poi/util/TestTempFile.java @@ -54,10 +54,12 @@ public class TestTempFile { @After public void tearDown() throws IOException { String[] files = tempDir.list(); + assertNotNull(files); // can have the "poifiles" subdir if(files.length == 1) { assertEquals("Had: " + Arrays.toString(files), DefaultTempFileCreationStrategy.POIFILES, files[0]); files = new File(tempDir, files[0]).list(); + assertNotNull(files); assertEquals("Had: " + Arrays.toString(files), 0, files.length); } else { assertEquals("Had: " + Arrays.toString(files), 0, files.length);