When using the IDE to run tests in one of the
sub-modules uses the poi-* sub-directory, so
looking for the test-data in ../test-data is
useful to make executing tests work out-of-the-box
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@
1903103 13f79535-47bb-0310-9956-
ffa450edef68
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;
@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/**",
dataDirName = "test-data";
}
+ if (!new File(dataDirName).exists()) {
+ dataDirName = "../test-data";
+ }
+
List<Arguments> files = new ArrayList<>();
findFile(files, dataDirName + "/integration");
};
public Stream<Arguments> 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);
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;
}
public static Stream<Arguments> 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);