]> source.dussan.org Git - poi.git/commitdiff
add failing regression test files
authorAndreas Beeker <kiwiwings@apache.org>
Wed, 30 Dec 2020 22:56:36 +0000 (22:56 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Wed, 30 Dec 2020 22:56:36 +0000 (22:56 +0000)
fix ooxml-lite packaging
fix PP97 dual storage file handling in extractor

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884962 13f79535-47bb-0310-9956-ffa450edef68

29 files changed:
build.xml
src/examples/src/org/apache/poi/examples/ss/ExcelComparator.java
src/multimodule/ooxml-full/java9/module-info.java
src/multimodule/ooxml-lite/java9/module-info.class
src/multimodule/ooxml-lite/java9/module-info.java
src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
src/scratchpad/src/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
test-data/integration/stress001.docx [new file with mode: 0644]
test-data/integration/stress002.xlsx [new file with mode: 0644]
test-data/integration/stress003.docx [new file with mode: 0644]
test-data/integration/stress004.docx [new file with mode: 0644]
test-data/integration/stress005.docx [new file with mode: 0644]
test-data/integration/stress006.docx [new file with mode: 0644]
test-data/integration/stress007.docx [new file with mode: 0644]
test-data/integration/stress008.docx [new file with mode: 0644]
test-data/integration/stress009.docx [new file with mode: 0644]
test-data/integration/stress010.docx [new file with mode: 0644]
test-data/integration/stress011.docx [new file with mode: 0644]
test-data/integration/stress012.docx [new file with mode: 0644]
test-data/integration/stress013.pptx [new file with mode: 0644]
test-data/integration/stress014.docx [new file with mode: 0644]
test-data/integration/stress015.docx [new file with mode: 0644]
test-data/integration/stress016.docx [new file with mode: 0644]
test-data/integration/stress017.docx [new file with mode: 0644]
test-data/integration/stress018.docx [new file with mode: 0644]
test-data/integration/stress019.docx [new file with mode: 0644]
test-data/integration/stress020.xlsx [new file with mode: 0644]

index b2ed09d96d78301a6b664030935111cd4469edf3..f2d71a1cefa9270b827a847b4515289ac374e8b1 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1753,16 +1753,23 @@ under the License.
             </modulepath>
         </javac>
 
+        <copy file="${ooxml.lite.report}.clazz" tofile="${ooxml.lite.report}.clazz1" overwrite="true">
+            <filterchain>
+                <sortfilter/>
+                <suffixlines suffix="$*.class"/>
+            </filterchain>
+        </copy>
+
         <copy file="${ooxml.lite.report}.clazz" tofile="${ooxml.lite.report}.clazz2" overwrite="true">
             <filterchain>
-                <tokenfilter>
-                    <replaceregex pattern="(.*)" replace="\1.class${line.separator}\1$*.class "/>
-                </tokenfilter>
+                <sortfilter/>
+                <suffixlines suffix=".class"/>
             </filterchain>
         </copy>
 
         <copy file="${ooxml.lite.report}.xsb" tofile="${ooxml.lite.report}.xsb2" overwrite="true">
             <filterchain>
+                <sortfilter/>
                 <prefixlines prefix="org/apache/poi/schemas/ooxml/system/ooxml/"/>
                 <suffixlines suffix=".xsb"/>
             </filterchain>
@@ -1770,15 +1777,17 @@ under the License.
 
         <mkdir dir="build/dist/maven/poi-ooxml-lite"/>
 
-        <jar destfile="${ooxml.lite.jar}" duplicate="preserve">
+        <jar destfile="${ooxml.lite.jar}" duplicate="fail">
             <zipfileset dir="${basedir}/src/multimodule/ooxml-lite/java9" prefix="META-INF/versions/9" excludes="*.java"/>
             <zipfileset src="${ooxml.xsds.jar}">
-                <patternset includesfile="${ooxml.lite.report}.clazz2">
+                <patternset>
+                    <includesfile name="${ooxml.lite.report}.clazz1"/>
+                    <includesfile name="${ooxml.lite.report}.clazz2"/>
+                    <includesfile name="${ooxml.lite.report}.xsb2"/>
+<!--                    <include name="org/apache/poi/schemas/ooxml/system/ooxml/*.xsb"/>-->
                     <include name="org/apache/poi/schemas/ooxml/element/**/*.xsb"/>
                 </patternset>
-                <patternset includesfile="${ooxml.lite.report}.xsb2"/>
             </zipfileset>
-            <zipfileset dir="src/multimodule/ooxml-full/java9" prefix="META-INF/versions/9" excludes="*.java"/>
             <manifest>
                 <attribute name="Multi-Release" value="true"/>
                 <attribute name="Automatic-Module-Name" value="org.apache.poi.ooxml.schemas"/>
index eb80d9286f1776e57225cadeb7a12ecfed26908d..069aef0ebe6bb5eb9d0285cfef5e679a16be56b3 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.Cell;
@@ -477,7 +478,7 @@ public class ExcelComparator {
 
         String col1 = getCellFillBackground(loc1);
         String col2 = getCellFillBackground(loc2);
-        if (!col1.equals(col2)) {
+        if (!Objects.equals(col1, col2)) {
             addMessage(loc1, loc2, "Cell Fill Color does not Match ::", col1, col2);
         }
     }
index 4587ea5e5dd85c3be064448d3a5bccf2924b3253..4600c9082adccbdc8990d158319e238d49ac7d26 100644 (file)
@@ -21,6 +21,9 @@ open module org.apache.poi.ooxml.schemas {
     // see https://bugs.openjdk.java.net/browse/JDK-8240847
     requires transitive org.apache.xmlbeans;
     requires java.xml;
+
+    exports org.apache.poi.schemas.ooxml.system.ooxml;
+
     exports com.microsoft.schemas.compatibility;
     exports com.microsoft.schemas.office.excel;
     exports com.microsoft.schemas.office.office;
index f6cd8ef67d2023bba092608b3a473ea0ae09b04c..5a1a8d9258b44306f29dce9dcd0d8a7b34bbf118 100644 (file)
Binary files a/src/multimodule/ooxml-lite/java9/module-info.class and b/src/multimodule/ooxml-lite/java9/module-info.class differ
index 1b22147d880590cb318baba79cbb4e0913c28a03..2559d369d8c921663a34c6f46b1abb71e33fa166 100644 (file)
@@ -23,6 +23,8 @@ open module org.apache.poi.ooxml.schemas {
     requires java.xml;
 
 
+
+
     exports com.microsoft.schemas.compatibility;
     exports com.microsoft.schemas.office.excel;
     exports com.microsoft.schemas.office.office;
@@ -40,6 +42,7 @@ open module org.apache.poi.ooxml.schemas {
     exports org.openxmlformats.schemas.officeDocument.x2006.customProperties;
     exports org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes;
     exports org.openxmlformats.schemas.officeDocument.x2006.extendedProperties;
+    exports org.openxmlformats.schemas.officeDocument.x2006.math;
     exports org.openxmlformats.schemas.officeDocument.x2006.relationships;
     exports org.openxmlformats.schemas.officeDocument.x2006.sharedTypes;
     exports org.openxmlformats.schemas.presentationml.x2006.main;
index 9715e49e80b5ff68d9549b2862db6de78c0953ec..6ea3b2132e216819a6a18b425f05e29a65de21f2 100644 (file)
@@ -81,6 +81,7 @@ public class TestExtractorFactory {
     private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
     private static final File ppt = getFileAndCheck(slTests, "SampleShow.ppt");
     private static final File pptx = getFileAndCheck(slTests, "SampleShow.pptx");
+    private static final File ppt97 = getFileAndCheck(slTests, "bug56240.ppt");
     private static final File txt = getFileAndCheck(slTests, "SampleShow.txt");
 
     private static final POIDataSamples olTests = POIDataSamples.getHSMFInstance();
@@ -126,6 +127,7 @@ public class TestExtractorFactory {
             Arguments.of("Word 6", doc6, "Word6Extractor", 20),
             Arguments.of("Word 95", doc95, "Word6Extractor", 120),
             Arguments.of("PowerPoint", ppt, "SlideShowExtractor", 120),
+            Arguments.of("PowerPoint 97 Dual", ppt97, "SlideShowExtractor", 120),
             Arguments.of("Visio", vsd, "VisioTextExtractor", 50),
             Arguments.of("Publisher", pub, "PublisherTextExtractor", 50),
             Arguments.of("Outlook msg", msg, "OutlookTextExtractor", 50)
index dfc09b2f7e60c8e7a30cb8f87eac3eebc4f18ecf..40904fe718c909653c8f3b6e0a57c547bc2889c1 100644 (file)
@@ -100,7 +100,7 @@ public class OLE2ScratchpadExtractorFactory implements ExtractorProvider {
                 }
             }
 
-            if (poifsDir.hasEntry(HSLFSlideShow.POWERPOINT_DOCUMENT)) {
+            if (poifsDir.hasEntry(HSLFSlideShow.POWERPOINT_DOCUMENT) || poifsDir.hasEntry(HSLFSlideShow.PP97_DOCUMENT)) {
                 return new SlideShowExtractor<>((HSLFSlideShow)SlideShowFactory.create(poifsDir));
             }
 
index 63e9b6910157d7481ded262dbdece159d8f542d0..9e8d255798ae14cbcf444928d8cc917c89d7e415 100644 (file)
@@ -78,6 +78,7 @@ public final class HSLFSlideShow extends POIDocument implements SlideShow<HSLFSh
 
        /** Powerpoint document entry/stream name */
     public static final String POWERPOINT_DOCUMENT = "PowerPoint Document";
+       public static final String PP97_DOCUMENT = "PP97_DUALSTORAGE";
        public static final String PP95_DOCUMENT = "PP40";
 
     enum LoadSavePhase {
index 264dcb0b4df14ff07e73ef121d8fb7d722aa3f9a..c5a43fff8763490a2549a69924eb4d286df73c51 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel;
 
 import static org.apache.poi.hslf.usermodel.HSLFSlideShow.POWERPOINT_DOCUMENT;
 import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT;
+import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP97_DOCUMENT;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -74,8 +75,6 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
     //arbitrarily selected; may need to increase
     private static final int MAX_RECORD_LENGTH = 200_000_000;
 
-    private static final String DUAL_STORAGE_NAME = "PP97_DUALSTORAGE";
-
     // Holds metadata on where things are in our document
     private CurrentUserAtom currentUser;
 
@@ -163,10 +162,10 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
 
     private static DirectoryNode handleDualStorage(DirectoryNode dir) throws IOException {
         // when there's a dual storage entry, use it, as the outer document can't be read quite probably ...
-        if (!dir.hasEntry(DUAL_STORAGE_NAME)) {
+        if (!dir.hasEntry(PP97_DOCUMENT)) {
             return dir;
         }
-        return (DirectoryNode) dir.getEntry(DUAL_STORAGE_NAME);
+        return (DirectoryNode) dir.getEntry(PP97_DOCUMENT);
     }
 
     /**
@@ -831,7 +830,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
         // only close the filesystem, if we are based on the root node.
         // embedded documents/slideshows shouldn't close the parent container
         if (getDirectory().getParent() == null ||
-                getDirectory().getName().equals(DUAL_STORAGE_NAME)) {
+            PP97_DOCUMENT.equals(getDirectory().getName())) {
             POIFSFileSystem fs = getDirectory().getFileSystem();
             if (fs != null) {
                 fs.close();
diff --git a/test-data/integration/stress001.docx b/test-data/integration/stress001.docx
new file mode 100644 (file)
index 0000000..4be44a6
Binary files /dev/null and b/test-data/integration/stress001.docx differ
diff --git a/test-data/integration/stress002.xlsx b/test-data/integration/stress002.xlsx
new file mode 100644 (file)
index 0000000..9428f84
Binary files /dev/null and b/test-data/integration/stress002.xlsx differ
diff --git a/test-data/integration/stress003.docx b/test-data/integration/stress003.docx
new file mode 100644 (file)
index 0000000..100917b
Binary files /dev/null and b/test-data/integration/stress003.docx differ
diff --git a/test-data/integration/stress004.docx b/test-data/integration/stress004.docx
new file mode 100644 (file)
index 0000000..8997b02
Binary files /dev/null and b/test-data/integration/stress004.docx differ
diff --git a/test-data/integration/stress005.docx b/test-data/integration/stress005.docx
new file mode 100644 (file)
index 0000000..56f9f1a
Binary files /dev/null and b/test-data/integration/stress005.docx differ
diff --git a/test-data/integration/stress006.docx b/test-data/integration/stress006.docx
new file mode 100644 (file)
index 0000000..765846e
Binary files /dev/null and b/test-data/integration/stress006.docx differ
diff --git a/test-data/integration/stress007.docx b/test-data/integration/stress007.docx
new file mode 100644 (file)
index 0000000..5eb9df6
Binary files /dev/null and b/test-data/integration/stress007.docx differ
diff --git a/test-data/integration/stress008.docx b/test-data/integration/stress008.docx
new file mode 100644 (file)
index 0000000..6a9c5d3
Binary files /dev/null and b/test-data/integration/stress008.docx differ
diff --git a/test-data/integration/stress009.docx b/test-data/integration/stress009.docx
new file mode 100644 (file)
index 0000000..f811dd7
Binary files /dev/null and b/test-data/integration/stress009.docx differ
diff --git a/test-data/integration/stress010.docx b/test-data/integration/stress010.docx
new file mode 100644 (file)
index 0000000..5ffdbda
Binary files /dev/null and b/test-data/integration/stress010.docx differ
diff --git a/test-data/integration/stress011.docx b/test-data/integration/stress011.docx
new file mode 100644 (file)
index 0000000..46b098d
Binary files /dev/null and b/test-data/integration/stress011.docx differ
diff --git a/test-data/integration/stress012.docx b/test-data/integration/stress012.docx
new file mode 100644 (file)
index 0000000..7146047
Binary files /dev/null and b/test-data/integration/stress012.docx differ
diff --git a/test-data/integration/stress013.pptx b/test-data/integration/stress013.pptx
new file mode 100644 (file)
index 0000000..574ba55
Binary files /dev/null and b/test-data/integration/stress013.pptx differ
diff --git a/test-data/integration/stress014.docx b/test-data/integration/stress014.docx
new file mode 100644 (file)
index 0000000..3250313
Binary files /dev/null and b/test-data/integration/stress014.docx differ
diff --git a/test-data/integration/stress015.docx b/test-data/integration/stress015.docx
new file mode 100644 (file)
index 0000000..8853d48
Binary files /dev/null and b/test-data/integration/stress015.docx differ
diff --git a/test-data/integration/stress016.docx b/test-data/integration/stress016.docx
new file mode 100644 (file)
index 0000000..f65f2d0
Binary files /dev/null and b/test-data/integration/stress016.docx differ
diff --git a/test-data/integration/stress017.docx b/test-data/integration/stress017.docx
new file mode 100644 (file)
index 0000000..1f39b2c
Binary files /dev/null and b/test-data/integration/stress017.docx differ
diff --git a/test-data/integration/stress018.docx b/test-data/integration/stress018.docx
new file mode 100644 (file)
index 0000000..10f30e4
Binary files /dev/null and b/test-data/integration/stress018.docx differ
diff --git a/test-data/integration/stress019.docx b/test-data/integration/stress019.docx
new file mode 100644 (file)
index 0000000..420ad1d
Binary files /dev/null and b/test-data/integration/stress019.docx differ
diff --git a/test-data/integration/stress020.xlsx b/test-data/integration/stress020.xlsx
new file mode 100644 (file)
index 0000000..8ed54cf
Binary files /dev/null and b/test-data/integration/stress020.xlsx differ