diff --git a/build.xml b/build.xml
index 54537d17fd..b95d541ddb 100644
--- a/build.xml
+++ b/build.xml
@@ -208,10 +208,20 @@ under the License.
@{artifact}
-
+
+
+
+ @{artifact}
+
+
+
+
+
+
+
@@ -225,13 +235,23 @@ under the License.
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -250,50 +270,50 @@ under the License.
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
-
-
+
+
-
-
-
+
-
+
-
-
-
+
+
+
-
+
@@ -332,23 +352,30 @@ under the License.
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+
@@ -560,29 +587,9 @@ under the License.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -694,12 +701,15 @@ under the License.
+
-
+
+
+
@@ -712,7 +722,9 @@ under the License.
-
+
+
+
@@ -2475,15 +2487,14 @@ under the License.
-
-
+
-
-
+
+
@@ -2592,7 +2603,9 @@ under the License.
-
+
+
+
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
index 7f9692ecdc..9fd9b96bd6 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
@@ -119,6 +119,7 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+import org.apache.poi.util.Removal;
/**
* High level representation of a workbook. This is the first object most users
@@ -1151,7 +1152,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
public HSSFFont createFont() {
/*FontRecord font =*/
workbook.createNewFont();
- int fontindex = getNumberOfFontsAsInt() - 1;
+ int fontindex = getNumberOfFonts() - 1;
if (fontindex > 3) {
fontindex++; // THERE IS NO FOUR!!
@@ -1172,7 +1173,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
public HSSFFont findFont(boolean bold, short color, short fontHeight,
String name, boolean italic, boolean strikeout,
short typeOffset, byte underline) {
- int numberOfFonts = getNumberOfFontsAsInt();
+ int numberOfFonts = getNumberOfFonts();
for (int i = 0; i <= numberOfFonts; i++) {
// Remember - there is no 4!
if (i == 4) {
@@ -1202,6 +1203,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
@Override
@Deprecated
+ @Removal(version="6.0.0")
public int getNumberOfFontsAsInt() {
return getNumberOfFonts();
}
diff --git a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
index 5f31274439..076eafd03c 100644
--- a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
+++ b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
@@ -260,7 +260,7 @@ public final class AnalysisToolPak implements UDFFinder {
}
FreeRefFunction f = inst.findFunction(name);
if(f != null && !(f instanceof NotImplemented)) {
- throw new IllegalArgumentException("POI already implememts " + name +
+ throw new IllegalArgumentException("POI already implements " + name +
". You cannot override POI's implementations of Excel functions");
}
diff --git a/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java b/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java
index ad034e1a67..da670439a9 100644
--- a/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java
+++ b/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java
@@ -189,7 +189,7 @@ public final class FunctionEval {
retval[FunctionID.INDIRECT] = null; // Indirect.evaluate has different signature
retval[162] = TextFunction.CLEAN;
-
+
retval[163] = MatrixFunction.MDETERM;
retval[164] = MatrixFunction.MINVERSE;
retval[165] = MatrixFunction.MMULT;
@@ -394,7 +394,7 @@ public final class FunctionEval {
if(functions[idx] instanceof NotImplementedFunction) {
functions[idx] = func;
} else {
- throw new IllegalArgumentException("POI already implememts " + name +
+ throw new IllegalArgumentException("POI already implements " + name +
". You cannot override POI's implementations of Excel functions");
}
}
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
index 60b9e26e67..5e1ee2fbe4 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
@@ -299,7 +299,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
* and will be missing from the c14n resulting nodes.
*/
Canonicalizer c14n = Canonicalizer.getInstance(c14nAlgoId);
- c14nValue.write(c14n.canonicalizeSubtree(node));
+ c14n.canonicalizeSubtree(node, c14nValue);
}
} catch (RuntimeException e) {
throw e;
diff --git a/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java b/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
index 3e570e2b51..1a4940c051 100644
--- a/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
+++ b/src/ooxml/testcases/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -42,14 +43,11 @@ import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.poifs.filesystem.FileMagic;
-import org.apache.poi.poifs.filesystem.NotOLE2FileException;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
import org.apache.xmlbeans.XmlException;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
/**
* Test that the extractor factory plays nicely
@@ -129,9 +127,6 @@ public class TestExtractorFactory {
R apply(T t) throws IOException, OpenXML4JException, XmlException;
}
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void testFile() throws Exception {
for (int i = 0; i < TEST_SET.length; i += 4) {
@@ -142,11 +137,12 @@ public class TestExtractorFactory {
}
@Test
- public void testFileInvalid() throws Exception {
- thrown.expectMessage("Can't create extractor - unsupported file type: UNKNOWN");
- thrown.expect(IOException.class);
- // Text
- ExtractorFactory.createExtractor(txt);
+ public void testFileInvalid() {
+ IOException ex = assertThrows(
+ IOException.class,
+ () -> ExtractorFactory.createExtractor(txt)
+ );
+ assertEquals("Can't create extractor - unsupported file type: UNKNOWN", ex.getMessage());
}
@Test
@@ -155,10 +151,11 @@ public class TestExtractorFactory {
}
@Test
- public void testInputStreamInvalid() throws Exception {
- thrown.expectMessage("Can't create extractor - unsupported file type: UNKNOWN");
- thrown.expect(IOException.class);
- testInvalid(ExtractorFactory::createExtractor);
+ public void testInputStreamInvalid() throws IOException {
+ try (FileInputStream fis = new FileInputStream(txt)) {
+ IOException ex = assertThrows(IOException.class, () -> ExtractorFactory.createExtractor(fis));
+ assertTrue(ex.getMessage().contains(FileMagic.UNKNOWN.name()));
+ }
}
@Test
@@ -167,10 +164,12 @@ public class TestExtractorFactory {
}
@Test
- public void testPOIFSInvalid() throws Exception {
- thrown.expectMessage("Invalid header signature; read 0x3D20726F68747541, expected 0xE11AB1A1E011CFD0");
- thrown.expect(NotOLE2FileException.class);
- testInvalid((f) -> ExtractorFactory.createExtractor(new POIFSFileSystem(f)));
+ public void testPOIFSInvalid() {
+ IOException ex = assertThrows(
+ IOException.class,
+ () -> ExtractorFactory.createExtractor(new POIFSFileSystem(txt))
+ );
+ assertTrue(ex.getMessage().contains("Invalid header signature; read 0x3D20726F68747541, expected 0xE11AB1A1E011CFD0"));
}
private void testStream(final FunctionEx poifsIS, final boolean loadOOXML)
@@ -199,17 +198,6 @@ public class TestExtractorFactory {
}
}
- private void testInvalid(FunctionEx poifs) throws IOException, OpenXML4JException, XmlException {
- // Text
- try (FileInputStream fis = new FileInputStream(txt);
- POITextExtractor ignored = poifs.apply(fis)) {
- fail("extracting from invalid package");
- } catch (IllegalArgumentException e) {
- assertTrue("Had: " + e, e.getMessage().contains(FileMagic.UNKNOWN.name()));
- throw e;
- }
- }
-
@Test
public void testPackage() throws Exception {
for (int i = 0; i < TEST_SET.length; i += 4) {
@@ -273,6 +261,7 @@ public class TestExtractorFactory {
}
try (POITextExtractor extractor = xmlFactory.create(OPCPackage.open(xlsx.toString(), PackageAccess.READ))) {
+ assertNotNull(extractor);
assertTrue(extractor.getText().length() > 200);
}
} finally {
@@ -296,6 +285,7 @@ public class TestExtractorFactory {
assertTrue(extractor instanceof XSSFExcelExtractor);
}
try (POITextExtractor extractor = xmlFactory.create(OPCPackage.open(xlsx.toString()))) {
+ assertNotNull(extractor);
assertTrue(extractor.getText().length() > 200);
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
index 3858bc688d..4995fcb2ef 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
@@ -19,6 +19,7 @@ package org.apache.poi.openxml4j.opc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -29,9 +30,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.internal.ContentType;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
/**
* Tests for content type (ContentType class).
@@ -40,9 +39,6 @@ public final class TestContentType {
private static final String FEATURE_DISALLOW_DOCTYPE_DECL = "http://apache.org/xml/features/disallow-doctype-decl";
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
/**
* Check rule M1.13: Package implementers shall only create and only
* recognize parts with a content type; format designers shall specify a
@@ -158,12 +154,13 @@ public final class TestContentType {
*/
@Test
public void testFileWithContentTypeEntities() throws Exception {
- if (!isOldXercesActive()) {
- exception.expect(InvalidFormatException.class);
+ try (InputStream is = OpenXML4JTestDataSamples.openSampleStream("ContentTypeHasEntities.ooxml")) {
+ if (isOldXercesActive()) {
+ OPCPackage.open(is);
+ } else {
+ assertThrows(InvalidFormatException.class, () -> OPCPackage.open(is));
+ }
}
-
- InputStream is = OpenXML4JTestDataSamples.openSampleStream("ContentTypeHasEntities.ooxml");
- OPCPackage.open(is);
}
/**
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
index d8fc1b7b84..5f95abd1ca 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
@@ -22,11 +22,11 @@ import static org.apache.poi.openxml4j.OpenXML4JTestDataSamples.getSampleFile;
import static org.apache.poi.openxml4j.OpenXML4JTestDataSamples.getSampleFileName;
import static org.apache.poi.openxml4j.OpenXML4JTestDataSamples.openSampleStream;
import static org.apache.poi.openxml4j.opc.PackagingURIHelper.createPartName;
-import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -50,6 +50,7 @@ import java.util.List;
import java.util.TreeMap;
import java.util.function.BiConsumer;
import java.util.regex.Pattern;
+import java.util.stream.Stream;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
@@ -88,13 +89,9 @@ import org.apache.poi.xssf.usermodel.XSSFRelation;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.XWPFRelation;
import org.apache.xmlbeans.XmlException;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-import org.hamcrest.core.AllOf;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.function.ThrowingRunnable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -107,9 +104,6 @@ public final class TestPackage {
private static final String CONTENT_EXT_PROPS = "application/vnd.openxmlformats-officedocument.extended-properties+xml";
private static final POIDataSamples xlsSamples = POIDataSamples.getSpreadSheetInstance();
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
/**
* Test that just opening and closing the file doesn't alter the document.
*/
@@ -645,115 +639,46 @@ public final class TestPackage {
}
}
-
@Test
- public void NonOOXML_OLE2Stream() throws Exception {
- expectedEx.expect(OLE2NotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("The supplied data appears to be in the OLE2 Format"),
- containsString("You are calling the part of POI that deals with OOXML")
- ));
- try (InputStream stream = xlsSamples.openResourceAsStream("SampleSS.xls");
- OPCPackage p = OPCPackage.open(stream)) {
- assertNotNull(p);
- fail("Shouldn't be able to open OLE2");
+ public void NonOOXML_File() throws Exception {
+ handleNonOOXML(
+ "SampleSS.xls", OLE2NotOfficeXmlFileException.class,
+ "The supplied data appears to be in the OLE2 Format",
+ "You are calling the part of POI that deals with OOXML"
+ );
+
+ handleNonOOXML(
+ "SampleSS.xml", NotOfficeXmlFileException.class,
+ "The supplied data appears to be a raw XML file",
+ "Formats such as Office 2003 XML"
+ );
+
+ handleNonOOXML(
+ "SampleSS.ods", ODFNotOfficeXmlFileException.class,
+ "The supplied data appears to be in ODF",
+ "Formats like these (eg ODS"
+ );
+
+ handleNonOOXML(
+ "SampleSS.txt", NotOfficeXmlFileException.class,
+ "No valid entries or contents found",
+ "not a valid OOXML"
+ );
+ }
+
+ private void handleNonOOXML(String file, Class extends UnsupportedFileFormatException> exception, String... messageParts) throws IOException {
+ try (InputStream stream = xlsSamples.openResourceAsStream(file)) {
+ ThrowingRunnable[] trs = {
+ () -> OPCPackage.open(stream),
+ () -> OPCPackage.open(xlsSamples.getFile(file))
+ };
+ for (ThrowingRunnable tr : trs) {
+ Exception ex = assertThrows("Shouldn't be able to open "+file, exception, tr);
+ Stream.of(messageParts).forEach(mp -> assertTrue(ex.getMessage().contains(mp)));
+ }
}
}
- @Test
- public void NonOOXML_OLE2File() throws Exception {
- expectedEx.expect(OLE2NotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("The supplied data appears to be in the OLE2 Format"),
- containsString("You are calling the part of POI that deals with OOXML")
- ));
- try (OPCPackage p = OPCPackage.open(xlsSamples.getFile("SampleSS.xls"))) {
- assertNotNull(p);
- fail("Shouldn't be able to open OLE2");
- }
- }
-
- @Test
- public void NonOOXML_RawXmlStream() throws Exception {
- expectedEx.expect(NotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("The supplied data appears to be a raw XML file"),
- containsString("Formats such as Office 2003 XML")
- ));
- try (InputStream stream = xlsSamples.openResourceAsStream("SampleSS.xml");
- OPCPackage p = OPCPackage.open(stream)) {
- assertNotNull(p);
- fail("Shouldn't be able to open XML");
- }
- }
-
- @Test
- public void NonOOXML_RawXmlFile() throws Exception {
- expectedEx.expect(NotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("The supplied data appears to be a raw XML file"),
- containsString("Formats such as Office 2003 XML")
- ));
- try (OPCPackage p = OPCPackage.open(xlsSamples.getFile("SampleSS.xml"))) {
- assertNotNull(p);
- fail("Shouldn't be able to open XML");
- }
- }
-
- @Test
- public void NonOOXML_ODFStream() throws Exception {
- expectedEx.expect(ODFNotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("The supplied data appears to be in ODF"),
- containsString("Formats like these (eg ODS")
- ));
- try (InputStream stream = xlsSamples.openResourceAsStream("SampleSS.ods");
- OPCPackage p = OPCPackage.open(stream)) {
- assertNotNull(p);
- fail("Shouldn't be able to open ODS");
- }
- }
-
- @Test
- public void NonOOXML_ODFFile() throws Exception {
- expectedEx.expect(ODFNotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("The supplied data appears to be in ODF"),
- containsString("Formats like these (eg ODS")
- ));
- try (OPCPackage p = OPCPackage.open(xlsSamples.getFile("SampleSS.ods"))) {
- assertNotNull(p);
- fail("Shouldn't be able to open ODS");
- }
- }
-
- @Test
- public void NonOOXML_TextStream() throws Exception {
- expectedEx.expect(NotOfficeXmlFileException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("No valid entries or contents found"),
- containsString("not a valid OOXML")
- ));
- try (InputStream stream = xlsSamples.openResourceAsStream("SampleSS.txt");
- OPCPackage p = OPCPackage.open(stream)) {
- assertNotNull(p);
- fail("Shouldn't be able to open Plain Text");
- }
- }
-
- @Test
- public void NonOOXML_TextFile() throws Exception {
- // Unhelpful low-level error, sorry
- expectedEx.expect(UnsupportedFileFormatException.class);
- expectedEx.expectMessage(AllOf.allOf(
- containsString("No valid entries or contents found"),
- containsString("not a valid OOXML")
- ));
- try (OPCPackage p = OPCPackage.open(xlsSamples.getFile("SampleSS.txt"))) {
- assertNotNull(p);
- fail("Shouldn't be able to open Plain Text");
- }
- }
/**
* Zip bomb handling test
@@ -805,29 +730,32 @@ public final class TestPackage {
}
}
- expectedEx.expect(IOException.class);
- expectedEx.expectMessage("Zip bomb detected!");
-
- try (Workbook wb = WorkbookFactory.create(new ByteArrayInputStream(bos.toByteArray()))) {
- wb.getSheetAt(0);
- }
+ IOException ex = assertThrows(
+ IOException.class,
+ () -> WorkbookFactory.create(new ByteArrayInputStream(bos.toByteArray()))
+ );
+ assertTrue(ex.getMessage().contains("Zip bomb detected!"));
}
@Test
- public void testZipEntityExpansionTerminates() throws IOException, OpenXML4JException, XmlException {
- expectedEx.expect(IllegalStateException.class);
- expectedEx.expectMessage("The text would exceed the max allowed overall size of extracted text.");
- openXmlBombFile("poc-shared-strings.xlsx");
+ public void testZipEntityExpansionTerminates() {
+ IllegalStateException ex = assertThrows(
+ IllegalStateException.class,
+ () -> openXmlBombFile("poc-shared-strings.xlsx")
+ );
+ assertTrue(ex.getMessage().contains("The text would exceed the max allowed overall size of extracted text."));
}
@Test
- public void testZipEntityExpansionSharedStringTableEvents() throws IOException, OpenXML4JException, XmlException {
+ public void testZipEntityExpansionSharedStringTableEvents() {
boolean before = ExtractorFactory.getThreadPrefersEventExtractors();
ExtractorFactory.setThreadPrefersEventExtractors(true);
try {
- expectedEx.expect(IllegalStateException.class);
- expectedEx.expectMessage("The text would exceed the max allowed overall size of extracted text.");
- openXmlBombFile("poc-shared-strings.xlsx");
+ IllegalStateException ex = assertThrows(
+ IllegalStateException.class,
+ () -> openXmlBombFile("poc-shared-strings.xlsx")
+ );
+ assertTrue(ex.getMessage().contains("The text would exceed the max allowed overall size of extracted text."));
} finally {
ExtractorFactory.setThreadPrefersEventExtractors(before);
}
@@ -835,19 +763,33 @@ public final class TestPackage {
@Test
- public void testZipEntityExpansionExceedsMemory() throws IOException, OpenXML4JException, XmlException {
- expectedEx.expect(IOException.class);
- expectedEx.expectMessage("unable to parse shared strings table");
- expectedEx.expectCause(getCauseMatcher(SAXParseException.class, "The parser has encountered more than"));
- openXmlBombFile("poc-xmlbomb.xlsx");
+ public void testZipEntityExpansionExceedsMemory() {
+ IOException ex = assertThrows(
+ IOException.class,
+ () -> openXmlBombFile("poc-xmlbomb.xlsx")
+ );
+ assertTrue(ex.getMessage().contains("unable to parse shared strings table"));
+ assertTrue(matchSAXEx(ex));
}
@Test
- public void testZipEntityExpansionExceedsMemory2() throws IOException, OpenXML4JException, XmlException {
- expectedEx.expect(IOException.class);
- expectedEx.expectMessage("unable to parse shared strings table");
- expectedEx.expectCause(getCauseMatcher(SAXParseException.class, "The parser has encountered more than"));
- openXmlBombFile("poc-xmlbomb-empty.xlsx");
+ public void testZipEntityExpansionExceedsMemory2() {
+ IOException ex = assertThrows(
+ IOException.class,
+ () -> openXmlBombFile("poc-xmlbomb-empty.xlsx")
+ );
+ assertTrue(ex.getMessage().contains("unable to parse shared strings table"));
+ assertTrue(matchSAXEx(ex));
+ }
+
+ private static boolean matchSAXEx(Exception root) {
+ for (Throwable t = root; t != null; t = t.getCause()) {
+ if (t.getClass().isAssignableFrom(SAXParseException.class) &&
+ t.getMessage().contains("The parser has encountered more than")) {
+ return true;
+ }
+ }
+ return false;
}
private void openXmlBombFile(String file) throws IOException, OpenXML4JException, XmlException {
@@ -873,24 +815,28 @@ public final class TestPackage {
}
@Test
- public void zipBombCheckSizesRatioTooSmall() throws IOException, EncryptedDocumentException {
- expectedEx.expect(POIXMLException.class);
- expectedEx.expectMessage("You can adjust this limit via ZipSecureFile.setMinInflateRatio()");
- getZipStatsAndConsume((max_size, min_ratio) -> {
- // check ratio out of bounds
- ZipSecureFile.setMinInflateRatio(min_ratio+0.002);
- });
+ public void zipBombCheckSizesRatioTooSmall() {
+ POIXMLException ex = assertThrows(
+ POIXMLException.class,
+ () -> getZipStatsAndConsume((max_size, min_ratio) -> {
+ // check ratio out of bounds
+ ZipSecureFile.setMinInflateRatio(min_ratio+0.002);
+ })
+ );
+ assertTrue(ex.getMessage().contains("You can adjust this limit via ZipSecureFile.setMinInflateRatio()"));
}
@Test
public void zipBombCheckSizesSizeTooBig() throws IOException, EncryptedDocumentException {
- expectedEx.expect(POIXMLException.class);
- expectedEx.expectMessage("You can adjust this limit via ZipSecureFile.setMaxEntrySize()");
- getZipStatsAndConsume((max_size, min_ratio) -> {
- // check max entry size ouf of bounds
- ZipSecureFile.setMinInflateRatio(min_ratio-0.002);
- ZipSecureFile.setMaxEntrySize(max_size-200);
- });
+ POIXMLException ex = assertThrows(
+ POIXMLException.class,
+ () -> getZipStatsAndConsume((max_size, min_ratio) -> {
+ // check max entry size ouf of bounds
+ ZipSecureFile.setMinInflateRatio(min_ratio-0.002);
+ ZipSecureFile.setMaxEntrySize(max_size-200);
+ })
+ );
+ assertTrue(ex.getMessage().contains("You can adjust this limit via ZipSecureFile.setMaxEntrySize()"));
}
private void getZipStatsAndConsume(BiConsumer ratioCon) throws IOException {
@@ -1121,42 +1067,6 @@ public final class TestPackage {
}
}
- @SuppressWarnings("SameParameterValue")
- private static AnyCauseMatcher getCauseMatcher(Class cause, String message) {
- // junit is only using hamcrest-core, so instead of adding hamcrest-beans, we provide the throwable
- // search with the basics...
- // see https://stackoverflow.com/a/47703937/2066598
- return new AnyCauseMatcher<>(cause, message);
- }
-
- private static class AnyCauseMatcher extends TypeSafeMatcher {
- private final Class expectedType;
- private final String expectedMessage;
-
- AnyCauseMatcher(Class expectedType, String expectedMessage) {
- this.expectedType = expectedType;
- this.expectedMessage = expectedMessage;
- }
-
- @Override
- protected boolean matchesSafely(final Throwable root) {
- for (Throwable t = root; t != null; t = t.getCause()) {
- if (t.getClass().isAssignableFrom(expectedType) && t.getMessage().contains(expectedMessage)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("expects type ")
- .appendValue(expectedType)
- .appendText(" and a message ")
- .appendValue(expectedMessage);
- }
- }
-
@SuppressWarnings("UnstableApiUsage")
@Test
public void testBug63029() throws Exception {
diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
index a4e977c148..988024907a 100644
--- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
+++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
@@ -145,9 +145,7 @@ import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.w3.x2000.x09.xmldsig.ReferenceType;
import org.w3.x2000.x09.xmldsig.SignatureDocument;
import org.w3c.dom.Document;
@@ -160,9 +158,6 @@ public class TestSignatureInfo {
private KeyPair keyPair;
private X509Certificate x509;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@AfterClass
public static void removeUserLocale() {
LocaleUtil.resetUserLocale();
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShowFactory.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShowFactory.java
index b02995fcdd..b4fb08fef0 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShowFactory.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShowFactory.java
@@ -17,6 +17,10 @@
package org.apache.poi.xslf.usermodel;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -33,30 +37,25 @@ import org.apache.poi.sl.usermodel.BaseTestSlideShowFactory;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.TempFile;
import org.junit.Test;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
public final class TestXSLFSlideShowFactory extends BaseTestSlideShowFactory {
- private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
private static final String filename = "SampleShow.pptx";
private static final String password = "opensesame";
private static final String removeExpectedExceptionMsg =
"This functionality this unit test is trying to test is now passing. " +
"The unit test needs to be updated by deleting the expected exception code. Status and close any related bugs.";
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
- public void testFactoryFromFile() throws Exception {
+ public void testFactoryFromFile() {
// Remove thrown.* when bug 58779 is resolved
// In the mean time, this function will modify SampleShow.pptx on disk.
- thrown.expect(AssertionError.class);
- // thrown.expectCause(Matcher);
- thrown.expectMessage("SampleShow.pptx sample file was modified as a result of closing the slideshow");
- thrown.reportMissingExceptionWithMessage("Bug 58779: " + removeExpectedExceptionMsg);
-
- testFactoryFromFile(filename);
+ AssertionError ex = assertThrows(
+ "Bug 58779: " + removeExpectedExceptionMsg,
+ AssertionError.class,
+ () -> testFactoryFromFile(filename)
+ );
+ assertTrue(ex.getMessage().contains("SampleShow.pptx sample file was modified as a result of closing the slideshow"));
}
@Test
@@ -65,13 +64,14 @@ public final class TestXSLFSlideShowFactory extends BaseTestSlideShowFactory {
}
@Test
- public void testFactoryFromNative() throws Exception {
+ public void testFactoryFromNative() {
// Remove thrown.* when unit test for XSLF SlideShowFactory.create(OPCPackage) is implemented
- thrown.expect(UnsupportedOperationException.class);
- thrown.expectMessage("Test not implemented");
- thrown.reportMissingExceptionWithMessage(removeExpectedExceptionMsg);
-
- testFactoryFromNative(filename);
+ UnsupportedOperationException ex = assertThrows(
+ removeExpectedExceptionMsg,
+ UnsupportedOperationException.class,
+ () -> testFactoryFromNative(filename)
+ );
+ assertEquals("Test not implemented", ex.getMessage());
}
@Test
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
index 15dcf326a0..8a3ffe433f 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
@@ -20,6 +20,7 @@
package org.apache.poi.xssf.streaming;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import java.io.IOException;
@@ -57,18 +58,16 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void cloneSheet() throws IOException {
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("Not Implemented");
- super.cloneSheet();
+ public void cloneSheet() {
+ RuntimeException ex = assertThrows(RuntimeException.class, super::cloneSheet);
+ assertEquals("Not Implemented", ex.getMessage());
}
@Override
@Test
- public void cloneSheetMultipleTimes() throws IOException {
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("Not Implemented");
- super.cloneSheetMultipleTimes();
+ public void cloneSheetMultipleTimes() {
+ RuntimeException ex = assertThrows(RuntimeException.class, super::cloneSheetMultipleTimes);
+ assertEquals("Not Implemented", ex.getMessage());
}
/**
@@ -76,10 +75,9 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void shiftMerged() throws IOException {
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("Not Implemented");
- super.shiftMerged();
+ public void shiftMerged() {
+ RuntimeException ex = assertThrows(RuntimeException.class, super::shiftMerged);
+ assertEquals("Not Implemented", ex.getMessage());
}
/**
@@ -89,15 +87,14 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void bug35084() throws IOException {
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("Not Implemented");
- super.bug35084();
+ public void bug35084() {
+ RuntimeException ex = assertThrows(RuntimeException.class, super::bug35084);
+ assertEquals("Not Implemented", ex.getMessage());
}
@Override
@Test
- public void getCellComment() throws IOException {
+ public void getCellComment() {
// TODO: reading cell comments via Sheet does not work currently as it tries
// to access the underlying sheet for this, but comments are stored as
// properties on Cells...
@@ -119,9 +116,8 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
sheet.createRow(3);
sheet.createRow(4);
- thrown.expect(Throwable.class);
- thrown.expectMessage("Attempting to write a row[1] in the range [0,1] that is already written to disk.");
- sheet.createRow(1);
+ Throwable ex = assertThrows(Throwable.class, () -> sheet.createRow(1));
+ assertEquals("Attempting to write a row[1] in the range [0,1] that is already written to disk.", ex.getMessage());
}
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java b/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java
index 91ee3a38a3..5c60d2d69b 100644
--- a/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java
+++ b/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
@@ -39,16 +40,11 @@ import org.apache.poi.hsmf.datatypes.MAPIProperty;
import org.apache.poi.hsmf.datatypes.Types;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
public final class TestHMEFMessage {
private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void testCounts() throws Exception {
HMEFMessage msg = openSample("quick-winmail.dat");
@@ -161,12 +157,13 @@ public final class TestHMEFMessage {
}
@Test
- public void testInvalidMessage() throws Exception {
+ public void testInvalidMessage() {
InputStream str = new ByteArrayInputStream(new byte[4]);
-
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("TNEF signature not detected in file, expected 574529400 but got 0");
- new HMEFMessage(str);
+ IllegalArgumentException ex = assertThrows(
+ IllegalArgumentException.class,
+ () -> new HMEFMessage(str)
+ );
+ assertEquals("TNEF signature not detected in file, expected 574529400 but got 0", ex.getMessage());
}
@Test
@@ -200,10 +197,11 @@ public final class TestHMEFMessage {
LittleEndian.putUShort(90, out);
InputStream str = new ByteArrayInputStream(out.toByteArray());
-
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Unhandled level 90");
- new HMEFMessage(str);
+ IllegalStateException ex = assertThrows(
+ IllegalStateException.class,
+ () -> new HMEFMessage(str)
+ );
+ assertEquals("Unhandled level 90", ex.getMessage());
}
@Test
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java b/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java
index 681cd46708..bdb5bba463 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/dev/BasePPTIteratingTest.java
@@ -17,6 +17,7 @@
package org.apache.poi.hslf.dev;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import java.io.File;
import java.io.PrintStream;
@@ -36,9 +37,7 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.util.NullPrintStream;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -58,9 +57,6 @@ public abstract class BasePPTIteratingTest {
ENCRYPTED_FILES.add("Password_Protected-hello.ppt");
}
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
protected static final Map> EXCLUDED =
new HashMap<>();
@@ -112,24 +108,29 @@ public abstract class BasePPTIteratingTest {
@Test
public void testAllFiles() throws Exception {
String fileName = file.getName();
+ Class extends Throwable> t = null;
if (EXCLUDED.containsKey(fileName)) {
- thrown.expect(EXCLUDED.get(fileName));
+ t = EXCLUDED.get(fileName);
+ } else if (getFailedOldFiles().contains(fileName)) {
+ t = OldPowerPointFormatException.class;
+ } else if (getFailedEncryptedFiles().contains(fileName)) {
+ t = EncryptedPowerPointFileException.class;
}
- try {
+ if (t == null) {
runOneFile(file);
- } catch (OldPowerPointFormatException e) {
- // expected for some files
- if(!OLD_FILES.contains(file.getName())) {
- throw e;
- }
- } catch (EncryptedPowerPointFileException e) {
- // expected for some files
- if(!ENCRYPTED_FILES.contains(file.getName())) {
- throw e;
- }
+ } else {
+ assertThrows(t, () -> runOneFile(file));
}
}
abstract void runOneFile(File pFile) throws Exception;
+
+ protected Set getFailedEncryptedFiles() {
+ return ENCRYPTED_FILES;
+ }
+
+ protected Set getFailedOldFiles() {
+ return OLD_FILES;
+ }
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java b/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java
index de2f7721c2..7ff2349fbd 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestPPTXMLDump.java
@@ -16,14 +16,16 @@
==================================================================== */
package org.apache.poi.hslf.dev;
+import static org.junit.Assert.assertThrows;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Set;
+
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.Test;
-import java.io.File;
-
-import static org.junit.Assert.fail;
-
public class TestPPTXMLDump extends BasePPTIteratingTest {
@Test
public void testMain() throws Exception {
@@ -34,16 +36,21 @@ public class TestPPTXMLDump extends BasePPTIteratingTest {
HSLFTestDataSamples.getSampleFile("pictures.ppt").getAbsolutePath()
});
- try {
- PPTXMLDump.main(new String[]{"invalidfile"});
- fail("Should catch exception here");
- } catch (EmptyFileException e) {
- // expected here
- }
+ assertThrows(EmptyFileException.class, () -> PPTXMLDump.main(new String[]{"invalidfile"}));
}
@Override
void runOneFile(File pFile) throws Exception {
PPTXMLDump.main(new String[]{pFile.getAbsolutePath()});
}
+
+ @Override
+ protected Set getFailedEncryptedFiles() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ protected Set getFailedOldFiles() {
+ return Collections.emptySet();
+ }
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java b/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java
index e749d7586d..9a6445e1e2 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowDumper.java
@@ -16,18 +16,19 @@
==================================================================== */
package org.apache.poi.hslf.dev;
-import org.apache.poi.EmptyFileException;
-import org.apache.poi.hslf.HSLFTestDataSamples;
-import org.apache.poi.util.IOUtils;
-import org.junit.Test;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.fail;
+import org.apache.poi.EmptyFileException;
+import org.apache.poi.hslf.HSLFTestDataSamples;
+import org.apache.poi.util.IOUtils;
+import org.junit.Test;
public class TestSlideShowDumper extends BasePPTIteratingTest {
private static final Set FAILING = new HashSet<>();
@@ -39,8 +40,6 @@ public class TestSlideShowDumper extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
- SlideShowDumper.main(new String[0]);
-
// SlideShowDumper calls IOUtils.toByteArray(is), which would fail if a different size is defined
IOUtils.setByteArrayMaxOverride(-1);
@@ -76,4 +75,14 @@ public class TestSlideShowDumper extends BasePPTIteratingTest {
}
}
}
+
+ @Override
+ protected Set getFailedEncryptedFiles() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ protected Set getFailedOldFiles() {
+ return Collections.emptySet();
+ }
}
\ No newline at end of file
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java b/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java
index 8158b5c547..dbab32a041 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/dev/TestSlideShowRecordDumper.java
@@ -16,20 +16,18 @@
==================================================================== */
package org.apache.poi.hslf.dev;
-import org.apache.poi.EmptyFileException;
-import org.apache.poi.hslf.HSLFTestDataSamples;
-import org.junit.Test;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
-import static org.junit.Assert.fail;
+import org.apache.poi.EmptyFileException;
+import org.apache.poi.hslf.HSLFTestDataSamples;
+import org.junit.Test;
public class TestSlideShowRecordDumper extends BasePPTIteratingTest {
@Test
public void testMain() throws IOException {
- SlideShowRecordDumper.main(new String[0]);
-
SlideShowRecordDumper.main(new String[] {
HSLFTestDataSamples.getSampleFile("slide_master.ppt").getAbsolutePath(),
});
diff --git a/src/testcases/org/apache/poi/POITestCase.java b/src/testcases/org/apache/poi/POITestCase.java
index bda78bcf6d..7907012cfb 100644
--- a/src/testcases/org/apache/poi/POITestCase.java
+++ b/src/testcases/org/apache/poi/POITestCase.java
@@ -22,8 +22,8 @@ import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNoException;
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
index a609ef7a26..688ea0088d 100644
--- a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
+++ b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
@@ -17,12 +17,12 @@
package org.apache.poi.hpsf.basic;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
diff --git a/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java b/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java
index 262aafdb3b..823dc4418e 100644
--- a/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java
+++ b/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java
@@ -17,9 +17,9 @@
package org.apache.poi.hssf.dev;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import java.io.File;
-import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -27,10 +27,7 @@ import java.util.Locale;
import java.util.Map;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
@@ -44,11 +41,7 @@ import org.junit.runners.Parameterized.Parameters;
*/
@RunWith(Parameterized.class)
public abstract class BaseTestIteratingXLS {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- protected static final Map> EXCLUDED =
- new HashMap<>();
+ protected static final Map> EXCLUDED = new HashMap<>();
@Parameters(name="{index}: {0}")
public static Iterable