From: Javen O'Neal Date: Wed, 6 Apr 2016 05:15:15 +0000 (+0000) Subject: add test coverage for WorkbookFactory.create(File file, String password, Boolean... X-Git-Tag: REL_3_15_BETA2~358 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=277ad927ae291ef5a109d4cd9f64d96f38cb6380;p=poi.git add test coverage for WorkbookFactory.create(File file, String password, Boolean readOnly) when file does not exists git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737917 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java b/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java index b088359b69..4b77e96bef 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java +++ b/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java @@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.FileNotFoundException; import org.apache.poi.EmptyFileException; import org.apache.poi.EncryptedDocumentException; @@ -364,4 +365,21 @@ public final class TestWorkbookFactory { } catch (final EmptyFileException expected) {} emptyFile.delete(); } + + /** + * Check that a helpful exception is raised on a non-existing file + */ + @Test + public void testNonExistantFile() throws Exception { + File nonExistantFile = new File("notExistantFile"); + assertFalse(nonExistantFile.exists()); + + try { + WorkbookFactory.create(nonExistantFile, "password", true); + fail("Should not be able to create for a non-existant file"); + } catch (final FileNotFoundException e) { + // expected + } + } + }