aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2024-04-17 18:50:32 +0000
committerDominik Stadler <centic@apache.org>2024-04-17 18:50:32 +0000
commit4a3b92b305ad7a0c6e8a38d3567e2a86a330bae0 (patch)
tree190cadd0b0ef6dd0c12567f64552fce1ee6f7347 /poi-ooxml
parent9453fa908ae9a0c9a602725f4d5e1d6994b2b3f3 (diff)
downloadpoi-4a3b92b305ad7a0c6e8a38d3567e2a86a330bae0.tar.gz
poi-4a3b92b305ad7a0c6e8a38d3567e2a86a330bae0.zip
Comment out flaky assertion and add more information to find which file fails in CI
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917072 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java b/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
index b4f6fe09a0..be86baed3b 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java
@@ -20,6 +20,7 @@ import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.extractor.ExtractorFactory.createExtractor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -178,11 +179,14 @@ class TestExtractorFactory {
assertNotNull(ext);
testExtractor(ext, testcase, extractor, count);
pkg.revert();
+ } catch (Exception e) {
+ throw new Exception("While handling " + testcase + " - " + testFile + " - " + extractor);
}
}
@Test
void testFileInvalid() {
+ //noinspection resource
IOException ex = assertThrows(IOException.class, () -> createExtractor(txt));
assertEquals("Can't create extractor - unsupported file type: UNKNOWN", ex.getMessage());
}
@@ -198,6 +202,7 @@ class TestExtractorFactory {
@Test
void testPOIFSInvalid() {
// Not really an Extractor test, but we'll leave it to test POIFS reaction anyway ...
+ //noinspection resource
IOException ex = assertThrows(IOException.class, () -> new POIFSFileSystem(txt));
assertTrue(ex.getMessage().contains("Invalid header signature; read 0x3D20726F68747541, expected 0xE11AB1A1E011CFD0"));
}
@@ -205,6 +210,7 @@ class TestExtractorFactory {
@Test
void testPackageInvalid() {
// Text
+ //noinspection resource
assertThrows(NotOfficeXmlFileException.class, () -> OPCPackage.open(txt, PackageAccess.READ));
}
@@ -235,12 +241,12 @@ class TestExtractorFactory {
try {
// Check we get the right extractors now
try (POITextExtractor extractor = createExtractor(new POIFSFileSystem(new FileInputStream(xls)))) {
- assertTrue(extractor instanceof EventBasedExcelExtractor);
+ assertInstanceOf(EventBasedExcelExtractor.class, extractor);
assertTrue(extractor.getText().length() > 200);
}
try (POITextExtractor extractor = xmlFactory.create(OPCPackage.open(xlsx.toString(), PackageAccess.READ))) {
assertNotNull(extractor);
- assertTrue(extractor instanceof XSSFEventBasedExcelExtractor);
+ assertInstanceOf(XSSFEventBasedExcelExtractor.class, extractor);
assertTrue(extractor.getText().length() > 200);
}
} finally {
@@ -254,12 +260,12 @@ class TestExtractorFactory {
// And back
try (POITextExtractor extractor = createExtractor(new POIFSFileSystem(new FileInputStream(xls)))) {
- assertTrue(extractor instanceof ExcelExtractor);
+ assertInstanceOf(ExcelExtractor.class, extractor);
assertTrue(extractor.getText().length() > 200);
}
try (POITextExtractor extractor = xmlFactory.create(OPCPackage.open(xlsx.toString(), PackageAccess.READ))) {
- assertTrue(extractor instanceof XSSFExcelExtractor);
+ assertInstanceOf(XSSFExcelExtractor.class, extractor);
}
try (POITextExtractor extractor = xmlFactory.create(OPCPackage.open(xlsx.toString()))) {
@@ -319,8 +325,6 @@ class TestExtractorFactory {
final String actual = embeds.length+"-"+numWord+"-"+numXls+"-"+numPpt+"-"+numMsg+"-"+numWordX;
assertEquals(expected, actual, "invalid number of embeddings - "+format);
}
-
-
}
@ParameterizedTest
@@ -410,6 +414,7 @@ class TestExtractorFactory {
// run a number of files that might fail in order to catch
// leaked file resources when using file-leak-detector while
// running the test
+ //noinspection resource
assertThrows(Exception.class, () -> ex(file));
}