*/
@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");
/**
*
* @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) {
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;
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;
public void testSpecificExampleA() {
double a = 0.06-0.01;
double b = 0.05;
+ //noinspection ConstantConditions
assertFalse(a == b);
assertEquals(0, NumberComparer.compare(a, b));
}
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));
}
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);
IntList list = new IntList();
assertEquals(list, list);
+ //noinspection ObjectEqualsNull
assertTrue(!list.equals(null));
IntList list2 = new IntList(200);
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;
}
try {
i.next();
fail();
- } catch(ArrayIndexOutOfBoundsException e) {}
+ } catch(ArrayIndexOutOfBoundsException e) {
+ // expected here
+ }
i = new StringsIterator(new String[] {"1"});
try {
i.next();
fail();
- } catch(ArrayIndexOutOfBoundsException e) {}
+ } catch(ArrayIndexOutOfBoundsException e) {
+ // expected here
+ }
i = new StringsIterator(new String[] {"1","2","3"});
try {
i.next();
fail();
- } catch(ArrayIndexOutOfBoundsException e) {}
+ } catch(ArrayIndexOutOfBoundsException e) {
+ // expected here
+ }
}
@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);