From aa1c9c85833e617e2fa458fbb622be51747de55c Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Thu, 27 May 2010 12:27:19 +0000 Subject: [PATCH] better test format handling git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@470 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/JetFormatTest.java | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java b/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java index d2e3267..44c5544 100644 --- a/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; import java.nio.channels.FileChannel; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.Set; @@ -53,13 +54,32 @@ public class JetFormatTest extends TestCase { public String toString() { return _basename; } } - /** Defines currently supported db file formats. */ - final static FileFormat[] SUPPORTED_FILEFORMATS = - new FileFormat[] { - FileFormat.V2000, - FileFormat.V2003, - FileFormat.V2007, - }; + /** Defines currently supported db file formats. (can be modified at + runtime via the system property + "com.healthmarketscience.jackcess.testFormats") */ + final static FileFormat[] SUPPORTED_FILEFORMATS; + + static { + String testFormatStr = System.getProperty("com.healthmarketscience.jackcess.testFormats"); + Set testFormats = EnumSet.allOf(FileFormat.class); + if((testFormatStr != null) && (testFormatStr.length() > 0)) { + testFormats.clear(); + for(String tmp : testFormatStr.split(",")) { + testFormats.add(FileFormat.valueOf(tmp.toUpperCase())); + } + } + + List supported = new ArrayList(); + for(FileFormat ff : Arrays.asList(FileFormat.V2000, FileFormat.V2003, + FileFormat.V2007)) { + if(!testFormats.contains(ff)) { + continue; + } + supported.add(ff); + } + + SUPPORTED_FILEFORMATS = supported.toArray(new FileFormat[0]); + } /** * Defines known valid test database files, and their jet format version. @@ -94,20 +114,8 @@ public class JetFormatTest extends TestCase { public static List getSupportedForBasename(Basename basename) { - String testFormatStr = System.getProperty("com.healthmarketscience.jackcess.testFormats"); - Set testFormats = EnumSet.allOf(FileFormat.class); - if((testFormatStr != null) && (testFormatStr.length() > 0)) { - testFormats = EnumSet.noneOf(FileFormat.class); - for(String tmp : testFormatStr.split(",")) { - testFormats.add(FileFormat.valueOf(tmp.toUpperCase())); - } - } - List supportedTestDBs = new ArrayList(); for (FileFormat fileFormat : SUPPORTED_FILEFORMATS) { - if(!testFormats.contains(fileFormat)) { - continue; - } supportedTestDBs.add(new TestDB( getFileForBasename(basename, fileFormat), fileFormat)); -- 2.39.5