aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs/filesystem
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2010-12-27 07:53:05 +0000
committerNick Burch <nick@apache.org>2010-12-27 07:53:05 +0000
commitbc8332ccd93af1e5ecb9e25e7e56ee0b65daba25 (patch)
treea3033b696222cadbacd1e48eaaea81eb3a700a58 /src/testcases/org/apache/poi/poifs/filesystem
parent7b9ffe986afc627f4a901bafaa722a0abc32a814 (diff)
downloadpoi-bc8332ccd93af1e5ecb9e25e7e56ee0b65daba25.tar.gz
poi-bc8332ccd93af1e5ecb9e25e7e56ee0b65daba25.zip
Add NPOIFS SBAT tests, and stub out a few future tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1053016 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/poifs/filesystem')
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java71
1 files changed, 69 insertions, 2 deletions
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
index bca205d844..19305fa05b 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
@@ -102,7 +102,21 @@ public final class TestNPOIFSFileSystem extends TestCase {
// Check the SBAT (Small Blocks FAT) was properly processed
- // TODO
+ NPOIFSMiniStore ministore = fs.getMiniStore();
+
+ // Verify we only got two SBAT blocks
+ ministore.getBATBlockAndIndex(0);
+ ministore.getBATBlockAndIndex(128);
+ try {
+ ministore.getBATBlockAndIndex(256);
+ fail("Should only be two SBATs, but a 3rd was found");
+ } catch(IndexOutOfBoundsException e) {}
+
+ // Verify a few offsets: 0->50 is a stream
+ for(int i=0; i<50; i++) {
+ assertEquals(i+1, ministore.getNextBlock(i));
+ }
+ assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
}
// Now with a simple 4096 block file
@@ -153,7 +167,22 @@ public final class TestNPOIFSFileSystem extends TestCase {
// Check the SBAT (Small Blocks FAT) was properly processed
- // TODO
+ NPOIFSMiniStore ministore = fs.getMiniStore();
+
+ // Verify we only got one SBAT block
+ ministore.getBATBlockAndIndex(0);
+ ministore.getBATBlockAndIndex(128);
+ ministore.getBATBlockAndIndex(1023);
+ try {
+ ministore.getBATBlockAndIndex(1024);
+ fail("Should only be one SBAT, but a 2nd was found");
+ } catch(IndexOutOfBoundsException e) {}
+
+ // Verify a few offsets: 0->50 is a stream
+ for(int i=0; i<50; i++) {
+ assertEquals(i+1, ministore.getNextBlock(i));
+ }
+ assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
}
}
@@ -362,4 +391,42 @@ public final class TestNPOIFSFileSystem extends TestCase {
// Ensure it's correct
// TODO
}
+
+ /**
+ * Test that we can correctly get the list of directory
+ * entries, and the details on the files in them
+ */
+ public void testListEntries() throws Exception {
+ NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+ NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+ for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
+ // TODO
+ }
+
+ fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
+ fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
+ for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
+ // TODO
+ }
+ }
+
+ /**
+ * Tests that we can get the correct contents for
+ * a document in the filesystem
+ */
+ public void testGetDocumentEntry() throws Exception {
+ NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+ NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+ for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
+ // TODO
+ }
+
+ fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
+ fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
+ for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
+ // TODO
+ }
+ }
+
+ // TODO Directory/Document write tests
}