diff options
author | Tim Allison <tallison@apache.org> | 2023-09-20 20:32:59 +0000 |
---|---|---|
committer | Tim Allison <tallison@apache.org> | 2023-09-20 20:32:59 +0000 |
commit | 99117381e59d9a7f2abe27784009358c672c0ae3 (patch) | |
tree | 190b7ef61d91f9579bd7605d1a2c45cf142ea674 /poi/src/test | |
parent | ce919673c4e935e8c756c91938f973d5c9a23ddb (diff) | |
download | poi-99117381e59d9a7f2abe27784009358c672c0ae3.tar.gz poi-99117381e59d9a7f2abe27784009358c672c0ae3.zip |
Bug47950 -- make stream/directory name lookup in OLE2 case insensitive
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912438 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/test')
19 files changed, 186 insertions, 187 deletions
diff --git a/poi/src/test/java/org/apache/poi/hpsf/basic/TestReadAllFiles.java b/poi/src/test/java/org/apache/poi/hpsf/basic/TestReadAllFiles.java index 395aab02cf..cf13fd0474 100644 --- a/poi/src/test/java/org/apache/poi/hpsf/basic/TestReadAllFiles.java +++ b/poi/src/test/java/org/apache/poi/hpsf/basic/TestReadAllFiles.java @@ -154,7 +154,7 @@ class TestReadAllFiles { * If there is a document summry information stream, read it from * the POI filesystem. */ - if (dir.hasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) { + if (dir.hasEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) { final DocumentSummaryInformation dsi = TestWriteWellKnown.getDocumentSummaryInformation(poifs); assertNotNull(dsi); diff --git a/poi/src/test/java/org/apache/poi/hpsf/basic/TestWrite.java b/poi/src/test/java/org/apache/poi/hpsf/basic/TestWrite.java index 48b8b594ec..442bcde58f 100644 --- a/poi/src/test/java/org/apache/poi/hpsf/basic/TestWrite.java +++ b/poi/src/test/java/org/apache/poi/hpsf/basic/TestWrite.java @@ -447,8 +447,8 @@ class TestWrite { DirectoryEntry root = fs.getRoot(); // Read the properties in there - DocumentNode sinfDoc = (DocumentNode) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); - DocumentNode dinfDoc = (DocumentNode) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + DocumentNode sinfDoc = (DocumentNode) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); + DocumentNode dinfDoc = (DocumentNode) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME); InputStream sinfStream = new DocumentInputStream(sinfDoc); SummaryInformation sinf = (SummaryInformation) PropertySetFactory.create(sinfStream); @@ -479,8 +479,8 @@ class TestWrite { // Check it didn't get changed - sinfDoc = (DocumentNode) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); - dinfDoc = (DocumentNode) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + sinfDoc = (DocumentNode) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); + dinfDoc = (DocumentNode) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME); InputStream sinfStream2 = new DocumentInputStream(sinfDoc); sinf = (SummaryInformation) PropertySetFactory.create(sinfStream2); @@ -503,8 +503,8 @@ class TestWrite { DirectoryEntry root = fs.getRoot(); // Read the properties in once more - DocumentNode sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); - DocumentNode dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + DocumentNode sinfDoc = (DocumentNode)root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); + DocumentNode dinfDoc = (DocumentNode)root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME); InputStream sinfStream3 = new DocumentInputStream(sinfDoc); SummaryInformation sinf = (SummaryInformation)PropertySetFactory.create(sinfStream3); @@ -533,8 +533,8 @@ class TestWrite { // Check that the filesystem can give us back the same bytes - sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); - dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + sinfDoc = (DocumentNode)root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); + dinfDoc = (DocumentNode)root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME); InputStream sinfStream4 = new DocumentInputStream(sinfDoc); byte[] sinfData = IOUtils.toByteArray(sinfStream4); @@ -581,13 +581,13 @@ class TestWrite { // Read them back in again - sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); + sinfDoc = (DocumentNode)root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); InputStream sinfStream6 = new DocumentInputStream(sinfDoc); sinf = (SummaryInformation)PropertySetFactory.create(sinfStream6); sinfStream6.close(); assertEquals(131077, sinf.getOSVersion()); - dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + dinfDoc = (DocumentNode)root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME); InputStream dinfStream6 = new DocumentInputStream(dinfDoc); dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream6); dinfStream6.close(); @@ -609,13 +609,13 @@ class TestWrite { DirectoryEntry root = fs.getRoot(); // Re-check on load - DocumentNode sinfDoc = (DocumentNode) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); + DocumentNode sinfDoc = (DocumentNode) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); InputStream sinfStream7 = new DocumentInputStream(sinfDoc); SummaryInformation sinf = (SummaryInformation) PropertySetFactory.create(sinfStream7); sinfStream7.close(); assertEquals(131077, sinf.getOSVersion()); - DocumentNode dinfDoc = (DocumentNode) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + DocumentNode dinfDoc = (DocumentNode) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME); InputStream dinfStream7 = new DocumentInputStream(dinfDoc); DocumentSummaryInformation dinf = (DocumentSummaryInformation) PropertySetFactory.create(dinfStream7); dinfStream7.close(); diff --git a/poi/src/test/java/org/apache/poi/hpsf/basic/TestWriteWellKnown.java b/poi/src/test/java/org/apache/poi/hpsf/basic/TestWriteWellKnown.java index 06cf09cf3f..7a296522c7 100644 --- a/poi/src/test/java/org/apache/poi/hpsf/basic/TestWriteWellKnown.java +++ b/poi/src/test/java/org/apache/poi/hpsf/basic/TestWriteWellKnown.java @@ -494,7 +494,7 @@ class TestWriteWellKnown { static DocumentSummaryInformation getDocumentSummaryInformation(POIFSFileSystem poifs) throws IOException, NoPropertySetStreamException, UnexpectedPropertySetTypeException { - if (!poifs.getRoot().hasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) { + if (!poifs.getRoot().hasEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) { return null; } diff --git a/poi/src/test/java/org/apache/poi/hssf/extractor/TestExcelExtractor.java b/poi/src/test/java/org/apache/poi/hssf/extractor/TestExcelExtractor.java index 497bd20843..495ceb9837 100644 --- a/poi/src/test/java/org/apache/poi/hssf/extractor/TestExcelExtractor.java +++ b/poi/src/test/java/org/apache/poi/hssf/extractor/TestExcelExtractor.java @@ -252,9 +252,9 @@ final class TestExcelExtractor { try { fs = new POIFSFileSystem(POIDataSamples.getDocumentInstance().getFile("word_with_embeded.doc")); - DirectoryNode objPool = (DirectoryNode) fs.getRoot().getEntry("ObjectPool"); - DirectoryNode dirA = (DirectoryNode) objPool.getEntry("_1269427460"); - DirectoryNode dirB = (DirectoryNode) objPool.getEntry("_1269427461"); + DirectoryNode objPool = (DirectoryNode) fs.getRoot().getEntryCaseInsensitive("ObjectPool"); + DirectoryNode dirA = (DirectoryNode) objPool.getEntryCaseInsensitive("_1269427460"); + DirectoryNode dirB = (DirectoryNode) objPool.getEntryCaseInsensitive("_1269427461"); wbA = new HSSFWorkbook(dirA, fs, true); exA = new ExcelExtractor(wbA); @@ -287,8 +287,8 @@ final class TestExcelExtractor { try { fs = new POIFSFileSystem(ssSamples.getFile("excel_with_embeded.xls")); - DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B5"); - DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B4"); + DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntryCaseInsensitive("MBD0000A3B5"); + DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntryCaseInsensitive("MBD0000A3B4"); wbA = new HSSFWorkbook(dirA, fs, true); wbB = new HSSFWorkbook(dirB, fs, true); diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java index b836e3269c..b9d5fcb3ca 100644 --- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2451,7 +2451,7 @@ final class TestBugs extends BaseTestBugzillaIssues { try (POIFSFileSystem poifs = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls"))) { DocumentEntry entry = - (DocumentEntry) poifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME); + (DocumentEntry) poifs.getRoot().getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME); RuntimeException ex = assertThrows( RuntimeException.class, diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index eb87441cd3..94f3c4fa78 100644 --- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -644,7 +644,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { DirectoryEntry dir = embeddedObject.getDirectory(); if (dir instanceof DirectoryNode) { DirectoryNode dNode = (DirectoryNode) dir; - if (dNode.hasEntry("WordDocument")) { + if (dNode.hasEntryCaseInsensitive("WordDocument")) { found = true; break; } diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java index 3434d7b581..e44195afcd 100644 --- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java +++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java @@ -121,14 +121,13 @@ final class TestNonStandardWorkbookStreamNames { wb.close(); DirectoryNode root = wb2.getDirectory(); - // Check that we have the new entries assertTrue(root.hasEntry("Workbook")); assertFalse(root.hasEntry("BOOK")); assertFalse(root.hasEntry("WORKBOOK")); // As we preserved, should also have a few other streams - assertTrue(root.hasEntry(SummaryInformation.DEFAULT_STREAM_NAME)); + assertTrue(root.hasEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME)); wb2.close(); } } diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java index 2bc2da0a1c..4faf164731 100644 --- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java +++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java @@ -89,7 +89,7 @@ class TestPOIFSProperties { summary1.setTitle(title); //write the modified property back to POIFS - fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete(); + fs.getRoot().getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME).delete(); fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME); // check that the information was added successfully to the filesystem object diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/ReaderWriter.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/ReaderWriter.java index 195682ae75..0c57856df0 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/ReaderWriter.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/ReaderWriter.java @@ -106,7 +106,7 @@ public final class ReaderWriter implements POIFSReaderListener, POIFSWriterListe try { - nextEntry = entry.getEntry(componentName); + nextEntry = entry.getEntryCaseInsensitive(componentName); } catch (FileNotFoundException ignored) { diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDirectoryNode.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDirectoryNode.java index 1a81dc5a58..15342a245d 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDirectoryNode.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDirectoryNode.java @@ -73,7 +73,7 @@ final class TestDirectoryNode { assertEquals(0, node.getEntryCount()); // verify behavior of getEntry - assertThrows(FileNotFoundException.class, () -> node.getEntry("foo")); + assertThrows(FileNotFoundException.class, () -> node.getEntryCaseInsensitive("foo")); // verify behavior of isDirectoryEntry assertTrue(node.isDirectoryEntry()); @@ -124,11 +124,11 @@ final class TestDirectoryNode { assertEquals(2, node.getEntryCount()); // verify behavior of getEntry - DirectoryNode child1 = (DirectoryNode) node.getEntry("child1"); + DirectoryNode child1 = (DirectoryNode) node.getEntryCaseInsensitive("child1"); - child1.getEntry("child3"); - node.getEntry("child2"); - assertThrows(FileNotFoundException.class, () -> node.getEntry("child3")); + child1.getEntryCaseInsensitive("child3"); + node.getEntryCaseInsensitive("child2"); + assertThrows(FileNotFoundException.class, () -> node.getEntryCaseInsensitive("child3")); // verify behavior of isDirectoryEntry assertTrue(node.isDirectoryEntry()); diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocument.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocument.java index 94bc700be3..59c6d168ba 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocument.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocument.java @@ -101,8 +101,8 @@ class TestDocument { POIFSFileSystem poifs = document.getFileSystem(); String name = "test" + input.length; DirectoryNode root = poifs.getRoot(); - if (root.hasEntry(name)) { - root.deleteEntry((EntryNode)root.getEntry(name)); + if (root.hasEntryCaseInsensitive(name)) { + root.deleteEntry((EntryNode)root.getEntryCaseInsensitive(name)); } return ((DocumentNode)root .createDocument(name, new ByteArrayInputStream(input))) diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java index c0d4de1353..c083a2c3e4 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java @@ -381,22 +381,22 @@ final class TestDocumentInputStream { // Check inside DirectoryNode root = poifs.getRoot(); // Top Level - Entry top = root.getEntry("Contents"); + Entry top = root.getEntryCaseInsensitive("Contents"); assertTrue(top.isDocumentEntry()); stream = root.createDocumentInputStream(top); assertNotEquals(-1, stream.read()); // One Level Down - DirectoryNode escher = (DirectoryNode) root.getEntry("Escher"); - Entry one = escher.getEntry("EscherStm"); + DirectoryNode escher = (DirectoryNode) root.getEntryCaseInsensitive("Escher"); + Entry one = escher.getEntryCaseInsensitive("EscherStm"); assertTrue(one.isDocumentEntry()); stream = escher.createDocumentInputStream(one); assertNotEquals(-1, stream.read()); // Two Levels Down - DirectoryNode quill = (DirectoryNode) root.getEntry("Quill"); - DirectoryNode quillSub = (DirectoryNode) quill.getEntry("QuillSub"); - Entry two = quillSub.getEntry("CONTENTS"); + DirectoryNode quill = (DirectoryNode) root.getEntryCaseInsensitive("Quill"); + DirectoryNode quillSub = (DirectoryNode) quill.getEntryCaseInsensitive("QuillSub"); + Entry two = quillSub.getEntryCaseInsensitive("CONTENTS"); assertTrue(two.isDocumentEntry()); stream = quillSub.createDocumentInputStream(two); assertNotEquals(-1, stream.read()); diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEmptyDocument.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEmptyDocument.java index f60ce5bc3b..9507b13a7d 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEmptyDocument.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEmptyDocument.java @@ -101,13 +101,13 @@ final class TestEmptyDocument { // This line caused the error. try (POIFSFileSystem fs = new POIFSFileSystem(out.toInputStream())) { - DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntry("Empty"); + DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Empty"); assertEquals(0, entry.getSize(), "Expected zero size"); byte[] actualReadbackData; actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry)); assertEquals(0, actualReadbackData.length, "Expected zero read from stream"); - entry = (DocumentEntry) fs.getRoot().getEntry("NotEmpty"); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("NotEmpty"); actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry)); assertEquals(testData.length, entry.getSize(), "Expected size was wrong"); assertArrayEquals(testData, actualReadbackData, "Expected same data read from stream"); diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEntryUtils.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEntryUtils.java index 16fa1fd240..9dfec6f276 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEntryUtils.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestEntryUtils.java @@ -53,18 +53,18 @@ class TestEntryUtils { EntryUtils.copyNodeRecursively(entryR, fsD.getRoot()); assertEquals(1, fsD.getRoot().getEntryCount()); - assertNotNull(fsD.getRoot().getEntry("EntryRoot")); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("EntryRoot")); EntryUtils.copyNodeRecursively(entryA1, fsD.getRoot()); assertEquals(2, fsD.getRoot().getEntryCount()); - assertNotNull(fsD.getRoot().getEntry("EntryRoot")); - assertNotNull(fsD.getRoot().getEntry("EntryA1")); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("EntryRoot")); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("EntryA1")); EntryUtils.copyNodeRecursively(entryA2, fsD.getRoot()); assertEquals(3, fsD.getRoot().getEntryCount()); - assertNotNull(fsD.getRoot().getEntry("EntryRoot")); - assertNotNull(fsD.getRoot().getEntry("EntryA1")); - assertNotNull(fsD.getRoot().getEntry("EntryA2")); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("EntryRoot")); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("EntryA1")); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("EntryA2")); fsD.close(); @@ -74,15 +74,15 @@ class TestEntryUtils { EntryUtils.copyNodeRecursively(dirB, fsD.getRoot()); assertEquals(1, fsD.getRoot().getEntryCount()); - assertNotNull(fsD.getRoot().getEntry("DirB")); - assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntry("DirB")).getEntryCount()); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("DirB")); + assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntryCaseInsensitive("DirB")).getEntryCount()); EntryUtils.copyNodeRecursively(dirA, fsD.getRoot()); assertEquals(2, fsD.getRoot().getEntryCount()); - assertNotNull(fsD.getRoot().getEntry("DirB")); - assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntry("DirB")).getEntryCount()); - assertNotNull(fsD.getRoot().getEntry("DirA")); - assertEquals(2, ((DirectoryEntry)fsD.getRoot().getEntry("DirA")).getEntryCount()); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("DirB")); + assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntryCaseInsensitive("DirB")).getEntryCount()); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive("DirA")); + assertEquals(2, ((DirectoryEntry)fsD.getRoot().getEntryCaseInsensitive("DirA")).getEntryCount()); fsD.close(); // Copy the whole lot @@ -91,11 +91,11 @@ class TestEntryUtils { EntryUtils.copyNodes(fs, fsD, new ArrayList<>()); assertEquals(3, fsD.getRoot().getEntryCount()); - assertNotNull(fsD.getRoot().getEntry(dirA.getName())); - assertNotNull(fsD.getRoot().getEntry(dirB.getName())); - assertNotNull(fsD.getRoot().getEntry(entryR.getName())); - assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntry("DirB")).getEntryCount()); - assertEquals(2, ((DirectoryEntry)fsD.getRoot().getEntry("DirA")).getEntryCount()); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive(dirA.getName())); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive(dirB.getName())); + assertNotNull(fsD.getRoot().getEntryCaseInsensitive(entryR.getName())); + assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntryCaseInsensitive("DirB")).getEntryCount()); + assertEquals(2, ((DirectoryEntry)fsD.getRoot().getEntryCaseInsensitive("DirA")).getEntryCount()); fsD.close(); fs.close(); } @@ -131,11 +131,11 @@ class TestEntryUtils { try (InputStream tmpI = tmpO.toInputStream(); POIFSFileSystem nfs = new POIFSFileSystem(tmpI)) { - DirectoryEntry dN1 = (DirectoryEntry) nfs.getRoot().getEntry("DirA"); - DirectoryEntry dN2 = (DirectoryEntry) nfs.getRoot().getEntry("DirB"); - DocumentEntry eNA1 = (DocumentEntry) dN1.getEntry(entryA1.getName()); - DocumentEntry eNA2 = (DocumentEntry) dN1.getEntry(entryA2.getName()); - DocumentEntry eNB1 = (DocumentEntry) dN2.getEntry(entryB1.getName()); + DirectoryEntry dN1 = (DirectoryEntry) nfs.getRoot().getEntryCaseInsensitive("DirA"); + DirectoryEntry dN2 = (DirectoryEntry) nfs.getRoot().getEntryCaseInsensitive("DirB"); + DocumentEntry eNA1 = (DocumentEntry) dN1.getEntryCaseInsensitive(entryA1.getName()); + DocumentEntry eNA2 = (DocumentEntry) dN1.getEntryCaseInsensitive(entryA2.getName()); + DocumentEntry eNB1 = (DocumentEntry) dN2.getEntryCaseInsensitive(entryB1.getName()); assertFalse(EntryUtils.areDocumentsIdentical(eNA1, eNA2)); assertTrue(EntryUtils.areDocumentsIdentical(eNA1, eNB1)); diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java index ae28e00d36..39bbfa2a40 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java @@ -63,16 +63,16 @@ final class TestFilteringDirectoryNode { void testNoFiltering() throws Exception { FilteringDirectoryNode d = new FilteringDirectoryNode(fs.getRoot(), new HashSet<>()); assertEquals(3, d.getEntryCount()); - assertEquals(dirA.getName(), d.getEntry(dirA.getName()).getName()); + assertEquals(dirA.getName(), d.getEntryCaseInsensitive(dirA.getName()).getName()); - assertTrue(d.getEntry(dirA.getName()).isDirectoryEntry()); - assertFalse(d.getEntry(dirA.getName()).isDocumentEntry()); + assertTrue(d.getEntryCaseInsensitive(dirA.getName()).isDirectoryEntry()); + assertFalse(d.getEntryCaseInsensitive(dirA.getName()).isDocumentEntry()); - assertTrue(d.getEntry(dirB.getName()).isDirectoryEntry()); - assertFalse(d.getEntry(dirB.getName()).isDocumentEntry()); + assertTrue(d.getEntryCaseInsensitive(dirB.getName()).isDirectoryEntry()); + assertFalse(d.getEntryCaseInsensitive(dirB.getName()).isDocumentEntry()); - assertFalse(d.getEntry(eRoot.getName()).isDirectoryEntry()); - assertTrue(d.getEntry(eRoot.getName()).isDocumentEntry()); + assertFalse(d.getEntryCaseInsensitive(eRoot.getName()).isDirectoryEntry()); + assertTrue(d.getEntryCaseInsensitive(eRoot.getName()).isDocumentEntry()); Iterator<Entry> i = d.getEntries(); assertEquals(dirA, i.next()); @@ -93,13 +93,13 @@ final class TestFilteringDirectoryNode { FilteringDirectoryNode d1 = new FilteringDirectoryNode(fs.getRoot(), excl); assertEquals(2, d1.getEntryCount()); - assertTrue(d1.hasEntry(dirA.getName())); - assertTrue(d1.hasEntry(dirB.getName())); - assertFalse(d1.hasEntry(eRoot.getName())); + assertTrue(d1.hasEntryCaseInsensitive(dirA.getName())); + assertTrue(d1.hasEntryCaseInsensitive(dirB.getName())); + assertFalse(d1.hasEntryCaseInsensitive(eRoot.getName())); - assertEquals(dirA, d1.getEntry(dirA.getName())); - assertEquals(dirB, d1.getEntry(dirB.getName())); - assertThrows(FileNotFoundException.class, () -> d1.getEntry(eRoot.getName())); + assertEquals(dirA, d1.getEntryCaseInsensitive(dirA.getName())); + assertEquals(dirB, d1.getEntryCaseInsensitive(dirB.getName())); + assertThrows(FileNotFoundException.class, () -> d1.getEntryCaseInsensitive(eRoot.getName())); Iterator<Entry> i = d1.getEntries(); assertEquals(dirA, i.next()); @@ -117,12 +117,12 @@ final class TestFilteringDirectoryNode { FilteringDirectoryNode d2 = new FilteringDirectoryNode(fs.getRoot(), excl); assertEquals(1, d2.getEntryCount()); - assertFalse(d2.hasEntry(dirA.getName())); - assertTrue(d2.hasEntry(dirB.getName())); - assertFalse(d2.hasEntry(eRoot.getName())); - assertThrows(FileNotFoundException.class, () -> d2.getEntry(dirA.getName()), "Should be filtered"); - assertEquals(dirB, d2.getEntry(dirB.getName())); - assertThrows(FileNotFoundException.class, () -> d2.getEntry(eRoot.getName()), "Should be filtered"); + assertFalse(d2.hasEntryCaseInsensitive(dirA.getName())); + assertTrue(d2.hasEntryCaseInsensitive(dirB.getName())); + assertFalse(d2.hasEntryCaseInsensitive(eRoot.getName())); + assertThrows(FileNotFoundException.class, () -> d2.getEntryCaseInsensitive(dirA.getName()), "Should be filtered"); + assertEquals(dirB, d2.getEntryCaseInsensitive(dirB.getName())); + assertThrows(FileNotFoundException.class, () -> d2.getEntryCaseInsensitive(eRoot.getName()), "Should be filtered"); i = d2.getEntries(); assertEquals(dirB, i.next()); @@ -137,12 +137,12 @@ final class TestFilteringDirectoryNode { FilteringDirectoryNode d3 = new FilteringDirectoryNode(fs.getRoot(), excl); assertEquals(0, d3.getEntryCount()); - assertFalse(d3.hasEntry(dirA.getName())); - assertFalse(d3.hasEntry(dirB.getName())); - assertFalse(d3.hasEntry(eRoot.getName())); - assertThrows(FileNotFoundException.class, () -> d3.getEntry(dirA.getName()), "Should be filtered"); - assertThrows(FileNotFoundException.class, () -> d3.getEntry(dirB.getName()), "Should be filtered"); - assertThrows(FileNotFoundException.class, () -> d3.getEntry(eRoot.getName()), "Should be filtered"); + assertFalse(d3.hasEntryCaseInsensitive(dirA.getName())); + assertFalse(d3.hasEntryCaseInsensitive(dirB.getName())); + assertFalse(d3.hasEntryCaseInsensitive(eRoot.getName())); + assertThrows(FileNotFoundException.class, () -> d3.getEntryCaseInsensitive(dirA.getName()), "Should be filtered"); + assertThrows(FileNotFoundException.class, () -> d3.getEntryCaseInsensitive(dirB.getName()), "Should be filtered"); + assertThrows(FileNotFoundException.class, () -> d3.getEntryCaseInsensitive(eRoot.getName()), "Should be filtered"); i = d3.getEntries(); assertThrows(NoSuchElementException.class, i::next, "Should throw NoSuchElementException when depleted"); @@ -161,24 +161,24 @@ final class TestFilteringDirectoryNode { // Check main assertEquals(2, d.getEntryCount()); - assertTrue(d.hasEntry(dirA.getName())); - assertTrue(d.hasEntry(dirB.getName())); - assertFalse(d.hasEntry(eRoot.getName())); + assertTrue(d.hasEntryCaseInsensitive(dirA.getName())); + assertTrue(d.hasEntryCaseInsensitive(dirB.getName())); + assertFalse(d.hasEntryCaseInsensitive(eRoot.getName())); // Check filtering down - assertTrue(d.getEntry(dirA.getName()) instanceof FilteringDirectoryNode); - assertFalse(d.getEntry(dirB.getName()) instanceof FilteringDirectoryNode); + assertTrue(d.getEntryCaseInsensitive(dirA.getName()) instanceof FilteringDirectoryNode); + assertFalse(d.getEntryCaseInsensitive(dirB.getName()) instanceof FilteringDirectoryNode); - DirectoryEntry fdA = (DirectoryEntry) d.getEntry(dirA.getName()); - assertFalse(fdA.hasEntry(eA.getName())); - assertTrue(fdA.hasEntry(dirAA.getName())); + DirectoryEntry fdA = (DirectoryEntry) d.getEntryCaseInsensitive(dirA.getName()); + assertFalse(fdA.hasEntryCaseInsensitive(eA.getName())); + assertTrue(fdA.hasEntryCaseInsensitive(dirAA.getName())); - DirectoryEntry fdAA = (DirectoryEntry) fdA.getEntry(dirAA.getName()); - assertTrue(fdAA.hasEntry(eAA.getName())); + DirectoryEntry fdAA = (DirectoryEntry) fdA.getEntryCaseInsensitive(dirAA.getName()); + assertTrue(fdAA.hasEntryCaseInsensitive(eAA.getName())); } @Test void testNullDirectory() { assertThrows(IllegalArgumentException.class, () -> new FilteringDirectoryNode(null, null)); } -}
\ No newline at end of file +} diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java index 10e7759a06..a4c421a2a7 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java @@ -214,7 +214,7 @@ final class TestPOIFSFileSystem { DirectoryNode root = fs.getRoot(); assertEquals(1, root.getEntryCount()); - DocumentNode big = (DocumentNode)root.getEntry("BIG"); + DocumentNode big = (DocumentNode)root.getEntryCaseInsensitive("BIG"); assertEquals(hugeStream.length, big.getSize()); } diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java index fcc1e4bcf1..8d24e9f87b 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java @@ -390,7 +390,7 @@ final class TestPOIFSMiniStore { assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(2)); // Check the data is unchanged and the right length - entry = (DocumentEntry) fs.getRoot().getEntry("mini"); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("mini"); assertEquals(data.length, entry.getSize()); byte[] rdata = new byte[data.length]; dis = new DocumentInputStream(entry); @@ -398,7 +398,7 @@ final class TestPOIFSMiniStore { assertArrayEquals(data, rdata); dis.close(); - entry = (DocumentEntry) fs.getRoot().getEntry("mini2"); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("mini2"); assertEquals(data.length, entry.getSize()); rdata = new byte[data.length]; dis = new DocumentInputStream(entry); diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSStream.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSStream.java index 4efcc80983..7f25ca751d 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSStream.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSStream.java @@ -960,7 +960,7 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(10)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11)); - DocumentEntry normal = (DocumentEntry) fs1.getRoot().getEntry("Normal"); + DocumentEntry normal = (DocumentEntry) fs1.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(4106, normal.getSize()); assertEquals(4106, ((DocumentNode) normal).getProperty().getSize()); @@ -988,7 +988,7 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(10)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11)); - normal = (DocumentEntry) fs1.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs1.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(4096, normal.getSize()); assertEquals(4096, ((DocumentNode) normal).getProperty().getSize()); @@ -1011,13 +1011,13 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(10)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11)); - normal = (DocumentEntry) fs2.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs2.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(4096, normal.getSize()); assertEquals(4096, ((DocumentNode) normal).getProperty().getSize()); // Make longer, take 1 block at the end - normal = (DocumentEntry) fs2.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs2.getRoot().getEntryCaseInsensitive("Normal"); try (DocumentOutputStream nout = new DocumentOutputStream(normal)) { nout.write(main4106); } @@ -1036,14 +1036,14 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12)); - normal = (DocumentEntry) fs2.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs2.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(4106, normal.getSize()); assertEquals(4106, ((DocumentNode) normal).getProperty().getSize()); // Make it small, will trigger the SBAT stream and free lots up byte[] mini = new byte[]{42, 0, 1, 2, 3, 4, 42}; - normal = (DocumentEntry) fs2.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs2.getRoot().getEntryCaseInsensitive("Normal"); try (DocumentOutputStream nout = new DocumentOutputStream(normal)) { nout.write(mini); } @@ -1062,7 +1062,7 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(11)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12)); - normal = (DocumentEntry) fs2.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs2.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(7, normal.getSize()); assertEquals(7, ((DocumentNode) normal).getProperty().getSize()); @@ -1088,7 +1088,7 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(13)); - normal = (DocumentEntry) fs2.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs2.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(4096, normal.getSize()); assertEquals(4096, ((DocumentNode) normal).getProperty().getSize()); @@ -1112,7 +1112,7 @@ final class TestPOIFSStream { assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(12)); assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(13)); - normal = (DocumentEntry) fs3.getRoot().getEntry("Normal"); + normal = (DocumentEntry) fs3.getRoot().getEntryCaseInsensitive("Normal"); assertEquals(4096, normal.getSize()); assertEquals(4096, ((DocumentNode) normal).getProperty().getSize()); } @@ -1639,11 +1639,11 @@ final class TestPOIFSStream { assertEquals(5, root.getEntryCount()); // Check by the names - Entry thumbnail = root.getEntry("Thumbnail"); - Entry dsi = root.getEntry("\u0005DocumentSummaryInformation"); - Entry si = root.getEntry("\u0005SummaryInformation"); - Entry image = root.getEntry("Image"); - Entry tags = root.getEntry("Tags"); + Entry thumbnail = root.getEntryCaseInsensitive("Thumbnail"); + Entry dsi = root.getEntryCaseInsensitive("\u0005DocumentSummaryInformation"); + Entry si = root.getEntryCaseInsensitive("\u0005SummaryInformation"); + Entry image = root.getEntryCaseInsensitive("Image"); + Entry tags = root.getEntryCaseInsensitive("Tags"); assertFalse(thumbnail.isDirectoryEntry()); assertFalse(dsi.isDirectoryEntry()); @@ -1675,7 +1675,7 @@ final class TestPOIFSStream { throws IOException, NoPropertySetStreamException { try (POIFSFileSystem fs = opener.apply(file)) { DirectoryEntry root = fs.getRoot(); - Entry si = root.getEntry("\u0005SummaryInformation"); + Entry si = root.getEntryCaseInsensitive("\u0005SummaryInformation"); assertTrue(si.isDocumentEntry()); DocumentNode doc = (DocumentNode) si; @@ -1697,7 +1697,7 @@ final class TestPOIFSStream { // Try the other summary information - si = root.getEntry("\u0005DocumentSummaryInformation"); + si = root.getEntryCaseInsensitive("\u0005DocumentSummaryInformation"); assertTrue(si.isDocumentEntry()); doc = (DocumentNode) si; assertContentsMatches(null, doc); @@ -1745,11 +1745,11 @@ final class TestPOIFSStream { // Check the contents of them - parse the summary block and check sinf = (SummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, sinf.getOSVersion()); dinf = (DocumentSummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, dinf.getOSVersion()); @@ -1765,7 +1765,7 @@ final class TestPOIFSStream { try (POIFSFileSystem fs3 = writeOutAndReadBack(fs2)) { root = fs3.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(6, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); assertThat(root.getEntryNames(), hasItem("Image")); @@ -1777,21 +1777,21 @@ final class TestPOIFSStream { // Check old and new are there sinf = (SummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, sinf.getOSVersion()); dinf = (DocumentSummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, dinf.getOSVersion()); - assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini")); + assertContentsMatches(mini, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini")); // Write out and read once more, just to be sure try (POIFSFileSystem fs4 = writeOutAndReadBack(fs3)) { root = fs4.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(6, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); assertThat(root.getEntryNames(), hasItem("Image")); @@ -1801,14 +1801,14 @@ final class TestPOIFSStream { assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation")); sinf = (SummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, sinf.getOSVersion()); dinf = (DocumentSummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, dinf.getOSVersion()); - assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini")); + assertContentsMatches(mini, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini")); // Add a full stream, delete a full stream @@ -1817,7 +1817,7 @@ final class TestPOIFSStream { main4096[4095] = -11; testDir.createDocument("Normal4096", new ByteArrayInputStream(main4096)); - root.getEntry("Tags").delete(); + root.getEntryCaseInsensitive("Tags").delete(); // Write out, re-load @@ -1825,7 +1825,7 @@ final class TestPOIFSStream { // Check it's all there root = fs5.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(5, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); assertThat(root.getEntryNames(), hasItem("Image")); @@ -1836,19 +1836,19 @@ final class TestPOIFSStream { // Check old and new are there sinf = (SummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(SummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, sinf.getOSVersion()); dinf = (DocumentSummaryInformation) PropertySetFactory.create(new DocumentInputStream( - (DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); + (DocumentEntry) root.getEntryCaseInsensitive(DocumentSummaryInformation.DEFAULT_STREAM_NAME))); assertEquals(131333, dinf.getOSVersion()); - assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini")); - assertContentsMatches(main4096, (DocumentEntry) testDir.getEntry("Normal4096")); + assertContentsMatches(mini, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini")); + assertContentsMatches(main4096, (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096")); // Delete a directory, and add one more - testDir.getEntry("Testing 456").delete(); + testDir.getEntryCaseInsensitive("Testing 456").delete(); testDir.createDirectory("Testing ABC"); @@ -1857,7 +1857,7 @@ final class TestPOIFSStream { // Check root = fs6.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(5, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); @@ -1881,7 +1881,7 @@ final class TestPOIFSStream { try (POIFSFileSystem fs7 = writeOutAndReadBack(fs6)) { root = fs7.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(5, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); @@ -1897,13 +1897,13 @@ final class TestPOIFSStream { assertThat(testDir.getEntryNames(), hasItem("Testing 789")); assertThat(testDir.getEntryNames(), hasItem("Testing ABC")); - assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini")); - assertContentsMatches(mini2, (DocumentEntry) testDir.getEntry("Mini2")); - assertContentsMatches(main4096, (DocumentEntry) testDir.getEntry("Normal4096")); + assertContentsMatches(mini, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini")); + assertContentsMatches(mini2, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini2")); + assertContentsMatches(main4096, (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096")); // Delete a mini stream, add one more - testDir.getEntry("Mini").delete(); + testDir.getEntryCaseInsensitive("Mini").delete(); byte[] mini3 = new byte[]{42, 0, 42, 0, 42, 0, 42}; testDir.createDocument("Mini3", new ByteArrayInputStream(mini3)); @@ -1913,7 +1913,7 @@ final class TestPOIFSStream { try (POIFSFileSystem fs8 = writeOutAndReadBack(fs7)) { root = fs8.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(5, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); @@ -1929,19 +1929,19 @@ final class TestPOIFSStream { assertThat(testDir.getEntryNames(), hasItem("Testing 789")); assertThat(testDir.getEntryNames(), hasItem("Testing ABC")); - assertContentsMatches(mini2, (DocumentEntry) testDir.getEntry("Mini2")); - assertContentsMatches(mini3, (DocumentEntry) testDir.getEntry("Mini3")); - assertContentsMatches(main4096, (DocumentEntry) testDir.getEntry("Normal4096")); + assertContentsMatches(mini2, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini2")); + assertContentsMatches(mini3, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini3")); + assertContentsMatches(main4096, (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096")); // Change some existing streams - POIFSDocument mini2Doc = new POIFSDocument((DocumentNode) testDir.getEntry("Mini2")); + POIFSDocument mini2Doc = new POIFSDocument((DocumentNode) testDir.getEntryCaseInsensitive("Mini2")); mini2Doc.replaceContents(new ByteArrayInputStream(mini)); byte[] main4106 = new byte[4106]; main4106[0] = 41; main4106[4105] = 42; - POIFSDocument mainDoc = new POIFSDocument((DocumentNode) testDir.getEntry("Normal4096")); + POIFSDocument mainDoc = new POIFSDocument((DocumentNode) testDir.getEntryCaseInsensitive("Normal4096")); mainDoc.replaceContents(new ByteArrayInputStream(main4106)); @@ -1949,7 +1949,7 @@ final class TestPOIFSStream { try (POIFSFileSystem fs9 = writeOutAndReadBack(fs8)) { root = fs9.getRoot(); - testDir = (DirectoryEntry) root.getEntry("Testing 123"); + testDir = (DirectoryEntry) root.getEntryCaseInsensitive("Testing 123"); assertEquals(5, root.getEntryCount()); assertThat(root.getEntryNames(), hasItem("Thumbnail")); @@ -1965,9 +1965,9 @@ final class TestPOIFSStream { assertThat(testDir.getEntryNames(), hasItem("Testing 789")); assertThat(testDir.getEntryNames(), hasItem("Testing ABC")); - assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini2")); - assertContentsMatches(mini3, (DocumentEntry) testDir.getEntry("Mini3")); - assertContentsMatches(main4106, (DocumentEntry) testDir.getEntry("Normal4096")); + assertContentsMatches(mini, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini2")); + assertContentsMatches(mini3, (DocumentEntry) testDir.getEntryCaseInsensitive("Mini3")); + assertContentsMatches(main4106, (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096")); } } } @@ -2165,16 +2165,16 @@ final class TestPOIFSStream { // Check some data assertEquals(1, fs5.getRoot().getEntryCount()); - testDir = (DirectoryEntry) fs5.getRoot().getEntry("Test Directory"); + testDir = (DirectoryEntry) fs5.getRoot().getEntryCaseInsensitive("Test Directory"); assertEquals(3, testDir.getEntryCount()); - DocumentEntry miniDoc = (DocumentEntry) testDir.getEntry("Mini"); + DocumentEntry miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini"); assertContentsMatches(mini, miniDoc); - DocumentEntry normDoc = (DocumentEntry) testDir.getEntry("Normal4096"); + DocumentEntry normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096"); assertContentsMatches(main4096, normDoc); - normDoc = (DocumentEntry) testDir.getEntry("Normal5124"); + normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal5124"); assertContentsMatches(main5124, normDoc); @@ -2278,10 +2278,10 @@ final class TestPOIFSStream { // Check that we can read the right data pre-write - DocumentEntry miniDoc = (DocumentEntry) testDir.getEntry("Mini"); + DocumentEntry miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini"); assertContentsMatches(mini, miniDoc); - DocumentEntry normDoc = (DocumentEntry) testDir.getEntry("Normal4096"); + DocumentEntry normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096"); assertContentsMatches(main4096, normDoc); @@ -2319,16 +2319,16 @@ final class TestPOIFSStream { DirectoryEntry fsRoot = fs2.getRoot(); assertEquals(1, fsRoot.getEntryCount()); - parentDir = (DirectoryEntry) fsRoot.getEntry("Parent Directory"); + parentDir = (DirectoryEntry) fsRoot.getEntryCaseInsensitive("Parent Directory"); assertEquals(1, parentDir.getEntryCount()); - testDir = (DirectoryEntry) parentDir.getEntry("Test Directory"); + testDir = (DirectoryEntry) parentDir.getEntryCaseInsensitive("Test Directory"); assertEquals(2, testDir.getEntryCount()); - miniDoc = (DocumentEntry) testDir.getEntry("Mini"); + miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini"); assertContentsMatches(mini, miniDoc); - normDoc = (DocumentEntry) testDir.getEntry("Normal4096"); + normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4096"); assertContentsMatches(main4096, normDoc); @@ -2347,19 +2347,19 @@ final class TestPOIFSStream { fsRoot = fs3.getRoot(); assertEquals(1, fsRoot.getEntryCount()); - parentDir = (DirectoryEntry) fsRoot.getEntry("Parent Directory"); + parentDir = (DirectoryEntry) fsRoot.getEntryCaseInsensitive("Parent Directory"); assertEquals(1, parentDir.getEntryCount()); - testDir = (DirectoryEntry) parentDir.getEntry("Test Directory"); + testDir = (DirectoryEntry) parentDir.getEntryCaseInsensitive("Test Directory"); assertEquals(4, testDir.getEntryCount()); - miniDoc = (DocumentEntry) testDir.getEntry("Mini"); + miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini"); assertContentsMatches(mini, miniDoc); - miniDoc = (DocumentEntry) testDir.getEntry("Mini2"); + miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini2"); assertContentsMatches(mini2, miniDoc); - normDoc = (DocumentEntry) testDir.getEntry("Normal4106"); + normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4106"); assertContentsMatches(main4106, normDoc); } } @@ -2372,15 +2372,15 @@ final class TestPOIFSStream { DirectoryNode testDir = fs.getRoot(); assertEquals(3, testDir.getEntryCount()); - DocumentEntry entry = (DocumentEntry) testDir.getEntry("test-zero-1"); + DocumentEntry entry = (DocumentEntry) testDir.getEntryCaseInsensitive("test-zero-1"); assertNotNull(entry); assertEquals(0, entry.getSize()); - entry = (DocumentEntry) testDir.getEntry("test-zero-2"); + entry = (DocumentEntry) testDir.getEntryCaseInsensitive("test-zero-2"); assertNotNull(entry); assertEquals(0, entry.getSize()); - entry = (DocumentEntry) testDir.getEntry("test-zero-3"); + entry = (DocumentEntry) testDir.getEntryCaseInsensitive("test-zero-3"); assertNotNull(entry); assertEquals(0, entry.getSize()); @@ -2419,19 +2419,19 @@ final class TestPOIFSStream { testDir.createDocument("empty-3", new ByteArrayInputStream(empty)); // Check - miniDoc = (DocumentEntry) testDir.getEntry("Mini2"); + miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini2"); assertContentsMatches(mini2, miniDoc); - normDoc = (DocumentEntry) testDir.getEntry("Normal4106"); + normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4106"); assertContentsMatches(main4106, normDoc); - emptyDoc = (DocumentEntry) testDir.getEntry("empty-1"); + emptyDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("empty-1"); assertContentsMatches(empty, emptyDoc); - emptyDoc = (DocumentEntry) testDir.getEntry("empty-2"); + emptyDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("empty-2"); assertContentsMatches(empty, emptyDoc); - emptyDoc = (DocumentEntry) testDir.getEntry("empty-3"); + emptyDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("empty-3"); assertContentsMatches(empty, emptyDoc); // Look at the properties entry, and check the empty ones @@ -2469,19 +2469,19 @@ final class TestPOIFSStream { try (POIFSFileSystem fs2 = writeOutAndReadBack(fs1)) { testDir = fs2.getRoot(); - miniDoc = (DocumentEntry) testDir.getEntry("Mini2"); + miniDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Mini2"); assertContentsMatches(mini2, miniDoc); - normDoc = (DocumentEntry) testDir.getEntry("Normal4106"); + normDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("Normal4106"); assertContentsMatches(main4106, normDoc); - emptyDoc = (DocumentEntry) testDir.getEntry("empty-1"); + emptyDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("empty-1"); assertContentsMatches(empty, emptyDoc); - emptyDoc = (DocumentEntry) testDir.getEntry("empty-2"); + emptyDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("empty-2"); assertContentsMatches(empty, emptyDoc); - emptyDoc = (DocumentEntry) testDir.getEntry("empty-3"); + emptyDoc = (DocumentEntry) testDir.getEntryCaseInsensitive("empty-3"); assertContentsMatches(empty, emptyDoc); // Check that a mini-stream was assigned, with one block used @@ -2528,7 +2528,7 @@ final class TestPOIFSStream { assertEquals(5, src.getRoot().getEntryCount()); // Grab the VBA project root - DirectoryEntry vbaProj = (DirectoryEntry) src.getRoot().getEntry("_VBA_PROJECT_CUR"); + DirectoryEntry vbaProj = (DirectoryEntry) src.getRoot().getEntryCaseInsensitive("_VBA_PROJECT_CUR"); assertEquals(3, vbaProj.getEntryCount()); // Can't delete yet, has stuff assertFalse(vbaProj.delete()); @@ -2550,7 +2550,7 @@ final class TestPOIFSStream { DirectoryEntry dir = (DirectoryEntry) entry; String[] names = dir.getEntryNames().toArray(new String[dir.getEntryCount()]); for (String name : names) { - Entry ce = dir.getEntry(name); + Entry ce = dir.getEntryCaseInsensitive(name); _recursiveDeletee(ce); } assertTrue(dir.delete()); @@ -2602,7 +2602,7 @@ final class TestPOIFSStream { // Extend it past the 2gb mark try (POIFSFileSystem fs = new POIFSFileSystem(big, false)) { for (int i = 0; i < 19; i++) { - entry = (DocumentEntry) fs.getRoot().getEntry("Entry" + i); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Entry" + i); assertNotNull(entry); assertEquals(s100mb, entry.getSize()); } @@ -2614,11 +2614,11 @@ final class TestPOIFSStream { // Check it still works try (POIFSFileSystem fs = new POIFSFileSystem(big, false)) { for (int i = 0; i < 19; i++) { - entry = (DocumentEntry) fs.getRoot().getEntry("Entry" + i); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Entry" + i); assertNotNull(entry); assertEquals(s100mb, entry.getSize()); } - entry = (DocumentEntry) fs.getRoot().getEntry("Bigger"); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Bigger"); assertNotNull(entry); assertEquals(s512mb, entry.getSize()); } @@ -2637,7 +2637,7 @@ final class TestPOIFSStream { // Read it try (POIFSFileSystem fs = new POIFSFileSystem(big, false)) { for (int i = 0; i < 4; i++) { - entry = (DocumentEntry) fs.getRoot().getEntry("Entry" + i); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Entry" + i); assertNotNull(entry); assertEquals(s512mb, entry.getSize()); } @@ -2650,7 +2650,7 @@ final class TestPOIFSStream { // Check it worked try (POIFSFileSystem fs = new POIFSFileSystem(big, false)) { for (int i = 0; i < 5; i++) { - entry = (DocumentEntry) fs.getRoot().getEntry("Entry" + i); + entry = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Entry" + i); assertNotNull(entry); assertEquals(s512mb, entry.getSize()); } diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPropertySorter.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPropertySorter.java index 7c674b5b69..4b12050ba2 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPropertySorter.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPropertySorter.java @@ -116,9 +116,9 @@ final class TestPropertySorter { String VBA = "VBA"; DirectoryEntry root = fs.getRoot(); - DirectoryEntry vba_project = (DirectoryEntry)root.getEntry(_VBA_PROJECT_CUR); + DirectoryEntry vba_project = (DirectoryEntry)root.getEntryCaseInsensitive(_VBA_PROJECT_CUR); - DirectoryNode vba = (DirectoryNode)vba_project.getEntry(VBA); + DirectoryNode vba = (DirectoryNode)vba_project.getEntryCaseInsensitive(VBA); DirectoryProperty p = (DirectoryProperty)vba.getProperty(); List<Property> lst = new ArrayList<>(); |