diff --git a/Core/build.xml b/Core/build.xml index 25b415cf790446478b366d0db99103879617e537..198d6b74f863a28adfac4f88e7bdf8d28387e8d0 100644 --- a/Core/build.xml +++ b/Core/build.xml @@ -235,7 +235,7 @@ <for list="${integration-test-sys-props}" param="integration-test-sys-prop"> <sequential> <property - name="test-qa-functional-sys-prop.@{integration-test-sys-prop}" + name="test-qa-functional-sys-prop.integration-test.@{integration-test-sys-prop}" value="${integration-test.@{integration-test-sys-prop}}" /> </sequential> diff --git a/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java b/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java index 679f596cc288608d42aae754f72b64d2980cbbd6..851253aa324afd086c9cb15ab9fec77deb360cea 100644 --- a/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java +++ b/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java @@ -33,7 +33,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.logging.Level; import org.sleuthkit.autopsy.coreutils.Logger; import java.util.stream.Collectors; @@ -56,6 +55,8 @@ public class ConfigDeserializer { // A config file key must be specifed or at least the test suites path, and output path. // If a config specifying the EnvConfig json exists, specify this path to load it private static final String CONFIG_FILE_KEY = "configFile"; + // expecting properties are marked as "integration-test.propVal" + private static final String INTEGRATION_TEST_NAMESPACE = "integration-test"; /** * Deserializes the specified json file into an EnvConfig object using @@ -69,9 +70,10 @@ public class ConfigDeserializer { * validated. */ public EnvConfig getEnvConfigFromSysProps() throws IOException, IllegalStateException { - if (System.getProperty(CONFIG_FILE_KEY) != null) { + String configFileKey = String.join(".", INTEGRATION_TEST_NAMESPACE, CONFIG_FILE_KEY); + if (System.getProperty(configFileKey) != null) { // try to load from file if value is present - String fileLoc = System.getProperty(CONFIG_FILE_KEY); + String fileLoc = System.getProperty(configFileKey); File envConfigFile = new File(fileLoc); if (envConfigFile.exists()) { return getEnvConfig(envConfigFile); @@ -81,7 +83,8 @@ public EnvConfig getEnvConfigFromSysProps() throws IOException, IllegalStateExce } else { // otherwise, try to load from properties try { - return validate(null, convertToObj(getSysPropsMap(), EnvConfig.class)); + Map<String, Object> integrationProperties = getOrCreate(getSysPropsMap(), INTEGRATION_TEST_NAMESPACE); + return validate(null, convertToObj(integrationProperties, EnvConfig.class)); } catch (IllegalStateException ex) { throw new IllegalStateException("EnvConfig could not be determined from system property values", ex); } @@ -99,9 +102,8 @@ public EnvConfig getEnvConfigFromSysProps() throws IOException, IllegalStateExce private Map<String, Object> getSysPropsMap() { Map<String, Object> mapToRet = new HashMap<>(); - for (Entry<Object, Object> property : System.getProperties().entrySet()) { - String key = property.getKey().toString(); - Object value = property.getValue().toString(); + for (String key : System.getProperties().stringPropertyNames()) { + String value = System.getProperty(key); String[] keyPieces = key.split("\\."); Map<String, Object> mapToAddTo = mapToRet; @@ -117,7 +119,8 @@ private Map<String, Object> getSysPropsMap() { /** * Extends HashMap<String, Object> to guarantee a type of - * Map<String, Object> with type erasure. + * Map<String, Object> + * with type erasure. */ private static class StringObjMap extends HashMap<String, Object> { @@ -237,7 +240,9 @@ public List<TestSuiteConfig> getTestSuiteConfig(File rootDirectory, File configF JsonNode root = mapper.readTree(configFile); if (root.isArray()) { // Define a collection type of List<TestSuiteConfig> for the purposes of json deserialization. - CollectionType listClass = mapper.getTypeFactory().constructCollectionType(List.class, TestSuiteConfig.class); + CollectionType listClass = mapper.getTypeFactory().constructCollectionType(List.class, + TestSuiteConfig.class + ); // This suppresses compiler warning for this cast. @SuppressWarnings("unchecked") @@ -245,7 +250,8 @@ public List<TestSuiteConfig> getTestSuiteConfig(File rootDirectory, File configF return validate(rootDirectory, configFile, testSuites); } else { - return validate(rootDirectory, configFile, Arrays.asList(mapper.treeToValue(root, TestSuiteConfig.class))); + return validate(rootDirectory, configFile, Arrays.asList(mapper.treeToValue(root, TestSuiteConfig.class + ))); } } catch (IOException ex) { logger.log(Level.WARNING, "Unable to read test suite config at " + configFile.getPath(), ex);