poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1675696 - in /poi/trunk/src/testcases/org/apache/poi/poifs/filesystem: TestFileSystemBugs.java TestPOIFSFileSystem.java
Date Thu, 23 Apr 2015 18:16:38 GMT
Author: nick
Date: Thu Apr 23 18:16:37 2015
New Revision: 1675696

URL: http://svn.apache.org/r1675696
Log:
Pull out a common NPOIFS/POIFS test to a decidated bugs test class

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

Added: 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=1675696&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java Thu Apr
23 18:16:37 2015
@@ -0,0 +1,66 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.poifs.filesystem;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.POIDataSamples;
+
+/**
+ * Tests bugs across both POIFSFileSystem and NPOIFSFileSystem
+ */
+public final class TestFileSystemBugs 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());
+    }
+}

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java?rev=1675696&r1=1675695&r2=1675696&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java Thu Apr
23 18:16:37 2015
@@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
-import java.util.Iterator;
 
 import junit.framework.TestCase;
 
@@ -37,12 +36,9 @@ import org.apache.poi.poifs.storage.RawD
 
 /**
  * Tests for POIFSFileSystem
- *
- * @author Josh Micich
  */
 public final class TestPOIFSFileSystem extends TestCase {
    private POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
-   
 
 	/**
 	 * Mock exception used to ensure correct error handling
@@ -297,43 +293,6 @@ public final class TestPOIFSFileSystem e
 	      }
 	   }
 	}
-	
-	/**
-	 * 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);



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


Mime
View raw message