aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-04-25 21:23:10 +0000
committerNick Burch <nick@apache.org>2014-04-25 21:23:10 +0000
commit2f81141640dc4d1d37dc6ff8ead2c4c281f7938f (patch)
tree5b854bb151ed28d50c5f717aa0af917bbbdce5ed /src/testcases/org/apache/poi/poifs
parent7e3b3b85d926dc5f2bb0c0e1178a5f719b28f19d (diff)
downloadpoi-2f81141640dc4d1d37dc6ff8ead2c4c281f7938f.tar.gz
poi-2f81141640dc4d1d37dc6ff8ead2c4c281f7938f.zip
More progress with the write/read npoifs tests, but one bug still to go....
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1590153 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/poifs')
-rw-r--r--src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java80
1 files changed, 71 insertions, 9 deletions
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
index df3bca587d..104b0600a5 100644
--- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
+++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
@@ -646,10 +646,11 @@ public final class TestNPOIFSFileSystem {
public void readWriteRead() throws Exception {
SummaryInformation sinf = null;
DocumentSummaryInformation dinf = null;
+ DirectoryEntry root = null, testDir = null;
for(NPOIFSFileSystem fs : get512and4kFileAndInput()) {
// Check we can find the entries we expect
- DirectoryNode root = fs.getRoot();
+ root = fs.getRoot();
assertEquals(5, root.getEntryCount());
assertThat(root.getEntryNames(), hasItem("Thumbnail"));
assertThat(root.getEntryNames(), hasItem("Image"));
@@ -678,11 +679,13 @@ public final class TestNPOIFSFileSystem {
dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(
(DocumentEntry)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
- assertEquals(131333, sinf.getOSVersion());
+ assertEquals(131333, dinf.getOSVersion());
// Add a test mini stream
- DirectoryEntry testDir = root.createDirectory("Testing 123");
+ testDir = root.createDirectory("Testing 123");
+ testDir.createDirectory("Testing 456");
+ testDir.createDirectory("Testing 789");
byte[] mini = new byte[] { 42, 0, 1, 2, 3, 4, 42 };
testDir.createDocument("Mini", new ByteArrayInputStream(mini));
@@ -707,26 +710,85 @@ public final class TestNPOIFSFileSystem {
dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(
(DocumentEntry)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
- assertEquals(131333, sinf.getOSVersion());
+ assertEquals(131333, dinf.getOSVersion());
testDir = (DirectoryEntry)root.getEntry("Testing 123");
assertContentsMatches(mini, (DocumentEntry)testDir.getEntry("Mini"));
// Add a full stream, delete a full stream
- // TODO Add check
+ byte[] main4096 = new byte[4096];
+ main4096[0] = -10;
+ main4096[4095] = -11;
+ testDir.createDocument("Normal4096", new ByteArrayInputStream(main4096));
+
+ root.getEntry("Tags").delete();
- // Write out, re-load
- // TODO Add check
+ // Write out, re-load
+ fs = writeOutAndReadBack(fs);
+ }
+ // TODO Fix from here on down
+/*
// Check it's all there
- // TODO Add check
+ assertEquals(5, root.getEntryCount());
+ assertThat(root.getEntryNames(), hasItem("Thumbnail"));
+ assertThat(root.getEntryNames(), hasItem("Image"));
+ assertThat(root.getEntryNames(), hasItem("Testing 123"));
+ assertThat(root.getEntryNames(), hasItem("\u0005DocumentSummaryInformation"));
+ assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation"));
+
+
+ // Check old and new are there
+ sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(
+ (DocumentEntry)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME)));
+ assertEquals(131333, sinf.getOSVersion());
+
+ dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(
+ (DocumentEntry)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
+ assertEquals(131333, dinf.getOSVersion());
+
+ testDir = (DirectoryEntry)root.getEntry("Testing 123");
+ assertContentsMatches(mini, (DocumentEntry)testDir.getEntry("Mini"));
+ assertContentsMatches(main4096, (DocumentEntry)testDir.getEntry("Normal4096"));
- // TODO Something about directories too
+
+ // Delete a directory, and add one more
+ testDir.getEntry("Testing 456").delete();
+ testDir.createDirectory("Testing ABC");
+
+
+ // Save
+ fs = writeOutAndReadBack(fs);
+
+ // Check
+ assertEquals(5, root.getEntryCount());
+ assertThat(root.getEntryNames(), hasItem("Thumbnail"));
+ assertThat(root.getEntryNames(), hasItem("Image"));
+ assertThat(root.getEntryNames(), hasItem("Testing 123"));
+ assertThat(root.getEntryNames(), hasItem("\u0005DocumentSummaryInformation"));
+ assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation"));
+
+ testDir = (DirectoryEntry)root.getEntry("Testing 123");
+ assertEquals(4, testDir.getEntryCount());
+ assertThat(testDir.getEntryNames(), hasItem("Mini"));
+ assertThat(testDir.getEntryNames(), hasItem("Normal4096"));
+ assertThat(testDir.getEntryNames(), hasItem("Testing 789"));
+ assertThat(testDir.getEntryNames(), hasItem("Testing ABC"));
+
+
+ // Another mini stream
+
+ // Save, load, check
+
+ // Delete a mini stream, add one more
+
+ // Save, load, check
// All done
fs.close();
}
+*/
}
/**