Fix some warnings in unit tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808521 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-09-16 08:29:06 +00:00
parent 7c01f5a50c
commit 0297946834
10 changed files with 21 additions and 21 deletions

View File

@ -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");

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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));
}

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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
}
}

View File

@ -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);