Bug 54938: Throw InvalidFormatException as documented instead of IllegalArgumentException in WorkbookFactory.create()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-08-17 20:54:32 +00:00
parent 633eb964b4
commit 0377dbbb3e
2 changed files with 3 additions and 2 deletions

View File

@ -208,7 +208,7 @@ public class WorkbookFactory {
if (POIXMLDocument.hasOOXMLHeader(inp)) {
return new XSSFWorkbook(OPCPackage.open(inp));
}
throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
throw new InvalidFormatException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
}
/**

View File

@ -30,6 +30,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import junit.framework.TestCase;
@ -135,7 +136,7 @@ public final class TestWorkbookFactory extends TestCase {
stream.close();
}
fail();
} catch(IllegalArgumentException e) {
} catch(InvalidFormatException e) {
// Good
}
}