poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1675698 - /poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
Date Thu, 23 Apr 2015 18:20:27 GMT
Author: nick
Date: Thu Apr 23 18:20:27 2015
New Revision: 1675698

URL: http://svn.apache.org/r1675698
Log:
Make the test generic across POIFS and NPOIFS

Modified:
    poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java?rev=1675698&r1=1675697&r2=1675698&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java Thu Apr
23 18:20:27 2015
@@ -34,33 +34,45 @@ public final class TestFileSystemBugs ex
     public void testNotesOLE2Files() throws Exception {
         POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
 
-        // Open the file up
-        POIFSFileSystem fs = new POIFSFileSystem(
-                _samples.openResourceAsStream("Notes.ole2")
-                );
+        // Open the file up with the two FileSystems
+        @SuppressWarnings("resource")
+        DirectoryNode[] roots = new DirectoryNode[] {
+                new POIFSFileSystem(
+                        _samples.openResourceAsStream("Notes.ole2")
+                ).getRoot(),
+                new NPOIFSFileSystem(
+                        _samples.openResourceAsStream("Notes.ole2")
+                ).getRoot()
+        };
 
         // Check the contents
-        assertEquals(1, fs.getRoot().getEntryCount());
+        for (DirectoryNode root : roots) {
+            assertEquals(1, root.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());
+            Entry entry = root.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());
+            
+            // Tidy
+            if (root.getNFileSystem() != null)
+                root.getNFileSystem().close();
+        }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message