aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcases/org/apache/poi/poifs')
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java22
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java38
2 files changed, 57 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
index b09c469458..fef200fdcb 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
@@ -165,24 +165,40 @@ public final class TestPOIFSDocumentPath extends TestCase {
}
}
- // test weird variants
+ // Test weird variants
+
+ // This one is allowed, even if it's really odd
assertEquals(n, new POIFSDocumentPath(base, null).length());
+ new POIFSDocumentPath(base, new String[]
+ {
+ "fu", ""
+ });
+
+ // This one is allowed too
+ new POIFSDocumentPath(base, new String[]
+ {
+ "", "fu"
+ });
+
+ // This one shouldn't be allowed
try
{
new POIFSDocumentPath(base, new String[]
{
- "fu", ""
+ "fu", null
});
fail("should have caught IllegalArgumentException");
}
catch (IllegalArgumentException ignored)
{
}
+
+ // Ditto
try
{
new POIFSDocumentPath(base, new String[]
{
- "fu", null
+ null, "fu"
});
fail("should have caught IllegalArgumentException");
}
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
index 5ebc168941..ae9ac644a4 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Iterator;
import junit.framework.TestCase;
@@ -226,6 +227,43 @@ public final class TestPOIFSFileSystem extends TestCase {
}
}
}
+
+ /**
+ * Test that we can open files that come via Lotus notes.
+ * These have a top level directory without a name....
+ */
+ public void testNotesOLE2Files() throws Exception {
+ POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
+
+ // Open the file up
+ POIFSFileSystem fs = new POIFSFileSystem(
+ _samples.openResourceAsStream("Notes.ole2")
+ );
+
+ // Check the contents
+ assertEquals(1, fs.getRoot().getEntryCount());
+
+ Entry entry = fs.getRoot().getEntries().next();
+ assertTrue(entry.isDirectoryEntry());
+ assertTrue(entry instanceof DirectoryEntry);
+
+ // The directory lacks a name!
+ DirectoryEntry dir = (DirectoryEntry)entry;
+ assertEquals("", dir.getName());
+
+ // Has two children
+ assertEquals(2, dir.getEntryCount());
+
+ // Check them
+ Iterator<Entry> it = dir.getEntries();
+ entry = it.next();
+ assertEquals(true, entry.isDocumentEntry());
+ assertEquals("\u0001Ole10Native", entry.getName());
+
+ entry = it.next();
+ assertEquals(true, entry.isDocumentEntry());
+ assertEquals("\u0001CompObj", entry.getName());
+ }
private static InputStream openSampleStream(String sampleFileName) {
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);