diff --git a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java index 8c94027459..aaa1173c7c 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Stream; +import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.tools.ant.DirectoryScanner; import org.junit.jupiter.api.function.Executable; @@ -71,7 +72,15 @@ import org.opentest4j.AssertionFailedError; @Execution(ExecutionMode.CONCURRENT) public class TestAllFiles { private static final String DEFAULT_TEST_DATA_PATH = "test-data"; - public static final File ROOT_DIR = new File(System.getProperty("POI.testdata.path", DEFAULT_TEST_DATA_PATH)); + public static final File ROOT_DIR; + static { + File dir = new File(System.getProperty(POIDataSamples.TEST_PROPERTY, DEFAULT_TEST_DATA_PATH)); + if (!dir.exists()) { + dir = new File(System.getProperty(POIDataSamples.TEST_PROPERTY, "../" + DEFAULT_TEST_DATA_PATH)); + } + + ROOT_DIR = dir; + } public static final String[] SCAN_EXCLUDES = { "**/.svn/**", diff --git a/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestTriggerCoverage.java b/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestTriggerCoverage.java index c2bf7aa2f0..8ce0ae9692 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestTriggerCoverage.java +++ b/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestTriggerCoverage.java @@ -70,6 +70,10 @@ class TestTriggerCoverage { dataDirName = "test-data"; } + if (!new File(dataDirName).exists()) { + dataDirName = "../test-data"; + } + List files = new ArrayList<>(); findFile(files, dataDirName + "/integration"); diff --git a/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java b/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java index 065fe6a70a..5ec8a30b23 100644 --- a/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java +++ b/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java @@ -50,7 +50,8 @@ public abstract class BaseTestIteratingXLS { }; public Stream files() { - String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY, "test-data"); + String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY, + new File("test-data").exists() ? "test-data" : "../test-data"); DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(dataDirName); diff --git a/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java b/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java index 90bd30c3c5..6b99428aea 100644 --- a/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java +++ b/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.stream.Stream; import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; +import org.apache.poi.POIDataSamples; import org.apache.poi.ddf.DefaultEscherRecordFactory; import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherDggRecord; @@ -127,7 +128,12 @@ class TestDrawingAggregate { } public static Stream samples() { - File testData = new File(System.getProperty("POI.testdata.path"), "spreadsheet"); + String property = System.getProperty(POIDataSamples.TEST_PROPERTY, "test-data"); + File testData = new File(property, "spreadsheet"); + if (!testData.exists()) { + testData = new File("../" + property, "spreadsheet"); + } + File[] files = testData.listFiles((dir, name) -> name.endsWith(".xls")); assertNotNull(files, "Need to find files in test-data path, had path: " + testData); return Stream.of(files).map(Arguments::of);