]> source.dussan.org Git - poi.git/commitdiff
add test coverage for WorkbookFactory.create(File file, String password, Boolean...
authorJaven O'Neal <onealj@apache.org>
Wed, 6 Apr 2016 05:15:15 +0000 (05:15 +0000)
committerJaven O'Neal <onealj@apache.org>
Wed, 6 Apr 2016 05:15:15 +0000 (05:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737917 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java

index b088359b6982c192dc13dcae32c823874d502da3..4b77e96bef24745a5e420d0f82d3edd4fabe0f79 100644 (file)
@@ -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
+        }
+    }
+
 }