Eclipse warnings, helper unit-test, improve information provided in Exceptions, do not swallow inner stacktraces, ...

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1724486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-01-13 19:45:05 +00:00
parent 11bee1ebf9
commit bd25521857
5 changed files with 15 additions and 10 deletions

View File

@ -114,7 +114,7 @@ public abstract class AbstractFileHandler implements FileHandler {
}
} catch (IllegalArgumentException e) {
if(!EXPECTED_EXTRACTOR_FAILURES.contains(file)) {
throw new Exception("While handling " + file, e);
throw e;
}
} finally {
extractor.close();

View File

@ -19,6 +19,7 @@ package org.apache.poi.stress;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@ -57,4 +58,10 @@ public class HSLFFileHandler extends SlideShowHandler {
stream.close();
}
}
// a test-case to test this locally without executing the full TestAllFiles
@Test
public void testExtractor() throws Exception {
handleExtracting(new File("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx"));
}
}

View File

@ -235,7 +235,7 @@ public class CellFormat {
if (DateUtil.isValidExcelDate(numericValue)) {
return getApplicableFormatPart(numericValue).apply(value);
} else {
throw new IllegalArgumentException("value not a valid Excel date");
throw new IllegalArgumentException("value " + numericValue + " of date " + value + " is not a valid Excel date");
}
} else {
return textFmt.apply(value);

View File

@ -390,8 +390,7 @@ public final class PackagePropertiesPart extends PackagePart implements
try {
this.created = setDateValue(created);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("created : "
+ e.getLocalizedMessage(), e);
throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
}
}
@ -573,7 +572,8 @@ public final class PackagePropertiesPart extends PackagePart implements
d = df.parse(dateTzStr, new ParsePosition(0));
}
if (d == null) {
throw new InvalidFormatException("Date not well formated");
throw new InvalidFormatException("Date " + dateTzStr + " not well formated, "
+ "expected format " + DEFAULT_DATEFORMAT + " or " + ALTERNATIVE_DATEFORMAT);
}
return new Nullable<Date>(d);
}

View File

@ -2586,8 +2586,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
CalculationChain chain = ((XSSFWorkbook)wb).getCalculationChain();
CTCalcCell[] cArray = chain.getCTCalcChain().getCArray();
for(CTCalcCell calc : cArray) {
for(CTCalcCell calc : chain.getCTCalcChain().getCList()) {
// A2 to A6 should be gone
assertFalse(calc.getR().equals("A2"));
assertFalse(calc.getR().equals("A3"));
@ -2601,8 +2600,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertNotNull(sheetBack);
chain = ((XSSFWorkbook)wbBack).getCalculationChain();
cArray = chain.getCTCalcChain().getCArray();
for(CTCalcCell calc : cArray) {
for(CTCalcCell calc : chain.getCTCalcChain().getCList()) {
// A2 to A6 should be gone
assertFalse(calc.getR().equals("A2"));
assertFalse(calc.getR().equals("A3"));