diff --git a/.classpath b/.classpath
index 58ae07b0f8..bc01351d8d 100644
--- a/.classpath
+++ b/.classpath
@@ -14,6 +14,7 @@
+
diff --git a/build.xml b/build.xml
index 00d7829805..ec4e65bb2a 100644
--- a/build.xml
+++ b/build.xml
@@ -122,6 +122,12 @@ under the License.
+
+
+
+
+
+
@@ -285,6 +291,14 @@ under the License.
+
+
+
+
+
+
+
+
@@ -369,6 +383,8 @@ under the License.
+
+
@@ -788,6 +804,28 @@ under the License.
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1036,6 +1074,45 @@ under the License.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1503,7 +1580,7 @@ under the License.
-
+
diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java
new file mode 100644
index 0000000000..b2bc251f83
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/TestAllFiles.java
@@ -0,0 +1,278 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi;
+
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.poi.stress.*;
+import org.apache.tools.ant.DirectoryScanner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This is an integration test which performs various actions on all stored test-files and tries
+ * to reveal problems which are introduced, but not covered (yet) by unit tests.
+ *
+ * This test looks for any file under the test-data directory and tries to do some useful
+ * processing with it based on it's type.
+ *
+ * The test is implemented as a junit {@link Parameterized} test, which leads
+ * to one test-method call for each file (currently around 950 files are handled).
+ *
+ * There is a a mapping of extension to implementations of the interface
+ * {@link FileHandler} which defines how the file is loaded and which actions are
+ * tried with the file.
+ *
+ * The test can be expanded by adding more actions to the FileHandlers, this automatically
+ * applies the action to any such file in our test-data repository.
+ *
+ * There is also a list of files that should actually fail.
+ *
+ * Note: It is also a test-failure if a file that is expected to fail now actually works,
+ * i.e. if a bug was fixed in POI itself, the file should be removed from the expected-failures
+ * here as well! This is to ensure that files that should not work really do not work, e.g.
+ * that we do not remove expected sanity checks.
+ */
+@RunWith(Parameterized.class)
+public class TestAllFiles {
+ // map file extensions to the actual mappers
+ private static final Map HANDLERS = new HashMap();
+ static {
+ // Excel
+ HANDLERS.put(".xls", new HSSFFileHandler());
+ HANDLERS.put(".xlsx", new XSSFFileHandler());
+ HANDLERS.put(".xlsm", new XSSFFileHandler());
+ HANDLERS.put(".xltx", new XSSFFileHandler());
+ HANDLERS.put(".xlsb", new XSSFFileHandler());
+
+ // Word
+ HANDLERS.put(".doc", new HWPFFileHandler());
+ HANDLERS.put(".docx", new XWPFFileHandler());
+ HANDLERS.put(".dotx", new XWPFFileHandler());
+ HANDLERS.put(".docm", new XWPFFileHandler());
+ HANDLERS.put(".ooxml", new XWPFFileHandler()); // OPCPackage
+
+ // Powerpoint
+ HANDLERS.put(".ppt", new HSLFFileHandler());
+ HANDLERS.put(".pptx", new XSLFFileHandler());
+ HANDLERS.put(".pptm", new XSLFFileHandler());
+ HANDLERS.put(".ppsm", new XSLFFileHandler());
+ HANDLERS.put(".ppsx", new XSLFFileHandler());
+ HANDLERS.put(".thmx", new XSLFFileHandler());
+
+ // Outlook
+ HANDLERS.put(".msg", new HSMFFileHandler());
+
+ // Publisher
+ HANDLERS.put(".pub", new HPBFFileHandler());
+
+ // Visio
+ HANDLERS.put(".vsd", new HDGFFileHandler());
+
+ // POIFS
+ HANDLERS.put(".ole2", new POIFSFileHandler());
+
+ // Microsoft Admin Template?
+ HANDLERS.put(".adm", new HPSFFileHandler());
+
+ // Microsoft TNEF
+ HANDLERS.put(".dat", new HMEFFileHandler());
+
+ // TODO: are these readable by some of the formats?
+ HANDLERS.put(".shw", new NullFileHandler());
+ HANDLERS.put(".zvi", new NullFileHandler());
+ HANDLERS.put(".mpp", new NullFileHandler());
+ HANDLERS.put(".qwp", new NullFileHandler());
+ HANDLERS.put(".wps", new NullFileHandler());
+ HANDLERS.put(".bin", new NullFileHandler());
+ HANDLERS.put(".xps", new NullFileHandler());
+ HANDLERS.put(".sldprt", new NullFileHandler());
+ HANDLERS.put(".mdb", new NullFileHandler());
+ HANDLERS.put(".vml", new NullFileHandler());
+
+ // ignore some file types, images, other formats, ...
+ HANDLERS.put(".txt", new NullFileHandler());
+ HANDLERS.put(".pdf", new NullFileHandler());
+ HANDLERS.put(".rtf", new NullFileHandler());
+ HANDLERS.put(".gif", new NullFileHandler());
+ HANDLERS.put(".html", new NullFileHandler());
+ HANDLERS.put(".png", new NullFileHandler());
+ HANDLERS.put(".wmf", new NullFileHandler());
+ HANDLERS.put(".emf", new NullFileHandler());
+ HANDLERS.put(".dib", new NullFileHandler());
+ HANDLERS.put(".svg", new NullFileHandler());
+ HANDLERS.put(".pict", new NullFileHandler());
+ HANDLERS.put(".jpg", new NullFileHandler());
+ HANDLERS.put(".wav", new NullFileHandler());
+ HANDLERS.put(".pfx", new NullFileHandler());
+ HANDLERS.put(".xml", new NullFileHandler());
+
+ // map some files without extension
+ HANDLERS.put("spreadsheet/BigSSTRecord", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR1", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR2", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR3", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR4", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR5", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR6", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecord2CR7", new NullFileHandler());
+ HANDLERS.put("spreadsheet/BigSSTRecordCR", new NullFileHandler());
+ HANDLERS.put("spreadsheet/test_properties1", new NullFileHandler());
+ }
+
+ private static final Set EXPECTED_FAILURES = new HashSet();
+ static {
+ // password protected files
+ EXPECTED_FAILURES.add("poifs/protect.xlsx");
+ EXPECTED_FAILURES.add("spreadsheet/password.xls");
+ EXPECTED_FAILURES.add("spreadsheet/51832.xls");
+ EXPECTED_FAILURES.add("document/PasswordProtected.doc");
+ EXPECTED_FAILURES.add("slideshow/Password_Protected-hello.ppt");
+ EXPECTED_FAILURES.add("slideshow/Password_Protected-56-hello.ppt");
+ EXPECTED_FAILURES.add("slideshow/Password_Protected-np-hello.ppt");
+ EXPECTED_FAILURES.add("slideshow/cryptoapi-proc2356.ppt");
+ EXPECTED_FAILURES.add("document/bug53475-password-is-pass.docx");
+ EXPECTED_FAILURES.add("document/bug53475-password-is-solrcell.docx");
+ EXPECTED_FAILURES.add("spreadsheet/xor-encryption-abc.xls");
+ EXPECTED_FAILURES.add("spreadsheet/35897-type4.xls");
+
+ // TODO: fails XMLExportTest, is this ok?
+ EXPECTED_FAILURES.add("spreadsheet/CustomXMLMapping-singleattributenamespace.xlsx");
+ EXPECTED_FAILURES.add("spreadsheet/55864.xlsx");
+
+ // TODO: these fail now with some NPE/file read error because we now try to compute every value via Cell.toString()!
+ EXPECTED_FAILURES.add("spreadsheet/44958.xls");
+ EXPECTED_FAILURES.add("spreadsheet/44958_1.xls");
+ EXPECTED_FAILURES.add("spreadsheet/testArraysAndTables.xls");
+
+ // TODO: good to ignore?
+ EXPECTED_FAILURES.add("spreadsheet/sample-beta.xlsx");
+ EXPECTED_FAILURES.add("spreadsheet/49931.xls");
+ EXPECTED_FAILURES.add("poifs/protected_sha512.xlsx");
+ EXPECTED_FAILURES.add("poifs/extenxls_pwd123.xlsx");
+ EXPECTED_FAILURES.add("openxml4j/ContentTypeHasParameters.ooxml");
+
+ // This is actually a spreadsheet!
+ EXPECTED_FAILURES.add("hpsf/TestRobert_Flaherty.doc");
+
+ // some files that are broken, Excel 5.0/95, Word 95, ...
+ EXPECTED_FAILURES.add("poifs/protected_agile.docx");
+ EXPECTED_FAILURES.add("spreadsheet/43493.xls");
+ EXPECTED_FAILURES.add("spreadsheet/46904.xls");
+ EXPECTED_FAILURES.add("document/56880.doc");
+ EXPECTED_FAILURES.add("document/Bug49933.doc");
+ EXPECTED_FAILURES.add("document/Bug50955.doc");
+ EXPECTED_FAILURES.add("document/Bug51944.doc");
+ EXPECTED_FAILURES.add("document/Word6.doc");
+ EXPECTED_FAILURES.add("document/Word6_sections.doc");
+ EXPECTED_FAILURES.add("document/Word6_sections2.doc");
+ EXPECTED_FAILURES.add("document/Word95.doc");
+ EXPECTED_FAILURES.add("document/word95err.doc");
+ EXPECTED_FAILURES.add("hpsf/TestMickey.doc");
+ EXPECTED_FAILURES.add("slideshow/PPT95.ppt");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_DCTermsNamespaceLimitedUseFAIL.docx");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_DoNotUseCompatibilityMarkupFAIL.docx");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_LimitedXSITypeAttribute_NotPresentFAIL.docx");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_LimitedXSITypeAttribute_PresentWithUnauthorizedValueFAIL.docx");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_OnlyOneCorePropertiesPartFAIL.docx");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_UnauthorizedXMLLangAttributeFAIL.docx");
+ EXPECTED_FAILURES.add("openxml4j/OPCCompliance_DerivedPartNameFAIL.docx");
+ EXPECTED_FAILURES.add("spreadsheet/54764-2.xlsx"); // see TestXSSFBugs.bug54764()
+ EXPECTED_FAILURES.add("spreadsheet/54764.xlsx"); // see TestXSSFBugs.bug54764()
+ EXPECTED_FAILURES.add("spreadsheet/Simple.xlsb");
+ EXPECTED_FAILURES.add("spreadsheet/testEXCEL_4.xls");
+ EXPECTED_FAILURES.add("spreadsheet/testEXCEL_5.xls");
+ EXPECTED_FAILURES.add("spreadsheet/testEXCEL_95.xls");
+
+ // non-TNEF files
+ EXPECTED_FAILURES.add("ddf/Container.dat");
+ EXPECTED_FAILURES.add("ddf/47143.dat");
+ }
+
+ @Parameters(name="{index}: {0} using {1}")
+ public static Iterable files() {
+ DirectoryScanner scanner = new DirectoryScanner();
+ scanner.setBasedir(new File("test-data"));
+
+ scanner.scan();
+
+ System.out.println("Handling " + scanner.getIncludedFiles().length + " files");
+
+ List files = new ArrayList();
+ for(String file : scanner.getIncludedFiles()) {
+ files.add(new Object[] { file, HANDLERS.get(getExtension(file)) });
+ }
+
+ return files;
+ }
+
+ @Parameter(value=0)
+ public String file;
+
+ @Parameter(value=1)
+ public FileHandler handler;
+
+ @Test
+ public void testAllFiles() throws Exception {
+ assertNotNull("Unknown file extension for file: " + file + ": " + getExtension(file), handler);
+ InputStream stream = new FileInputStream(new File("test-data", file));
+ try {
+ handler.handleFile(stream);
+
+ assertFalse("Expected to fail for file " + file + " and handler " + handler + ", but did not fail!",
+ EXPECTED_FAILURES.contains(file));
+ } catch (Exception e) {
+ // check if we expect failure for this file
+ if(!EXPECTED_FAILURES.contains(file)) {
+ throw new Exception("While handling " + file, e);
+ }
+ } finally {
+ stream.close();
+ }
+ }
+
+ private static String getExtension(String file) {
+ int pos = file.lastIndexOf('.');
+ if(pos == -1 || pos == file.length()-1) {
+ return file;
+ }
+
+ return file.substring(pos);
+ }
+
+ private static class NullFileHandler implements FileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java b/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java
new file mode 100644
index 0000000000..acc8b97cd2
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java
@@ -0,0 +1,77 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hssf.usermodel;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.poi.hssf.record.Record;
+import org.junit.Test;
+
+/**
+ * Needs to be implemented in this package to have access to
+ * HSSFWorkbook.getWorkbook()
+ */
+public class RecordsStresser {
+ public static void handleWorkbook(HSSFWorkbook wb) {
+ List records = wb.getWorkbook().getRecords();
+ for(Record record : records) {
+ // some Records do not implement clone ?!
+ // equals instead of instanceof is on purpose here to only skip exactly this class and not any derived ones
+// if(record.getClass().equals(InterfaceHdrRecord.class) ||
+// record.getClass().equals(MMSRecord.class) ||
+// record.getClass().equals(InterfaceEndRecord.class) ||
+// record.getClass().equals(WriteAccessRecord.class) ||
+// record.getClass().equals(CodepageRecord.class) ||
+// record.getClass().equals(DSFRecord.class)) {
+// continue;
+// }
+ try {
+ Record newRecord = (Record) record.clone();
+
+ assertEquals("Expecting the same class back from clone(), but had Record of type " + record.getClass() + " and got back a " + newRecord.getClass() + " from clone()",
+ record.getClass(), newRecord.getClass());
+
+ byte[] origBytes = record.serialize();
+ byte[] newBytes = newRecord.serialize();
+
+ assertArrayEquals("Record of type " + record.getClass() + " should return the same byte array via the clone() method, but did return a different array",
+ origBytes, newBytes);
+ } catch (RuntimeException e) {
+ // some Records do not implement clone, ignore those for now
+ assertTrue(e.getMessage().contains("needs to define a clone method"));
+ }
+ }
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/spreadsheet/15556.xls");
+ try {
+ HSSFWorkbook wb = new HSSFWorkbook(stream);
+ handleWorkbook(wb);
+ } finally {
+ stream.close();
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/FileHandler.java b/src/integrationtest/org/apache/poi/stress/FileHandler.java
new file mode 100644
index 0000000000..e6f3385f02
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/FileHandler.java
@@ -0,0 +1,37 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import java.io.InputStream;
+
+/**
+ * Base interface for the various file types that are
+ * used in the stress testing.
+ */
+public interface FileHandler {
+ /**
+ * The FileHandler receives a stream ready for reading the
+ * file and should handle the content that is provided and
+ * try to read and interpret the data.
+ *
+ * Closing is handled by the framework outside this call.
+ *
+ * @param stream
+ * @throws Exception
+ */
+ void handleFile(InputStream stream) throws Exception;
+}
diff --git a/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java
new file mode 100644
index 0000000000..7fac6647a3
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java
@@ -0,0 +1,58 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hdgf.HDGFDiagram;
+import org.apache.poi.hdgf.streams.Stream;
+import org.apache.poi.hdgf.streams.TrailerStream;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.Test;
+
+public class HDGFFileHandler extends POIFSFileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HDGFDiagram diagram = new HDGFDiagram(new POIFSFileSystem(stream));
+ Stream[] topLevelStreams = diagram.getTopLevelStreams();
+ assertNotNull(topLevelStreams);
+ for(Stream str : topLevelStreams) {
+ assertTrue(str.getPointer().getLength() >= 0);
+ }
+
+ TrailerStream trailerStream = diagram.getTrailerStream();
+ assertNotNull(trailerStream);
+ assertTrue(trailerStream.getPointer().getLength() >= 0);
+
+ // writing is not yet implemented... handlePOIDocument(diagram);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/diagram/44501.vsd");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java
new file mode 100644
index 0000000000..dfa8750058
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java
@@ -0,0 +1,60 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hmef.HMEFMessage;
+import org.apache.poi.hmef.attribute.MAPIAttribute;
+import org.apache.poi.hmef.attribute.MAPIStringAttribute;
+import org.junit.Test;
+
+public class HMEFFileHandler implements FileHandler {
+
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HMEFMessage msg = new HMEFMessage(stream);
+
+ // list all properties
+ StringBuilder props = new StringBuilder();
+ for(MAPIAttribute att : msg.getMessageMAPIAttributes()) {
+ props.append(att.getType()).append(": ").append(MAPIStringAttribute.getAsString( att)).append("\n");
+ }
+
+ // there are two test-files that have no body...
+ if(!msg.getSubject().equals("Testing TNEF Message") && !msg.getSubject().equals("TNEF test message with attachments")) {
+ assertNotNull("Had: " + msg.getBody() + ", " + msg.getSubject() + ", " + msg.getAttachments() + ": " + props.toString(),
+ msg.getBody());
+ }
+ assertNotNull("Had: " + msg.getBody() + ", " + msg.getSubject() + ", " + msg.getAttachments() + ": " + props.toString(),
+ msg.getSubject());
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/hmef/quick-winmail.dat");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java
new file mode 100644
index 0000000000..31ad8bc123
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java
@@ -0,0 +1,49 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hpbf.HPBFDocument;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.Test;
+
+public class HPBFFileHandler extends POIFSFileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HPBFDocument pub = new HPBFDocument(new POIFSFileSystem(stream));
+ assertNotNull(pub.getEscherDelayStm());
+ assertNotNull(pub.getMainContents());
+ assertNotNull(pub.getQuillContents());
+
+ // writing is not yet implemented... handlePOIDocument(pub);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/publisher/SampleBrochure.pub");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
new file mode 100644
index 0000000000..b7d846ae62
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
@@ -0,0 +1,46 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.Test;
+
+public class HPSFFileHandler implements FileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HPSFPropertiesOnlyDocument hpsf = new HPSFPropertiesOnlyDocument(new POIFSFileSystem(stream));
+ assertNotNull(hpsf.getDocumentSummaryInformation());
+ assertNotNull(hpsf.getSummaryInformation());
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/hpsf/Test0313rur.adm");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java
new file mode 100644
index 0000000000..51e54f6eb2
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java
@@ -0,0 +1,56 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.record.Record;
+import org.junit.Test;
+
+public class HSLFFileHandler extends POIFSFileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HSLFSlideShow slide = new HSLFSlideShow(stream);
+ assertNotNull(slide.getCurrentUserAtom());
+ assertNotNull(slide.getEmbeddedObjects());
+ assertNotNull(slide.getUnderlyingBytes());
+ assertNotNull(slide.getPictures());
+ Record[] records = slide.getRecords();
+ assertNotNull(records);
+ for(Record record : records) {
+ assertTrue(record.getRecordType() >= 0);
+ }
+
+ handlePOIDocument(slide);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/hpsf/Test_Humor-Generation.ppt");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java
new file mode 100644
index 0000000000..9de8b798c5
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java
@@ -0,0 +1,69 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hsmf.MAPIMessage;
+import org.junit.Test;
+
+public class HSMFFileHandler extends POIFSFileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ MAPIMessage mapi = new MAPIMessage(stream);
+ assertNotNull(mapi.getAttachmentFiles());
+ assertNotNull(mapi.getDisplayBCC());
+ assertNotNull(mapi.getMessageDate());
+
+ /* => Writing isn't yet supported...
+ // write out the file
+ File file = TempFile.createTempFile("StressTest", ".msg");
+ writeToFile(mapi, file);
+
+ MAPIMessage read = new MAPIMessage(file.getAbsolutePath());
+ assertNotNull(read.getAttachmentFiles());
+ assertNotNull(read.getDisplayBCC());
+ assertNotNull(read.getMessageDate());
+ */
+
+ // writing is not yet supported... handlePOIDocument(mapi);
+ }
+
+// private void writeToFile(MAPIMessage mapi, File file)
+// throws FileNotFoundException, IOException {
+// OutputStream stream = new FileOutputStream(file);
+// try {
+// mapi.write(stream);
+// } finally {
+// stream.close();
+// }
+// }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/hsmf/example_received_regular.msg");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java
new file mode 100644
index 0000000000..19dbd97a0e
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java
@@ -0,0 +1,52 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.junit.Test;
+
+public class HSSFFileHandler extends SpreadsheetHandler {
+ private POIFSFileHandler delegate = new POIFSFileHandler();
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HSSFWorkbook wb = new HSSFWorkbook(stream);
+ handleWorkbook(wb, ".xls");
+
+ // TODO: some documents fail currently...
+ //HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
+ //evaluator.evaluateAll();
+
+ delegate.handlePOIDocument(wb);
+
+ // also try to see if some of the Records behave incorrectly
+ // TODO: still fails on some records... RecordsStresser.handleWorkbook(wb);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/spreadsheet/49219.xls");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java
new file mode 100644
index 0000000000..1b6d4646c7
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java
@@ -0,0 +1,48 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.hwpf.HWPFDocument;
+import org.junit.Test;
+
+public class HWPFFileHandler extends POIFSFileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ HWPFDocument doc = new HWPFDocument(stream);
+ assertNotNull(doc.getBookmarks());
+ assertNotNull(doc.getCharacterTable());
+ assertNotNull(doc.getEndnotes());
+
+ handlePOIDocument(doc);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/document/HeaderFooterUnicode.doc");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java b/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java
new file mode 100644
index 0000000000..31deac7106
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java
@@ -0,0 +1,49 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.poi.POIDocument;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+
+public class POIFSFileHandler implements FileHandler {
+
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ POIFSFileSystem fs = new POIFSFileSystem(stream);
+ handlePOIFSFileSystem(fs);
+ }
+
+ private void handlePOIFSFileSystem(POIFSFileSystem fs) {
+ assertNotNull(fs);
+ assertNotNull(fs.getRoot());
+ }
+
+ protected void handlePOIDocument(POIDocument doc) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ doc.write(out);
+
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+ POIFSFileSystem fs = new POIFSFileSystem(in);
+ handlePOIFSFileSystem(fs);
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java b/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
new file mode 100644
index 0000000000..f28a85b529
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
@@ -0,0 +1,31 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.poi.POIXMLDocument;
+
+public final class POIXMLDocumentHandler {
+ protected void handlePOIXMLDocument(POIXMLDocument doc) throws Exception {
+ assertNotNull(doc.getAllEmbedds());
+ assertNotNull(doc.getPackage());
+ assertNotNull(doc.getPackagePart());
+ assertNotNull(doc.getProperties());
+ assertNotNull(doc.getRelations());
+ }
+}
diff --git a/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java b/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java
new file mode 100644
index 0000000000..aad703ce98
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/SpreadsheetHandler.java
@@ -0,0 +1,86 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+
+public abstract class SpreadsheetHandler implements FileHandler {
+ public void handleWorkbook(Workbook wb, String extension) throws IOException {
+ // try to access some of the content
+ readContent(wb);
+
+ // write out the file
+ ByteArrayOutputStream out = writeToArray(wb);
+
+ // access some more content (we had cases where writing corrupts the data in memory)
+ readContent(wb);
+
+ // write once more
+ out = writeToArray(wb);
+
+ // read in the writen file
+ Workbook read;
+ try {
+ read = WorkbookFactory.create(new ByteArrayInputStream(out.toByteArray()));
+ } catch (InvalidFormatException e) {
+ throw new IllegalStateException(e);
+ }
+ assertNotNull(read);
+
+ readContent(read);
+ }
+
+ private ByteArrayOutputStream writeToArray(Workbook wb)
+ throws FileNotFoundException, IOException {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ try {
+ wb.write(stream);
+ } finally {
+ stream.close();
+ }
+
+ return stream;
+ }
+
+ private void readContent(Workbook wb) {
+ for(int i = 0;i < wb.getNumberOfSheets();i++) {
+ Sheet sheet = wb.getSheetAt(i);
+ assertNotNull(wb.getSheet(sheet.getSheetName()));
+ sheet.groupColumn((short) 4, (short) 5);
+ sheet.setColumnGroupCollapsed(4, true);
+ sheet.setColumnGroupCollapsed(4, false);
+
+ for(Row row : sheet) {
+ for(Cell cell : row) {
+ cell.toString();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java
new file mode 100644
index 0000000000..bcdff84992
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java
@@ -0,0 +1,49 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.xslf.XSLFSlideShow;
+import org.junit.Test;
+
+public class XSLFFileHandler implements FileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ XSLFSlideShow slide = new XSLFSlideShow(OPCPackage.open(stream));
+ assertNotNull(slide.getPresentation());
+ assertNotNull(slide.getSlideMasterReferences());
+ assertNotNull(slide.getSlideReferences());
+
+ new POIXMLDocumentHandler().handlePOIXMLDocument(slide);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/slideshow/testPPT.pptx");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
new file mode 100644
index 0000000000..701fdcdaaa
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
@@ -0,0 +1,71 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.poi.xssf.extractor.XSSFExportToXml;
+import org.apache.poi.xssf.usermodel.XSSFMap;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+public class XSSFFileHandler extends SpreadsheetHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ XSSFWorkbook wb = new XSSFWorkbook(stream);
+
+ // use the combined handler for HSSF/XSSF
+ handleWorkbook(wb, ".xlsx");
+
+ // TODO: some documents fail currently...
+ //XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb);
+ //evaluator.evaluateAll();
+
+ // also verify general POIFS-stuff
+ new POIXMLDocumentHandler().handlePOIXMLDocument(wb);
+
+ // and finally ensure that exporting to XML works
+ exportToXML(wb);
+ }
+
+ private void exportToXML(XSSFWorkbook wb) throws SAXException,
+ ParserConfigurationException, TransformerException {
+ for (XSSFMap map : wb.getCustomXMLMappings()) {
+ XSSFExportToXml exporter = new XSSFExportToXml(map);
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ exporter.exportToXML(os, true);
+ }
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/spreadsheet/WithConditionalFormatting.xlsx");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
new file mode 100644
index 0000000000..358009a2f0
--- /dev/null
+++ b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
@@ -0,0 +1,44 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.junit.Test;
+
+public class XWPFFileHandler implements FileHandler {
+ @Override
+ public void handleFile(InputStream stream) throws Exception {
+ XWPFDocument doc = new XWPFDocument(stream);
+
+ new POIXMLDocumentHandler().handlePOIXMLDocument(doc);
+ }
+
+ // a test-case to test this locally without executing the full TestAllFiles
+ @Test
+ public void test() throws Exception {
+ InputStream stream = new FileInputStream("test-data/document/footnotes.docx");
+ try {
+ handleFile(stream);
+ } finally {
+ stream.close();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
index d0e118ae20..ccc883dd30 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
@@ -213,6 +213,19 @@ public final class TestXSSFExportToXML extends TestCase {
assertTrue(found);
}
+ public void testExportToXMLSingleAttributeNamespace() throws Exception {
+ // TODO: Fails, but I don't know if it is ok or not...
+
+// XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMapping-singleattributenamespace.xlsx");
+//
+// for (XSSFMap map : wb.getCustomXMLMappings()) {
+// XSSFExportToXml exporter = new XSSFExportToXml(map);
+//
+// ByteArrayOutputStream os = new ByteArrayOutputStream();
+// exporter.exportToXML(os, true);
+// }
+ }
+
public void test55850ComplexXmlExport() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java
index a6fc85e4d4..c3730bc043 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java
@@ -32,8 +32,13 @@ public class TestEFBiffViewer extends BaseXLSIteratingTest {
SILENT_EXCLUDED.add("51832.xls"); // password
SILENT_EXCLUDED.add("xor-encryption-abc.xls"); // password, ty again later!
SILENT_EXCLUDED.add("43493.xls"); // HSSFWorkbook cannot open it as well
+ SILENT_EXCLUDED.add("44958_1.xls"); // known bad file
SILENT_EXCLUDED.add("46904.xls"); // Exception, too old
SILENT_EXCLUDED.add("47251_1.xls"); // Broken test file
+ SILENT_EXCLUDED.add("testEXCEL_4.xls"); // old unsupported format
+ SILENT_EXCLUDED.add("testEXCEL_5.xls"); // old unsupported format
+ SILENT_EXCLUDED.add("testEXCEL_95.xls"); // old unsupported format
+ SILENT_EXCLUDED.add("35897-type4.xls"); // unsupported encryption
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
index cc124f449a..d42af8858f 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
@@ -37,6 +37,7 @@ public class TestReSave extends BaseXLSIteratingTest {
SILENT_EXCLUDED.add("43493.xls"); // HSSFWorkbook cannot open it as well
SILENT_EXCLUDED.add("46904.xls");
SILENT_EXCLUDED.add("51832.xls"); // password
+ SILENT_EXCLUDED.add("44958_1.xls"); // known bad file
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
index 7b101affeb..b6a535347a 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
@@ -24,6 +24,10 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.RecordFormatException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
/**
* @author aviks
@@ -74,4 +78,48 @@ public final class TestUnfixedBugs extends TestCase {
// Problem 3 - fixed and transfered
}
+
+ public void testFormulaRecordAggregate_1() throws Exception {
+ // fails at formula "=MEHRFACH.OPERATIONEN(E$3;$B$5;$D4)"
+ Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958_1.xls");
+ for(int i = 0;i < wb.getNumberOfSheets();i++) {
+ Sheet sheet = wb.getSheetAt(i);
+ assertNotNull(wb.getSheet(sheet.getSheetName()));
+ sheet.groupColumn((short) 4, (short) 5);
+ sheet.setColumnGroupCollapsed(4, true);
+ sheet.setColumnGroupCollapsed(4, false);
+
+ for(Row row : sheet) {
+ for(Cell cell : row) {
+ try {
+ cell.toString();
+ } catch (Exception e) {
+ throw new Exception("While handling: " + sheet.getSheetName() + "/" + row.getRowNum() + "/" + cell.getColumnIndex(), e);
+ }
+ }
+ }
+ }
+ }
+
+ public void testFormulaRecordAggregate() throws Exception {
+ // fails at formula "=MEHRFACH.OPERATIONEN(E$3;$B$5;$D4)"
+ Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958.xls");
+ for(int i = 0;i < wb.getNumberOfSheets();i++) {
+ Sheet sheet = wb.getSheetAt(i);
+ assertNotNull(wb.getSheet(sheet.getSheetName()));
+ sheet.groupColumn((short) 4, (short) 5);
+ sheet.setColumnGroupCollapsed(4, true);
+ sheet.setColumnGroupCollapsed(4, false);
+
+ for(Row row : sheet) {
+ for(Cell cell : row) {
+ try {
+ cell.toString();
+ } catch (Exception e) {
+ throw new Exception("While handling: " + sheet.getSheetName() + "/" + row.getRowNum() + "/" + cell.getColumnIndex(), e);
+ }
+ }
+ }
+ }
+ }
}
diff --git a/test-data/spreadsheet/44958_1.xls b/test-data/spreadsheet/44958_1.xls
new file mode 100644
index 0000000000..c407c2f10b
Binary files /dev/null and b/test-data/spreadsheet/44958_1.xls differ