diff options
author | Nick Burch <nick@apache.org> | 2011-11-28 16:51:06 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2011-11-28 16:51:06 +0000 |
commit | 9532e9c878cc8e11b462c1292ce276482e17afcb (patch) | |
tree | 42bf4c476ae86a64ab331f38dec80e350fa5aeac /src/testcases/org/apache/poi/poifs/filesystem | |
parent | 65fb35e5a035b8ac68c08385c21ae429d946f12f (diff) | |
download | poi-9532e9c878cc8e11b462c1292ce276482e17afcb.tar.gz poi-9532e9c878cc8e11b462c1292ce276482e17afcb.zip |
Add unit test for using FilteringDirectoryNode with EntryUtils.areDirectoriesIdentical
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1207422 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/TestEntryUtils.java | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java b/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java index 8c6712c96e..3cf452acff 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java @@ -20,13 +20,12 @@ package org.apache.poi.poifs.filesystem; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import junit.framework.TestCase; -import org.apache.poi.POIDataSamples; - public class TestEntryUtils extends TestCase { - private static final POIDataSamples dataSamples = POIDataSamples.getPOIFSInstance(); private byte[] dataSmallA = new byte[] { 12, 42, 11, -12, -121 }; private byte[] dataSmallB = new byte[] { 11, 73, 21, -92, -103 }; @@ -160,6 +159,33 @@ public class TestEntryUtils extends TestCase { assertEquals(true, EntryUtils.areDirectoriesIdentical(dirA1, dirB1)); - // TODO Excludes support + // Excludes support + List<String> excl = Arrays.asList(new String[] {"Ignore1", "IgnDir/Ign2"}); + FilteringDirectoryNode fdA = new FilteringDirectoryNode(dirA1, excl); + FilteringDirectoryNode fdB = new FilteringDirectoryNode(dirB1, excl); + + assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB)); + + // Add an ignored doc, no notice is taken + fdA.createDocument("Ignore1", new ByteArrayInputStream(dataSmallA)); + assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB)); + + // Add a directory with filtered contents, not the same + DirectoryEntry dirAI = dirA1.createDirectory("IgnDir"); + assertEquals(false, EntryUtils.areDirectoriesIdentical(fdA, fdB)); + + DirectoryEntry dirBI = dirB1.createDirectory("IgnDir"); + assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB)); + + // Add something to the filtered subdir that gets ignored + dirAI.createDocument("Ign2", new ByteArrayInputStream(dataSmallA)); + assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB)); + + // And something that doesn't + dirAI.createDocument("IgnZZ", new ByteArrayInputStream(dataSmallA)); + assertEquals(false, EntryUtils.areDirectoriesIdentical(fdA, fdB)); + + dirBI.createDocument("IgnZZ", new ByteArrayInputStream(dataSmallA)); + assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB)); } } |