mirror of https://github.com/apache/poi.git
Pull out a common NPOIFS/POIFS test to a decidated bugs test class
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1675696 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e04afe2fa9
commit
7fc50ed900
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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.RawDataBlockList;
|
|||
|
||||
/**
|
||||
* 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 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);
|
||||
|
|
Loading…
Reference in New Issue