From 29990737157a4af2e2462252a44db665671e2a6e Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Thu, 24 Aug 2023 08:53:01 +0000 Subject: 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 --- .../test/java/org/apache/poi/openxml4j/TestOPCPackageFileLimit.java | 2 ++ .../poi/xssf/eventusermodel/TestReadOnlySharedStringsTable.java | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'poi-ooxml') 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)); } } } -- cgit v1.2.3