aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-08-24 08:53:01 +0000
committerDominik Stadler <centic@apache.org>2023-08-24 08:53:01 +0000
commit29990737157a4af2e2462252a44db665671e2a6e (patch)
tree6c786386001dd094b690e5fa100372f5919fd509 /poi-ooxml
parentcdb2ba13989badf60d88c75daf69c94ae6ac2e13 (diff)
downloadpoi-29990737157a4af2e2462252a44db665671e2a6e.tar.gz
poi-29990737157a4af2e2462252a44db665671e2a6e.zip
Apply some IDE suggestions, add tests, set unit-test to isolated
Without Isolation, one test did change static settings and thus could cause flaky tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911891 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/openxml4j/TestOPCPackageFileLimit.java2
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestReadOnlySharedStringsTable.java6
2 files changed, 8 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/openxml4j/TestOPCPackageFileLimit.java b/poi-ooxml/src/test/java/org/apache/poi/openxml4j/TestOPCPackageFileLimit.java
index 017de0a10e..02f81ccd51 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/openxml4j/TestOPCPackageFileLimit.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/openxml4j/TestOPCPackageFileLimit.java
@@ -22,6 +22,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Isolated;
import java.io.File;
import java.io.IOException;
@@ -30,6 +31,7 @@ import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+@Isolated // changes static values, so other tests should not run at the same time
class TestOPCPackageFileLimit {
@Test
void testWithReducedFileLimit() throws InvalidFormatException {
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestReadOnlySharedStringsTable.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestReadOnlySharedStringsTable.java
index be486270ed..220963db79 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestReadOnlySharedStringsTable.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestReadOnlySharedStringsTable.java
@@ -67,6 +67,12 @@ public final class TestReadOnlySharedStringsTable {
assertEquals(i1.getString(), rtbl.getItemAt(i).getString());
assertEquals(i1.getString(), rtbl2.getItemAt(i).getString());
}
+
+ // verify invalid indices
+ assertThrows(IllegalStateException.class,
+ () -> rtbl.getItemAt(stbl.getUniqueCount()));
+ assertThrows(IndexOutOfBoundsException.class,
+ () -> rtbl.getItemAt(-1));
}
}
}