diff --git a/Core/build.xml b/Core/build.xml index 5610c47ba1..bbf612c3d9 100644 --- a/Core/build.xml +++ b/Core/build.xml @@ -196,109 +196,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Core/ivy.xml b/Core/ivy.xml index f1c8f10ab9..92be3f86e6 100644 --- a/Core/ivy.xml +++ b/Core/ivy.xml @@ -27,12 +27,7 @@ - - - - - diff --git a/Core/nbproject/project.xml b/Core/nbproject/project.xml index 7e4cb8f9de..165c56ea2f 100644 --- a/Core/nbproject/project.xml +++ b/Core/nbproject/project.xml @@ -391,18 +391,6 @@ ext/jackson-databind-2.9.7.jar release\modules\ext\jackson-databind-2.9.7.jar - - ext/jackson-dataformat-yaml-2.9.7.jar - release\modules\ext\jackson-dataformat-yaml-2.9.7.jar - - - ext/jackson-annotations-2.9.7.jar - release\modules\ext\jackson-annotations-2.9.7.jar - - - ext/jackson-core-2.9.7.jar - release\modules\ext\jackson-core-2.9.7.jar - ext/okhttp-2.7.5.jar release\modules\ext\okhttp-2.7.5.jar @@ -623,10 +611,18 @@ ext/curator-recipes-2.8.0.jar release\modules\ext\curator-recipes-2.8.0.jar + + ext/jackson-annotations-2.9.0.jar + release\modules\ext\jackson-annotations-2.9.0.jar + ext/objenesis-3.1.jar release\modules\ext\objenesis-3.1.jar + + ext/jackson-core-2.9.7.jar + release\modules\ext\jackson-core-2.9.7.jar + ext/commons-lang3-3.5.jar release\modules\ext\commons-lang3-3.5.jar diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/datasourcesummary/UserActivitySummaryTests.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/datasourcesummary/UserActivitySummaryTests.java index 9bb1307412..8e1eb8ff3e 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/datasourcesummary/UserActivitySummaryTests.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/datasourcesummary/UserActivitySummaryTests.java @@ -1,68 +1,68 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sleuthkit.autopsy.datasourcesummary; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException; -import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary; -import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary.TopDomainsResult; -import org.sleuthkit.autopsy.integrationtesting.IntegrationTest; -import org.sleuthkit.autopsy.integrationtesting.IntegrationTests; -import org.sleuthkit.datamodel.Content; -import org.sleuthkit.datamodel.DataSource; -import org.sleuthkit.datamodel.TskCoreException; -import org.openide.util.lookup.ServiceProvider; - -/** - * Tests for the UserActivitySummary class. - */ -@ServiceProvider(service = IntegrationTests.class) -public class UserActivitySummaryTests implements IntegrationTests { - - /** - * Runs UserActivitySummary.getRecentDomains for all data sources found in - * the current case. - * - * @return A map where the key is the data source name and the value are the - * results of that method. - */ - @IntegrationTest - public Map> getRecentDomainsTest() - throws NoCurrentCaseException, TskCoreException, SleuthkitCaseProviderException { - - UserActivitySummary userActivitySummary = new UserActivitySummary(); - Map> toRet = new HashMap<>(); - for (Content c : Case.getCurrentCaseThrows().getDataSources()) { - if (c instanceof DataSource) { - DataSource ds = (DataSource) c; - List thisResult = userActivitySummary.getRecentDomains(ds, 10); - toRet.put(ds.getName(), thisResult); - } - } - return toRet; - - } - - //...other tests for other methods in the class... -} +///* +// * Autopsy Forensic Browser +// * +// * Copyright 2020 Basis Technology Corp. +// * Contact: carrier sleuthkit org +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// +//package org.sleuthkit.autopsy.datasourcesummary; +// +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +//import org.sleuthkit.autopsy.casemodule.Case; +//import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; +//import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException; +//import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary; +//import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary.TopDomainsResult; +//import org.sleuthkit.autopsy.integrationtesting.IntegrationTest; +//import org.sleuthkit.autopsy.integrationtesting.IntegrationTests; +//import org.sleuthkit.datamodel.Content; +//import org.sleuthkit.datamodel.DataSource; +//import org.sleuthkit.datamodel.TskCoreException; +//import org.openide.util.lookup.ServiceProvider; +// +///** +// * Tests for the UserActivitySummary class. +// */ +//@ServiceProvider(service = IntegrationTests.class) +//public class UserActivitySummaryTests implements IntegrationTests { +// +// /** +// * Runs UserActivitySummary.getRecentDomains for all data sources found in +// * the current case. +// * +// * @return A map where the key is the data source name and the value are the +// * results of that method. +// */ +// @IntegrationTest +// public Map> getRecentDomainsTest() +// throws NoCurrentCaseException, TskCoreException, SleuthkitCaseProviderException { +// +// UserActivitySummary userActivitySummary = new UserActivitySummary(); +// Map> toRet = new HashMap<>(); +// for (Content c : Case.getCurrentCaseThrows().getDataSources()) { +// if (c instanceof DataSource) { +// DataSource ds = (DataSource) c; +// List thisResult = userActivitySummary.getRecentDomains(ds, 10); +// toRet.put(ds.getName(), thisResult); +// } +// } +// return toRet; +// +// } +// +// //...other tests for other methods in the class... +//} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryService.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryService.java deleted file mode 100644 index df36b93659..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.ingest; - -import java.util.List; - -/** - * Service for obtaining all Ingest Module Factories - */ -public class IngestModuleFactoryService { - public List getFactories() { - return IngestModuleFactoryLoader.getIngestModuleFactories(); - } -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTest.java deleted file mode 100644 index 5c43568a98..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation similar to Junit's @Test for outputing results as a part of an - * integration test. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface IntegrationTest { -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTests.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTests.java deleted file mode 100644 index 59aa5ae5cd..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTests.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting; - -/** - * Basic interface for integration test suite. - */ -public interface IntegrationTests { - /** - * Allows for a test to perform any necessary setup. - */ - default void setup() {} - - /** - * Allows for a test to perform any necessary disposing of resources. - */ - default void tearDown() {} - - /** - * Allows for this suite of tests to perform any necessary setup. - */ - default void setupClass() {} - - /** - * Allows for this suite of tests to dispose of resources. - */ - default void tearDownClass() {} -} - diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java deleted file mode 100644 index f0ff10f053..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import org.sleuthkit.autopsy.integrationtesting.config.IntegrationTestConfig; -import java.lang.reflect.Method; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import junit.framework.Test; -import junit.framework.TestCase; -import org.apache.cxf.common.util.CollectionUtils; -import org.netbeans.junit.NbModuleSuite; -import org.openide.util.Lookup; -import org.openide.util.io.NbObjectInputStream; -import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.casemodule.Case.CaseType; -import org.sleuthkit.autopsy.casemodule.CaseActionException; -import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor; -import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException; -import org.sleuthkit.autopsy.datasourceprocessors.DataSourceProcessorUtility; -import org.sleuthkit.autopsy.ingest.IngestJobSettings; -import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; -import org.sleuthkit.autopsy.ingest.IngestModuleFactoryService; -import org.sleuthkit.autopsy.ingest.IngestModuleFactory; -import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; -import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; -import org.sleuthkit.autopsy.integrationtesting.config.CaseConfig; -import org.sleuthkit.autopsy.integrationtesting.config.IntegrationCaseType; -import org.sleuthkit.autopsy.python.FactoryClassNameNormalizer; -import org.sleuthkit.autopsy.testutils.CaseUtils; -import org.sleuthkit.autopsy.testutils.IngestUtils; -import org.sleuthkit.datamodel.TskCoreException; - -/** - * Main entry point for running integration tests. Handles processing - * parameters, ingesting data sources for cases, and running items implementing - * IntegrationTests. - */ -public class MainTestRunner extends TestCase { - - private static final Logger logger = Logger.getLogger(MainTestRunner.class.getName()); // DO NOT USE AUTOPSY LOGGER - private static final String CONFIG_FILE_KEY = "CONFIG_FILE_KEY"; - private static final IngestModuleFactoryService ingestFactoryService = new IngestModuleFactoryService(); - private static final IngestType DEFAULT_INGEST_TYPE = IngestType.ALL_MODULES; - - /** - * Constructor required by JUnit - */ - public MainTestRunner(String name) { - super(name); - } - - /** - * Creates suite from particular test cases. - */ - public static Test suite() { - NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(MainTestRunner.class). - clusters(".*"). - enableModules(".*"); - - return NbModuleSuite.create(conf.addTest("runIntegrationTests")); - } - - public void runIntegrationTests() { - String configFile = System.getProperty(CONFIG_FILE_KEY); - IntegrationTestConfig config; - try { - config = getConfigFromFile(configFile); - } catch (IOException ex) { - logger.log(Level.WARNING, "There was an error processing integration test config at " + configFile, ex); - return; - } - - if (config == null) { - logger.log(Level.WARNING, "No properly formatted config found at " + configFile); - } - - if (!CollectionUtils.isEmpty(config.getCases())) { - for (CaseConfig caseConfig : config.getCases()) { - for (CaseType caseType : IntegrationCaseType.getCaseTypes(caseConfig.getCaseTypes())) { - Case autopsyCase = runIngest(caseConfig, caseType); - if (autopsyCase == null || autopsyCase != Case.getCurrentCase()) { - logger.log(Level.WARNING, - String.format("Case was not properly ingested or setup correctly for environment. Case is %s and current case is %s.", - autopsyCase, Case.getCurrentCase())); - return; - } - - String caseName = autopsyCase.getName(); - - runIntegrationTests(config, caseConfig, caseType); - - try { - Case.closeCurrentCase(); - } catch (CaseActionException ex) { - logger.log(Level.WARNING, "There was an error while trying to close current case: {0}", caseName); - return; - } - } - } - } - } - - private Case runIngest(CaseConfig caseConfig, CaseType caseType) { - Case openCase = null; - switch (caseType) { - case SINGLE_USER_CASE: - openCase = CaseUtils.createAsCurrentCase(caseConfig.getCaseName()); - break; - case MULTI_USER_CASE: - // TODO - default: - throw new IllegalArgumentException("Unknown case type: " + caseType); - } - - if (openCase == null) { - logger.log(Level.WARNING, String.format("No case could be created for %s of type %s.", caseConfig.getCaseName(), caseType)); - return null; - } - - addDataSourcesToCase(caseConfig.getDataSourceResources(), caseConfig.getCaseName()); - try { - IngestJobSettings ingestJobSettings = getIngestSettings(caseConfig.getCaseName(), - DEFAULT_INGEST_TYPE, - caseConfig.getIngestModules(), caseConfig.getIngestModuleSettingsPath()); - - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - } catch (TskCoreException ex) { - logger.log(Level.WARNING, String.format("There was an error while ingesting datasources for case %s", caseConfig.getCaseName()), ex); - } - - return openCase; - } - - private IngestJobSettings getIngestSettings(String profileName, IngestType ingestType, List enabledFactoryClasses, String pathToIngestModuleSettings) { - Map classToFactoryMap = ingestFactoryService.getFactories().stream() - .collect(Collectors.toMap(factory -> factory.getClass().getCanonicalName(), factory -> factory, (f1, f2) -> f1)); - - List ingestModuleTemplates = enabledFactoryClasses.stream() - .map(className -> { - IngestModuleFactory factory = classToFactoryMap.get(className); - if (factory == null) { - logger.log(Level.WARNING, "Could not find ingest module factory: " + className); - } - return factory; - }) - .filter(factory -> factory != null) - .map(factory -> getTemplate(pathToIngestModuleSettings, factory)) - .collect(Collectors.toList()); - - return new IngestJobSettings(profileName, ingestType, ingestModuleTemplates); - } - - private IngestModuleTemplate getTemplate(String pathToIngestModuleSettings, IngestModuleFactory factory) { - String fileName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) + ".settings"; - File settingsFile = Paths.get(pathToIngestModuleSettings, fileName).toFile(); - if (settingsFile.exists()) { - try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()))) { - IngestModuleIngestJobSettings settings = (IngestModuleIngestJobSettings) in.readObject(); - return new IngestModuleTemplate(factory, settings); - } catch (IOException | ClassNotFoundException ex) { - logger.log(Level.WARNING, String.format("Unable to open %s as IngestModuleIngestJobSettings", settingsFile), ex); - } - } - - return new IngestModuleTemplate(factory, factory.getDefaultIngestJobSettings()); - } - - private void addDataSourcesToCase(List pathStrings, String caseName) { - for (String strPath : pathStrings) { - Path path = Paths.get(strPath); - List processors = null; - try { - processors = DataSourceProcessorUtility.getOrderedListOfDataSourceProcessors(path); - } catch (AutoIngestDataSourceProcessorException ex) { - logger.log(Level.WARNING, String.format("There was an error while adding data source: %s to case %s", strPath, caseName)); - } - - if (CollectionUtils.isEmpty(processors)) { - continue; - } - - IngestUtils.addDataSource(processors.get(0), path); - } - } - - private IntegrationTestConfig getConfigFromFile(String filePath) throws IOException { - ObjectMapper om = new ObjectMapper(); - try (FileInputStream jsonSrc = new FileInputStream(filePath)) { - return om.readValue(jsonSrc, IntegrationTestConfig.class); - } - } - - private void runIntegrationTests(IntegrationTestConfig config, CaseConfig caseConfig, CaseType caseType) { - // this will capture output results - OutputResults results = new OutputResults(); - - // run through each ConsumerIntegrationTest - for (IntegrationTests testGroup : Lookup.getDefault().lookupAll(IntegrationTests.class)) { - - // if test should not be included in results, skip it. - if (!caseConfig.getTestConfig().hasIncludedTest(testGroup.getClass().getCanonicalName())) { - continue; - } - - List testMethods = getIntegrationTestMethods(testGroup); - if (CollectionUtils.isEmpty(testMethods)) { - continue; - } - - testGroup.setupClass(); - for (Method testMethod : testMethods) { - runIntegrationTestMethod(results, testGroup, testMethod); - } - testGroup.tearDownClass(); - } - - // write the results for the case to a file - serializeFile(results, config.getRootTestOutputPath(), caseConfig.getCaseName(), getCaseTypeId(caseType)); - } - - private String getCaseTypeId(CaseType caseType) { - if (caseType == null) { - return ""; - } - - switch (caseType) { - case SINGLE_USER_CASE: - return "singleUser"; - case MULTI_USER_CASE: - return "multiUser"; - default: - throw new IllegalArgumentException("Unknown case type: " + caseType); - } - } - - private void runIntegrationTestMethod(OutputResults results, IntegrationTests testGroup, Method testMethod) { - testGroup.setup(); - - // run the test method and get the results - Object serializableResult = null; - - try { - serializableResult = testMethod.invoke(testGroup); - } catch (IllegalAccessException | IllegalArgumentException ex) { - logger.log(Level.WARNING, - String.format("test method %s in %s could not be properly invoked", - testMethod.getName(), testGroup.getClass().getCanonicalName()), - ex); - - serializableResult = ex; - } catch (InvocationTargetException ex) { - serializableResult = ex.getCause(); - } - - testGroup.tearDown(); - - // add the results and capture the package, class, - // and method of the test for easy location of failed tests - results.addResult( - testGroup.getClass().getPackage().getName(), - testGroup.getClass().getSimpleName(), - testMethod.getName(), - serializableResult); - } - - private List getIntegrationTestMethods(IntegrationTests testGroup) { - return Stream.of(testGroup.getClass().getMethods()) - .filter((method) -> method.getAnnotation(IntegrationTest.class) != null) - .collect(Collectors.toList()); - } - - private void serializeFile(OutputResults results, String outputFolder, String caseName, String caseType) { - String outputExtension = ".yml"; - Path outputPath = Paths.get(outputFolder, String.format("%s-%s%s", caseName, caseType, outputExtension)); - ObjectMapper om = new ObjectMapper(new YAMLFactory()); - - try { - om.writeValue(outputPath.toFile(), results.getSerializableData()); - } catch (IOException ex) { - logger.log(Level.WARNING, "There was an error writing results to outputPath: " + outputPath, ex); - } - } -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/OutputResults.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/OutputResults.java deleted file mode 100644 index 4138657354..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/OutputResults.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; -import org.apache.commons.lang.exception.ExceptionUtils; - -/** - * Integration Test results for a case to be written to disk in a text format. - */ -public class OutputResults { - - private static class ExceptionObject { - - private final String message; - private final String stackTrace; - private final ExceptionObject innerException; - - ExceptionObject(Throwable t) { - this.message = t.getMessage(); - this.stackTrace = ExceptionUtils.getStackTrace(t); - this.innerException = (t.getCause() == null) ? null : new ExceptionObject(t.getCause()); - } - - String getMessage() { - return message; - } - - String getStackTrace() { - return stackTrace; - } - - ExceptionObject getInnerException() { - return innerException; - } - } - - private final Map>> data = new HashMap<>(); - - private static V getOrCreate(Map map, K key, Supplier onNotPresent) { - V curValue = map.get(key); - if (curValue == null) { - curValue = onNotPresent.get(); - map.put(key, curValue); - } - return curValue; - } - - public void addResult(String pkgName, String className, String methodName, Object result) { - Map> packageClasses = getOrCreate(data, pkgName, () -> new HashMap<>()); - Map classMethods = getOrCreate(packageClasses, className, () -> new HashMap<>()); - Object toWrite = result instanceof Throwable ? new ExceptionObject((Throwable) result) : result; - classMethods.put(methodName, toWrite); - } - - public Object getSerializableData() { - return Collections.unmodifiableMap(data); - } -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/CaseConfig.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/CaseConfig.java deleted file mode 100644 index 7ba3ae8f6c..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/CaseConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting.config; - -import java.util.List; - -/** - * Configuration in IntegrationTests per case. - */ -public class CaseConfig { - private final String caseName; - private final List dataSourceResources; - - private final List ingestModules; - private final String ingestModuleSettingsPath; - - private final IntegrationCaseType caseTypes; - private final TestingConfig testConfig; - - public CaseConfig(String caseName, List dataSourceResources, - List ingestModules, String ingestModuleSettingsPath, - IntegrationCaseType caseTypes, TestingConfig testConfig) { - this.caseName = caseName; - this.dataSourceResources = dataSourceResources; - this.ingestModules = ingestModules; - this.ingestModuleSettingsPath = ingestModuleSettingsPath; - this.caseTypes = caseTypes; - this.testConfig = testConfig; - } - - public String getCaseName() { - return caseName; - } - - public List getDataSourceResources() { - return dataSourceResources; - } - - public String getIngestModuleSettingsPath() { - return ingestModuleSettingsPath; - } - - public IntegrationCaseType getCaseTypes() { - return caseTypes; - } - - public TestingConfig getTestConfig() { - return testConfig; - } - - public List getIngestModules() { - return ingestModules; - } -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationCaseType.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationCaseType.java deleted file mode 100644 index d85c60d5c3..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationCaseType.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting.config; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.sleuthkit.autopsy.casemodule.Case.CaseType; - -/** - * The case types to create for this case. - */ -public enum IntegrationCaseType { - multiUser, singleUser, both; - - public static List getCaseTypes(IntegrationCaseType integrationCaseType) { - if (integrationCaseType == null) { - return Collections.emptyList(); - } - - switch (integrationCaseType) { - case multiUser: return Arrays.asList(CaseType.MULTI_USER_CASE); - case singleUser: return Arrays.asList(CaseType.SINGLE_USER_CASE); - case both: return Arrays.asList(CaseType.MULTI_USER_CASE, CaseType.SINGLE_USER_CASE); - default: throw new IllegalArgumentException("Unknown integration case type: " + integrationCaseType); - } - } -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java deleted file mode 100644 index 4547afa92a..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting.config; - -import java.util.List; - -/** - * Configuration for running Integration Tests including things like ingest - * parameters, datasource locations, cases to create, tests to run, etc. - */ -public class IntegrationTestConfig { - private final String rootCaseOutputPath; - private final String rootTestOutputPath; - private final List cases; - - public IntegrationTestConfig(String rootCaseOutputPath, - String rootTestOutputPath, List cases) { - this.rootCaseOutputPath = rootCaseOutputPath; - this.rootTestOutputPath = rootTestOutputPath; - this.cases = cases; - } - - public String getRootCaseOutputPath() { - return rootCaseOutputPath; - } - - public String getRootTestOutputPath() { - return rootTestOutputPath; - } - - public List getCases() { - return cases; - } -} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java deleted file mode 100644 index d845486073..0000000000 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2020 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.integrationtesting.config; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import org.apache.commons.collections4.CollectionUtils; - -/** - * Configuration for which integration test suites to run. - */ -public class TestingConfig { - private final Set excludeAllExcept; - private final Set includeAllExcept; - - private static Set convert(List orig) { - if (orig == null) { - return Collections.emptySet(); - } - - return orig.stream() - .map((item) -> item.toUpperCase()) - .collect(Collectors.toSet()); - } - - @JsonCreator - public TestingConfig(@JsonProperty() List excludeAllExcept, @JsonProperty() List includeAllExcept) { - this.excludeAllExcept = convert(excludeAllExcept); - this.includeAllExcept = convert(includeAllExcept); - } - - public Set getExcludeAllExcept() { - return excludeAllExcept; - } - - public Set getIncludeAllExcept() { - return includeAllExcept; - } - - public boolean hasIncludedTest(String itemType) { - if (itemType == null) { - return false; - } - - if (!CollectionUtils.isEmpty(includeAllExcept)) { - if (includeAllExcept.contains(itemType.toUpperCase())) { - return false; - } - } - - if (!CollectionUtils.isEmpty(excludeAllExcept)) { - return excludeAllExcept.contains(itemType.toUpperCase()); - } - - return true; - } -} diff --git a/IntegrationTesting/allJarsInUse.jar b/IntegrationTesting/allJarsInUse.jar new file mode 100644 index 0000000000..c358ab37eb Binary files /dev/null and b/IntegrationTesting/allJarsInUse.jar differ diff --git a/IntegrationTesting/allJarsInUse.zip b/IntegrationTesting/allJarsInUse.zip new file mode 100644 index 0000000000..86018983dc Binary files /dev/null and b/IntegrationTesting/allJarsInUse.zip differ diff --git a/IntegrationTesting/build.xml b/IntegrationTesting/build.xml index be49147cb6..9b15b6f832 100644 --- a/IntegrationTesting/build.xml +++ b/IntegrationTesting/build.xml @@ -2,11 +2,14 @@ - + Builds, tests, and runs the project org.sleuthkit.autopsy.integrationtesting. + - + + + + + + + + @@ -45,7 +63,7 @@ - + @@ -56,13 +74,14 @@ + - + diff --git a/IntegrationTesting/ivy.xml b/IntegrationTesting/ivy.xml new file mode 100644 index 0000000000..60c0891912 --- /dev/null +++ b/IntegrationTesting/ivy.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/IntegrationTesting/ivysettings.xml b/IntegrationTesting/ivysettings.xml new file mode 100644 index 0000000000..ca6b2f19fa --- /dev/null +++ b/IntegrationTesting/ivysettings.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/IntegrationTesting/nbproject/platform.properties b/IntegrationTesting/nbproject/platform.properties new file mode 100644 index 0000000000..cc3d6b1b13 --- /dev/null +++ b/IntegrationTesting/nbproject/platform.properties @@ -0,0 +1,16 @@ +cluster.path=\ + ${nbplatform.active.dir}/platform +disabled.modules=\ + org.netbeans.api.visual,\ + org.netbeans.core.execution,\ + org.netbeans.core.multiview,\ + org.netbeans.libs.jsr223,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.favorites,\ + org.openide.compat,\ + org.openide.execution,\ + org.openide.options,\ + org.openide.util.enumerations +nbplatform.active=default diff --git a/IntegrationTesting/nbproject/project.properties b/IntegrationTesting/nbproject/project.properties index 2b963e0724..7f36104b2e 100644 --- a/IntegrationTesting/nbproject/project.properties +++ b/IntegrationTesting/nbproject/project.properties @@ -1,3 +1,21 @@ +file.reference.commons-collections-3.2.1.jar=release\\modules\\ext\\commons-collections-3.2.1.jar +file.reference.commons-io-2.5.jar=release\\modules\\ext\\commons-io-2.5.jar +file.reference.commons-lang-2.4.jar=release\\modules\\ext\\commons-lang-2.4.jar +file.reference.commons-lang3-3.4.jar=release\\modules\\ext\\commons-lang3-3.4.jar +file.reference.hamcrest-core-1.3.jar=release\\modules\\ext\\hamcrest-core-1.3.jar +file.reference.jackson-annotations-2.11.3.jar=release\\modules\\ext\\jackson-annotations-2.11.3.jar +file.reference.jackson-annotations-2.9.7.jar=release\\modules\\ext\\jackson-annotations-2.9.7.jar +file.reference.jackson-core-2.11.3.jar=release\\modules\\ext\\jackson-core-2.11.3.jar +file.reference.jackson-core-2.9.7.jar=release\\modules\\ext\\jackson-core-2.9.7.jar +file.reference.jackson-databind-2.11.3.jar=release\\modules\\ext\\jackson-databind-2.11.3.jar +file.reference.jackson-databind-2.9.7.jar=release\\modules\\ext\\jackson-databind-2.9.7.jar +file.reference.jackson-dataformat-yaml-2.11.3.jar=release\\modules\\ext\\jackson-dataformat-yaml-2.11.3.jar +file.reference.jackson-dataformat-yaml-2.9.7.jar=release\\modules\\ext\\jackson-dataformat-yaml-2.9.7.jar +file.reference.joda-time-2.10.1.jar=release\\modules\\ext\\joda-time-2.10.1.jar +file.reference.junit-4.12.jar=release\\modules\\ext\\junit-4.12.jar +file.reference.oro-2.0.8.jar=release\\modules\\ext\\oro-2.0.8.jar +file.reference.snakeyaml-1.27.jar=release\\modules\\ext\\snakeyaml-1.27.jar +file.reference.velocity-1.6.2.jar=release\\modules\\ext\\velocity-1.6.2.jar javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial license.file=../LICENSE-2.0.txt diff --git a/IntegrationTesting/nbproject/project.xml b/IntegrationTesting/nbproject/project.xml index d353be8d20..a74961aa51 100644 --- a/IntegrationTesting/nbproject/project.xml +++ b/IntegrationTesting/nbproject/project.xml @@ -101,6 +101,46 @@ org.sleuthkit.autopsy.integrationtesting + + ext/hamcrest-core-1.3.jar + release\modules\ext\hamcrest-core-1.3.jar + + + ext/velocity-1.6.2.jar + release\modules\ext\velocity-1.6.2.jar + + + ext/commons-lang3-3.4.jar + release\modules\ext\commons-lang3-3.4.jar + + + ext/commons-lang-2.4.jar + release\modules\ext\commons-lang-2.4.jar + + + ext/commons-collections-3.2.1.jar + release\modules\ext\commons-collections-3.2.1.jar + + + ext/oro-2.0.8.jar + release\modules\ext\oro-2.0.8.jar + + + ext/joda-time-2.10.1.jar + release\modules\ext\joda-time-2.10.1.jar + + + ext/junit-4.12.jar + release\modules\ext\junit-4.12.jar + + + ext/commons-io-2.5.jar + release\modules\ext\commons-io-2.5.jar + + + ext/snakeyaml-1.27.jar + release\modules\ext\snakeyaml-1.27.jar + diff --git a/IntegrationTesting/release/modules/ext/commons-collections-3.2.1.jar b/IntegrationTesting/release/modules/ext/commons-collections-3.2.1.jar new file mode 100644 index 0000000000..c35fa1fee1 Binary files /dev/null and b/IntegrationTesting/release/modules/ext/commons-collections-3.2.1.jar differ diff --git a/IntegrationTesting/release/modules/ext/commons-io-2.5.jar b/IntegrationTesting/release/modules/ext/commons-io-2.5.jar new file mode 100644 index 0000000000..107b061f5f Binary files /dev/null and b/IntegrationTesting/release/modules/ext/commons-io-2.5.jar differ diff --git a/IntegrationTesting/release/modules/ext/commons-lang-2.4.jar b/IntegrationTesting/release/modules/ext/commons-lang-2.4.jar new file mode 100644 index 0000000000..532939ecab Binary files /dev/null and b/IntegrationTesting/release/modules/ext/commons-lang-2.4.jar differ diff --git a/IntegrationTesting/release/modules/ext/commons-lang3-3.4.jar b/IntegrationTesting/release/modules/ext/commons-lang3-3.4.jar new file mode 100644 index 0000000000..8ec91d454c Binary files /dev/null and b/IntegrationTesting/release/modules/ext/commons-lang3-3.4.jar differ diff --git a/IntegrationTesting/release/modules/ext/gson-2.8.6-javadoc.jar b/IntegrationTesting/release/modules/ext/gson-2.8.6-javadoc.jar new file mode 100644 index 0000000000..e3cce52dc7 Binary files /dev/null and b/IntegrationTesting/release/modules/ext/gson-2.8.6-javadoc.jar differ diff --git a/IntegrationTesting/release/modules/ext/gson-2.8.6-sources.jar b/IntegrationTesting/release/modules/ext/gson-2.8.6-sources.jar new file mode 100644 index 0000000000..1e07df4b0d Binary files /dev/null and b/IntegrationTesting/release/modules/ext/gson-2.8.6-sources.jar differ diff --git a/IntegrationTesting/release/modules/ext/gson-2.8.6.jar b/IntegrationTesting/release/modules/ext/gson-2.8.6.jar new file mode 100644 index 0000000000..4765c4afeb Binary files /dev/null and b/IntegrationTesting/release/modules/ext/gson-2.8.6.jar differ diff --git a/IntegrationTesting/release/modules/ext/hamcrest-core-1.3.jar b/IntegrationTesting/release/modules/ext/hamcrest-core-1.3.jar new file mode 100644 index 0000000000..9d5fe16e3d Binary files /dev/null and b/IntegrationTesting/release/modules/ext/hamcrest-core-1.3.jar differ diff --git a/IntegrationTesting/release/modules/ext/joda-time-2.10.1.jar b/IntegrationTesting/release/modules/ext/joda-time-2.10.1.jar new file mode 100644 index 0000000000..aa55ad2b17 Binary files /dev/null and b/IntegrationTesting/release/modules/ext/joda-time-2.10.1.jar differ diff --git a/IntegrationTesting/release/modules/ext/junit-4.12.jar b/IntegrationTesting/release/modules/ext/junit-4.12.jar new file mode 100644 index 0000000000..3a7fc266c3 Binary files /dev/null and b/IntegrationTesting/release/modules/ext/junit-4.12.jar differ diff --git a/IntegrationTesting/release/modules/ext/oro-2.0.8.jar b/IntegrationTesting/release/modules/ext/oro-2.0.8.jar new file mode 100644 index 0000000000..23488d2600 Binary files /dev/null and b/IntegrationTesting/release/modules/ext/oro-2.0.8.jar differ diff --git a/IntegrationTesting/release/modules/ext/snakeyaml-1.27-javadoc.jar b/IntegrationTesting/release/modules/ext/snakeyaml-1.27-javadoc.jar new file mode 100644 index 0000000000..a714fe6d36 Binary files /dev/null and b/IntegrationTesting/release/modules/ext/snakeyaml-1.27-javadoc.jar differ diff --git a/IntegrationTesting/release/modules/ext/snakeyaml-1.27-sources.jar b/IntegrationTesting/release/modules/ext/snakeyaml-1.27-sources.jar new file mode 100644 index 0000000000..6e08ed725b Binary files /dev/null and b/IntegrationTesting/release/modules/ext/snakeyaml-1.27-sources.jar differ diff --git a/IntegrationTesting/release/modules/ext/snakeyaml-1.27.jar b/IntegrationTesting/release/modules/ext/snakeyaml-1.27.jar new file mode 100644 index 0000000000..79bd430c4b Binary files /dev/null and b/IntegrationTesting/release/modules/ext/snakeyaml-1.27.jar differ diff --git a/IntegrationTesting/release/modules/ext/velocity-1.6.2.jar b/IntegrationTesting/release/modules/ext/velocity-1.6.2.jar new file mode 100644 index 0000000000..e0a73c1efa Binary files /dev/null and b/IntegrationTesting/release/modules/ext/velocity-1.6.2.jar differ diff --git a/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java b/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java index f0ff10f053..a85b4fa2c6 100644 --- a/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java +++ b/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/MainTestRunner.java @@ -18,10 +18,12 @@ */ package org.sleuthkit.autopsy.integrationtesting; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import java.io.File; import java.io.FileInputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.sleuthkit.autopsy.integrationtesting.config.IntegrationTestConfig; @@ -58,6 +60,7 @@ import org.sleuthkit.autopsy.python.FactoryClassNameNormalizer; import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestUtils; import org.sleuthkit.datamodel.TskCoreException; +import org.yaml.snakeyaml.Yaml; /** * Main entry point for running integration tests. Handles processing @@ -67,7 +70,7 @@ import org.sleuthkit.datamodel.TskCoreException; public class MainTestRunner extends TestCase { private static final Logger logger = Logger.getLogger(MainTestRunner.class.getName()); // DO NOT USE AUTOPSY LOGGER - private static final String CONFIG_FILE_KEY = "CONFIG_FILE_KEY"; + private static final String CONFIG_FILE_KEY = "configFileKey"; private static final IngestModuleFactoryService ingestFactoryService = new IngestModuleFactoryService(); private static final IngestType DEFAULT_INGEST_TYPE = IngestType.ALL_MODULES; @@ -213,10 +216,11 @@ public class MainTestRunner extends TestCase { } private IntegrationTestConfig getConfigFromFile(String filePath) throws IOException { - ObjectMapper om = new ObjectMapper(); - try (FileInputStream jsonSrc = new FileInputStream(filePath)) { - return om.readValue(jsonSrc, IntegrationTestConfig.class); - } + //return new IntegrationTestConfig("C:\\Users\\gregd\\Desktop\\testoutput", "C:\\Users\\gregd\\Desktop\\testoutput", Collections.emptyList()); + GsonBuilder builder = new GsonBuilder(); + builder.registerTypeAdapter(IntegrationTestConfig.class, IntegrationTestConfig.DESERIALIZER); + Gson gson = builder.create(); + return gson.fromJson(new FileReader(new File(filePath)), IntegrationTestConfig.class); } private void runIntegrationTests(IntegrationTestConfig config, CaseConfig caseConfig, CaseType caseType) { @@ -301,10 +305,12 @@ public class MainTestRunner extends TestCase { private void serializeFile(OutputResults results, String outputFolder, String caseName, String caseType) { String outputExtension = ".yml"; Path outputPath = Paths.get(outputFolder, String.format("%s-%s%s", caseName, caseType, outputExtension)); - ObjectMapper om = new ObjectMapper(new YAMLFactory()); + Yaml yaml = new Yaml(); try { - om.writeValue(outputPath.toFile(), results.getSerializableData()); + + FileWriter writer = new FileWriter(outputPath.toFile()); + yaml.dump(results.getSerializableData(), writer); } catch (IOException ex) { logger.log(Level.WARNING, "There was an error writing results to outputPath: " + outputPath, ex); } diff --git a/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java b/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java index 4547afa92a..5c156f87ce 100644 --- a/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java +++ b/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/IntegrationTestConfig.java @@ -18,6 +18,13 @@ */ package org.sleuthkit.autopsy.integrationtesting.config; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; import java.util.List; /** @@ -25,6 +32,21 @@ import java.util.List; * parameters, datasource locations, cases to create, tests to run, etc. */ public class IntegrationTestConfig { + private static final Type listOfCasesType = new TypeToken>(){}.getType(); + + public static final JsonDeserializer DESERIALIZER = new JsonDeserializer() { + @Override + public IntegrationTestConfig deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException { + JsonObject jObj = je.getAsJsonObject(); + String rootCaseOutputPath = jObj.get("rootTestOutputPath").getAsString(); + String rootTestOutputPath = jObj.get("rootTestOutputPath").getAsString(); + List cases = jdc.deserialize(jObj.get("cases"), listOfCasesType); + + return new IntegrationTestConfig(rootCaseOutputPath, rootTestOutputPath, cases); + } + }; + + private final String rootCaseOutputPath; private final String rootTestOutputPath; private final List cases; diff --git a/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java b/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java index d845486073..b95278b91f 100644 --- a/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java +++ b/IntegrationTesting/test/qa-functional/src/org/sleuthkit/autopsy/integrationtesting/config/TestingConfig.java @@ -18,8 +18,6 @@ */ package org.sleuthkit.autopsy.integrationtesting.config; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Collections; import java.util.List; import java.util.Set; @@ -43,8 +41,7 @@ public class TestingConfig { .collect(Collectors.toSet()); } - @JsonCreator - public TestingConfig(@JsonProperty() List excludeAllExcept, @JsonProperty() List includeAllExcept) { + public TestingConfig(List excludeAllExcept, List includeAllExcept) { this.excludeAllExcept = convert(excludeAllExcept); this.includeAllExcept = convert(includeAllExcept); }