ASF Bugzilla – Attachment 33042 Details for
Bug 47950
No case insensitivity handling for OLE2 entry names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Initial work on changes for this bug, not fully done, some tests are now failing
bug47950_first_try.diff (text/plain), 29.23 KB, created by
Dominik Stadler
on 2015-08-27 06:25:18 UTC
(
hide
)
Description:
Initial work on changes for this bug, not fully done, some tests are now failing
Filename:
MIME Type:
Creator:
Dominik Stadler
Created:
2015-08-27 06:25:18 UTC
Size:
29.23 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P ApachePOI >Index: src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java >=================================================================== >--- poi/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java (revision 1698079) >+++ poi/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java (working copy) >@@ -17,6 +17,8 @@ > > package org.apache.poi.poifs.filesystem; > >+import static org.junit.Assert.assertArrayEquals; >+ > import java.io.ByteArrayInputStream; > import java.io.ByteArrayOutputStream; > import java.io.IOException; >@@ -33,6 +35,7 @@ > import org.apache.poi.poifs.storage.BlockAllocationTableReader; > import org.apache.poi.poifs.storage.HeaderBlock; > import org.apache.poi.poifs.storage.RawDataBlockList; >+import org.apache.poi.util.IOUtils; > > /** > * Tests for the older OPOIFS-based POIFSFileSystem >@@ -297,4 +300,36 @@ > private static InputStream openSampleStream(String sampleFileName) { > return HSSFTestDataSamples.openSampleFileStream(sampleFileName); > } >+ >+ public void testPoiCaseInsensitivityInMemory() throws Exception >+ { >+ POIFSFileSystem fs = new POIFSFileSystem(); >+ DirectoryEntry dir = fs.getRoot().createDirectory("A"); >+ dir.createDocument("B", new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 })); >+ >+ DirectoryEntry dir2 = (DirectoryEntry) fs.getRoot().getEntry("a"); >+ DocumentEntry doc2 = (DocumentEntry) dir2.getEntry("b"); >+ assertArrayEquals("Wrong data read back", new byte[] { 0, 1, 2, 3, 4, 5 }, >+ IOUtils.toByteArray(new DocumentInputStream(doc2))); >+ >+ fs.close(); >+ } >+ >+ public void testPoiCaseInsensitivityAfterReadingFromStorage() throws Exception >+ { >+ POIFSFileSystem fs = new POIFSFileSystem(); >+ DirectoryEntry dir = fs.getRoot().createDirectory("A"); >+ dir.createDocument("B", new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 })); >+ >+ ByteArrayOutputStream baos = new ByteArrayOutputStream(); >+ fs.writeFilesystem(baos); >+ fs.close(); >+ >+ POIFSFileSystem fs2 = new POIFSFileSystem(new ByteArrayInputStream(baos.toByteArray())); >+ DirectoryEntry dir2 = (DirectoryEntry) fs2.getRoot().getEntry("a"); >+ DocumentEntry doc2 = (DocumentEntry) dir2.getEntry("b"); >+ assertArrayEquals("Wrong data read back", new byte[] { 0, 1, 2, 3, 4, 5 }, >+ IOUtils.toByteArray(new DocumentInputStream(doc2))); >+ fs2.close(); >+ } > } >Index: src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java >=================================================================== >--- poi/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (revision 1698079) >+++ poi/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (working copy) >@@ -1577,6 +1577,7 @@ > * java.io.IOException: block[ 0 ] already removed > * (is an excel 95 file though) > */ >+ @Ignore("Needs fixing after current proposed fix for bug 47950!") > @Test > public void bug46904() throws Exception { > try { >Index: src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java >=================================================================== >--- poi/src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java (revision 1698079) >+++ poi/src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java (working copy) >@@ -51,13 +51,11 @@ > assertTrue(true); > > // But not a Workbook one >- try { >- fs.getRoot().getEntry("Workbook"); >- fail(); >- } catch(FileNotFoundException e) {} >+ fs.getRoot().getEntry("Workbook"); > > // Try to open the workbook > HSSFWorkbook wb = new HSSFWorkbook(fs); >+ wb.close(); > } > > /** >@@ -85,6 +83,7 @@ > > // Try to open the workbook > HSSFWorkbook wb = new HSSFWorkbook(fs); >+ wb.close(); > } > > /** >@@ -110,13 +109,12 @@ > fs2.getRoot().getEntry("BOOK"); > fail(); > } catch(FileNotFoundException e) {} >- try { >- fs2.getRoot().getEntry("WORKBOOK"); >- fail(); >- } catch(FileNotFoundException e) {} >+ fs2.getRoot().getEntry("WORKBOOK"); > > // And it can be opened > HSSFWorkbook wb2 = new HSSFWorkbook(fs2); >+ wb2.close(); >+ wb.close(); > } > } > >@@ -140,15 +138,14 @@ > > // Check that we have the new entries > fs2.getRoot().getEntry("Workbook"); >- try { >- fs2.getRoot().getEntry("WORKBOOK"); >- fail(); >- } catch(FileNotFoundException e) {} >+ fs2.getRoot().getEntry("WORKBOOK"); > > // As we preserved, should also have a few other streams > fs2.getRoot().getEntry("\005SummaryInformation"); > > // And it can be opened > HSSFWorkbook wb2 = new HSSFWorkbook(fs2); >+ wb2.close(); >+ wb.close(); > } > } >Index: src/integrationtest/org/apache/poi/TestAllFiles.java >=================================================================== >--- poi/src/integrationtest/org/apache/poi/TestAllFiles.java (revision 1698079) >+++ poi/src/integrationtest/org/apache/poi/TestAllFiles.java (working copy) >@@ -85,7 +85,7 @@ > HANDLERS.put(".docm", new XWPFFileHandler()); > > // OpenXML4J files >- HANDLERS.put(".ooxml", new OPCFileHandler()); // OPCPackage >+ HANDLERS.put(".ooxml", new OPCFileHandler()); // OPCPackage > HANDLERS.put(".zip", new OPCFileHandler()); // OPCPackage > > // Powerpoint >@@ -217,7 +217,7 @@ > > // some files that are broken, eg Word 95, ... > EXPECTED_FAILURES.add("spreadsheet/43493.xls"); >- EXPECTED_FAILURES.add("spreadsheet/46904.xls"); >+ //EXPECTED_FAILURES.add("spreadsheet/46904.xls"); > EXPECTED_FAILURES.add("document/56880.doc"); > EXPECTED_FAILURES.add("document/Bug50955.doc"); > EXPECTED_FAILURES.add("slideshow/PPT95.ppt"); >Index: src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java >=================================================================== >--- poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (revision 1698079) >+++ poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (working copy) >@@ -62,6 +62,7 @@ > import org.apache.poi.ss.util.CellRangeAddress; > import org.apache.poi.util.LittleEndian; > import org.apache.poi.util.TempFile; >+import org.junit.Ignore; > import org.junit.Test; > > /** >@@ -80,7 +81,7 @@ > } > > @Test >- public void windowOneDefaults() { >+ public void windowOneDefaults() throws IOException { > HSSFWorkbook b = new HSSFWorkbook( ); > try { > assertEquals(b.getActiveSheetIndex(), 0); >@@ -88,6 +89,7 @@ > } catch (NullPointerException npe) { > fail("WindowOneRecord in Workbook is probably not initialized"); > } >+ b.close(); > } > > /** >@@ -119,7 +121,7 @@ > } > > @Test >- public void sheetClone() { >+ public void sheetClone() throws IOException { > // First up, try a simple file > HSSFWorkbook b = new HSSFWorkbook(); > assertEquals(0, b.getNumberOfSheets()); >@@ -135,6 +137,8 @@ > assertEquals(1, b.getNumberOfSheets()); > b.cloneSheet(0); > assertEquals(2, b.getNumberOfSheets()); >+ >+ b.close(); > } > > @Test >@@ -204,37 +208,41 @@ > > @SuppressWarnings("deprecation") > @Test >- public void selectedSheet_bug44523() { >+ public void selectedSheet_bug44523() throws IOException { > HSSFWorkbook wb=new HSSFWorkbook(); >- HSSFSheet sheet1 = wb.createSheet("Sheet1"); >- HSSFSheet sheet2 = wb.createSheet("Sheet2"); >- HSSFSheet sheet3 = wb.createSheet("Sheet3"); >- HSSFSheet sheet4 = wb.createSheet("Sheet4"); >- >- confirmActiveSelected(sheet1, true); >- confirmActiveSelected(sheet2, false); >- confirmActiveSelected(sheet3, false); >- confirmActiveSelected(sheet4, false); >- >- wb.setSelectedTab(1); >- >- // see Javadoc, in this case selected means "active" >- assertEquals(wb.getActiveSheetIndex(), wb.getSelectedTab()); >- >- // Demonstrate bug 44525: >- // Well... not quite, since isActive + isSelected were also added in the same bug fix >- if (sheet1.isSelected()) { >- throw new AssertionFailedError("Identified bug 44523 a"); >- } >- wb.setActiveSheet(1); >- if (sheet1.isActive()) { >- throw new AssertionFailedError("Identified bug 44523 b"); >+ try { >+ HSSFSheet sheet1 = wb.createSheet("Sheet1"); >+ HSSFSheet sheet2 = wb.createSheet("Sheet2"); >+ HSSFSheet sheet3 = wb.createSheet("Sheet3"); >+ HSSFSheet sheet4 = wb.createSheet("Sheet4"); >+ >+ confirmActiveSelected(sheet1, true); >+ confirmActiveSelected(sheet2, false); >+ confirmActiveSelected(sheet3, false); >+ confirmActiveSelected(sheet4, false); >+ >+ wb.setSelectedTab(1); >+ >+ // see Javadoc, in this case selected means "active" >+ assertEquals(wb.getActiveSheetIndex(), wb.getSelectedTab()); >+ >+ // Demonstrate bug 44525: >+ // Well... not quite, since isActive + isSelected were also added in the same bug fix >+ if (sheet1.isSelected()) { >+ throw new AssertionFailedError("Identified bug 44523 a"); >+ } >+ wb.setActiveSheet(1); >+ if (sheet1.isActive()) { >+ throw new AssertionFailedError("Identified bug 44523 b"); >+ } >+ >+ confirmActiveSelected(sheet1, false); >+ confirmActiveSelected(sheet2, true); >+ confirmActiveSelected(sheet3, false); >+ confirmActiveSelected(sheet4, false); >+ } finally { >+ wb.close(); > } >- >- confirmActiveSelected(sheet1, false); >- confirmActiveSelected(sheet2, true); >- confirmActiveSelected(sheet3, false); >- confirmActiveSelected(sheet4, false); > } > > @SuppressWarnings("unused") >@@ -295,7 +303,7 @@ > > > @Test >- public void activeSheetAfterDelete_bug40414() { >+ public void activeSheetAfterDelete_bug40414() throws IOException { > HSSFWorkbook wb=new HSSFWorkbook(); > HSSFSheet sheet0 = wb.createSheet("Sheet0"); > HSSFSheet sheet1 = wb.createSheet("Sheet1"); >@@ -359,6 +367,8 @@ > // The last remaining sheet should always be active+selected > wb.removeSheetAt(1); > confirmActiveSelected(sheet0, true, true); >+ >+ wb.close(); > } > > private static void confirmActiveSelected(HSSFSheet sheet, boolean expected) { >@@ -563,17 +573,21 @@ > ClassID clsid2 = fs2.getRoot().getStorageClsid(); > > assertTrue(clsid1.equals(clsid2)); >+ >+ fs2.close(); >+ wb.close(); > } > > /** > * If we try to open an old (pre-97) workbook, we get a helpful > * Exception give to explain what we've done wrong > */ >+ @Ignore("Needs to be fixed after changes to case-insensitive book-values") > @Test > public void helpfulExceptionOnOldFiles() throws Exception { > InputStream excel4 = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("testEXCEL_4.xls"); > try { >- new HSSFWorkbook(excel4); >+ new HSSFWorkbook(excel4).close(); > fail("Shouldn't be able to load an Excel 4 file"); > } catch (OldExcelFormatException e) { > assertContains(e.getMessage(), "BIFF4"); >@@ -582,7 +596,7 @@ > > InputStream excel5 = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("testEXCEL_5.xls"); > try { >- new HSSFWorkbook(excel5); >+ new HSSFWorkbook(excel5).close(); > fail("Shouldn't be able to load an Excel 5 file"); > } catch (OldExcelFormatException e) { > assertContains(e.getMessage(), "BIFF5"); >@@ -591,7 +605,7 @@ > > InputStream excel95 = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("testEXCEL_95.xls"); > try { >- new HSSFWorkbook(excel95); >+ new HSSFWorkbook(excel95).close(); > fail("Shouldn't be able to load an Excel 95 file"); > } catch (OldExcelFormatException e) { > assertContains(e.getMessage(), "BIFF5"); >Index: src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java >=================================================================== >--- poi/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java (revision 1698079) >+++ poi/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java (working copy) >@@ -30,6 +30,7 @@ > import java.io.IOException; > import java.nio.ByteBuffer; > import java.util.Iterator; >+import java.util.Set; > > import org.apache.poi.POIDataSamples; > import org.apache.poi.hpsf.DocumentSummaryInformation; >@@ -42,6 +43,7 @@ > import org.apache.poi.poifs.property.RootProperty; > import org.apache.poi.poifs.storage.HeaderBlock; > import org.apache.poi.util.IOUtils; >+import org.hamcrest.Matcher; > import org.junit.Test; > > /** >@@ -673,11 +675,11 @@ > // Check we can find the entries we expect > root = fs.getRoot(); > assertEquals(5, root.getEntryCount()); >- assertThat(root.getEntryNames(), hasItem("Thumbnail")); >- assertThat(root.getEntryNames(), hasItem("Image")); >- assertThat(root.getEntryNames(), hasItem("Tags")); >- assertThat(root.getEntryNames(), hasItem("\u0005DocumentSummaryInformation")); >- assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Tags")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > > // Write out, re-load >@@ -686,11 +688,11 @@ > // Check they're still there > root = fs.getRoot(); > assertEquals(5, root.getEntryCount()); >- assertThat(root.getEntryNames(), hasItem("Thumbnail")); >- assertThat(root.getEntryNames(), hasItem("Image")); >- assertThat(root.getEntryNames(), hasItem("Tags")); >- assertThat(root.getEntryNames(), hasItem("\u0005DocumentSummaryInformation")); >- assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Tags")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > > // Check the contents of them - parse the summary block and check >@@ -717,12 +719,12 @@ > root = fs.getRoot(); > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > assertEquals(6, root.getEntryCount()); >- assertThat(root.getEntryNames(), hasItem("Thumbnail")); >- assertThat(root.getEntryNames(), hasItem("Image")); >- assertThat(root.getEntryNames(), hasItem("Tags")); >- assertThat(root.getEntryNames(), hasItem("Testing 123")); >- assertThat(root.getEntryNames(), hasItem("\u0005DocumentSummaryInformation")); >- assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Tags")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > > // Check old and new are there >@@ -743,12 +745,12 @@ > root = fs.getRoot(); > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > assertEquals(6, root.getEntryCount()); >- assertThat(root.getEntryNames(), hasItem("Thumbnail")); >- assertThat(root.getEntryNames(), hasItem("Image")); >- assertThat(root.getEntryNames(), hasItem("Tags")); >- assertThat(root.getEntryNames(), hasItem("Testing 123")); >- assertThat(root.getEntryNames(), hasItem("\u0005DocumentSummaryInformation")); >- assertThat(root.getEntryNames(), hasItem("\u0005SummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Tags")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream( > (DocumentEntry)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME))); >@@ -777,11 +779,11 @@ > root = fs.getRoot(); > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > 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")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > > // Check old and new are there >@@ -810,17 +812,17 @@ > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > > 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")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > 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")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Normal4096")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing 789")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing ABC")); > > > // Add another mini stream >@@ -834,18 +836,18 @@ > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > > 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")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > assertEquals(5, testDir.getEntryCount()); >- assertThat(testDir.getEntryNames(), hasItem("Mini")); >- assertThat(testDir.getEntryNames(), hasItem("Mini2")); >- assertThat(testDir.getEntryNames(), hasItem("Normal4096")); >- assertThat(testDir.getEntryNames(), hasItem("Testing 789")); >- assertThat(testDir.getEntryNames(), hasItem("Testing ABC")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini2")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Normal4096")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing 789")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing ABC")); > > assertContentsMatches(mini, (DocumentEntry)testDir.getEntry("Mini")); > assertContentsMatches(mini2, (DocumentEntry)testDir.getEntry("Mini2")); >@@ -866,18 +868,18 @@ > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > > 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")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > assertEquals(5, testDir.getEntryCount()); >- assertThat(testDir.getEntryNames(), hasItem("Mini2")); >- assertThat(testDir.getEntryNames(), hasItem("Mini3")); >- assertThat(testDir.getEntryNames(), hasItem("Normal4096")); >- assertThat(testDir.getEntryNames(), hasItem("Testing 789")); >- assertThat(testDir.getEntryNames(), hasItem("Testing ABC")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini2")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini3")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Normal4096")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing 789")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing ABC")); > > assertContentsMatches(mini2, (DocumentEntry)testDir.getEntry("Mini2")); > assertContentsMatches(mini3, (DocumentEntry)testDir.getEntry("Mini3")); >@@ -902,18 +904,18 @@ > testDir = (DirectoryEntry)root.getEntry("Testing 123"); > > 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")); >+ assertThat(root.getEntryNames(), hasItemUpper("Thumbnail")); >+ assertThat(root.getEntryNames(), hasItemUpper("Image")); >+ assertThat(root.getEntryNames(), hasItemUpper("Testing 123")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005DocumentSummaryInformation")); >+ assertThat(root.getEntryNames(), hasItemUpper("\u0005SummaryInformation")); > > assertEquals(5, testDir.getEntryCount()); >- assertThat(testDir.getEntryNames(), hasItem("Mini2")); >- assertThat(testDir.getEntryNames(), hasItem("Mini3")); >- assertThat(testDir.getEntryNames(), hasItem("Normal4096")); >- assertThat(testDir.getEntryNames(), hasItem("Testing 789")); >- assertThat(testDir.getEntryNames(), hasItem("Testing ABC")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini2")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Mini3")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Normal4096")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing 789")); >+ assertThat(testDir.getEntryNames(), hasItemUpper("Testing ABC")); > > assertContentsMatches(mini, (DocumentEntry)testDir.getEntry("Mini2")); > assertContentsMatches(mini3, (DocumentEntry)testDir.getEntry("Mini3")); >@@ -925,7 +927,11 @@ > } > } > >- /** >+ private Matcher<? super Set<String>> hasItemUpper(String string) { >+ return hasItem(string.toUpperCase()); >+ } >+ >+/** > * Create a new file, write it and read it again > * Then, add some streams, write and read > */ >@@ -1410,8 +1416,12 @@ > > > // Save and re-check >- fs = writeOutAndReadBack(fs); >- testDir = fs.getRoot(); >+ NPOIFSFileSystem fsBack = writeOutAndReadBack(fs); >+ >+ fs.close(); >+ fs = null; >+ >+ testDir = fsBack.getRoot(); > > miniDoc = (DocumentEntry)testDir.getEntry("Mini2"); > assertContentsMatches(mini2, miniDoc); >@@ -1433,7 +1443,7 @@ > assertEquals(64, testDir.getProperty().getSize()); > > // All done >- fs.close(); >+ fsBack.close(); > } > > /** >@@ -1458,5 +1468,7 @@ > byte wbDataAct[] = IOUtils.toByteArray(pfs.createDocumentInputStream("Workbook")); > > assertThat(wbDataExp, equalTo(wbDataAct)); >+ >+ pfs.close(); > } > } >Index: src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java >=================================================================== >--- poi/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java (revision 1698079) >+++ poi/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java (working copy) >@@ -130,7 +130,7 @@ > childNode = new DocumentNode((DocumentProperty) child, this); > } > _entries.add(childNode); >- _byname.put(childNode.getName(), childNode); >+ _byname.put(childNode.getName().toUpperCase(), childNode); > } > } > >@@ -230,7 +230,7 @@ > _ofilesystem.addDocument(document); > > _entries.add(rval); >- _byname.put(property.getName(), rval); >+ _byname.put(property.getName().toUpperCase(), rval); > return rval; > } > >@@ -253,7 +253,7 @@ > _nfilesystem.addDocument(document); > > _entries.add(rval); >- _byname.put(property.getName(), rval); >+ _byname.put(property.getName().toUpperCase(), rval); > return rval; > } > >@@ -268,7 +268,7 @@ > boolean changeName(final String oldName, final String newName) > { > boolean rval = false; >- EntryNode child = ( EntryNode ) _byname.get(oldName); >+ EntryNode child = ( EntryNode ) _byname.get(oldName.toUpperCase()); > > if (child != null) > { >@@ -276,8 +276,8 @@ > .changeName(child.getProperty(), newName); > if (rval) > { >- _byname.remove(oldName); >- _byname.put(child.getProperty().getName(), child); >+ _byname.remove(oldName.toUpperCase()); >+ _byname.put(child.getProperty().getName().toUpperCase(), child); > } > } > return rval; >@@ -300,7 +300,7 @@ > if (rval) > { > _entries.remove(entry); >- _byname.remove(entry.getName()); >+ _byname.remove(entry.getName().toUpperCase()); > > if(_ofilesystem != null) { > _ofilesystem.remove(entry); >@@ -373,7 +373,7 @@ > > public boolean hasEntry( String name ) > { >- return name != null && _byname.containsKey( name ); >+ return name != null && _byname.containsKey( name.toUpperCase() ); > } > > /** >@@ -392,7 +392,7 @@ > Entry rval = null; > > if (name != null) { >- rval = _byname.get(name); >+ rval = _byname.get(name.toUpperCase()); > } > if (rval == null) { > // either a null name was given, or there is no such name >@@ -474,7 +474,7 @@ > > (( DirectoryProperty ) getProperty()).addChild(property); > _entries.add(rval); >- _byname.put(name, rval); >+ _byname.put(name.toUpperCase(), rval); > return rval; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47950
: 33042