diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java index 0463642f90..cd55b16f82 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java @@ -160,9 +160,7 @@ public class EncryptionDetectionTest extends NbTestCase { CaseUtils.createCase(PASSWORD_DETECTION_CASE_NAME); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - List errorMessages = IngestUtils.addDataSource(dataSourceProcessor, PASSWORD_DETECTION_IMAGE_PATH); - String joinedErrors = String.join(System.lineSeparator(), errorMessages); - assertEquals(joinedErrors, 0, errorMessages.size()); + IngestUtils.addDataSource(dataSourceProcessor, PASSWORD_DETECTION_IMAGE_PATH); Case openCase = Case.getCurrentCaseThrows(); @@ -260,15 +258,7 @@ public class EncryptionDetectionTest extends NbTestCase { try { CaseUtils.createCase(VERACRYPT_DETECTION_CASE_NAME); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - List errorMessages = IngestUtils.addDataSource(dataSourceProcessor, VERACRYPT_DETECTION_IMAGE_PATH); - String joinedErrors; - if (errorMessages.isEmpty()) { - joinedErrors = "Encrypted partition did not cause error, it was expected to"; - } else { - joinedErrors = String.join(System.lineSeparator(), errorMessages); - } - //there will be 1 expected error regarding the encrypted partition not having a file system - assertEquals(joinedErrors, 1, errorMessages.size()); + IngestUtils.addDataSource(dataSourceProcessor, VERACRYPT_DETECTION_IMAGE_PATH); Case openCase = Case.getCurrentCaseThrows(); ArrayList templates = new ArrayList<>(); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/DataSourceProcessorRunner.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/DataSourceProcessorRunner.java index acb144405e..2d6d2d9c3a 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/DataSourceProcessorRunner.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/DataSourceProcessorRunner.java @@ -62,6 +62,7 @@ public final class DataSourceProcessorRunner { private final Object monitor; private final List errorMessages = new ArrayList<>(); private final List dataSourceContent = new ArrayList<>(); + private DataSourceProcessorResult result; /** * Constructs a data source processor "callback" that collects the @@ -91,6 +92,7 @@ public final class DataSourceProcessorRunner { public void done(DataSourceProcessorCallback.DataSourceProcessorResult result, List errorMessages, List dataSourceContent) { this.errorMessages.addAll(errorMessages); this.dataSourceContent.addAll(dataSourceContent); + this.result = result; synchronized (monitor) { monitor.notify(); } @@ -131,6 +133,15 @@ public final class DataSourceProcessorRunner { public List getDataSourceContent() { return new ArrayList<>(this.dataSourceContent); } + + /** + * Gets the result of the data source processor run. + * + * @return The result. + */ + public DataSourceProcessorResult getResult() { + return result; + } } /** diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java index aac48890ca..7dd2871294 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java @@ -19,11 +19,11 @@ package org.sleuthkit.autopsy.testutils; import java.nio.file.Path; -import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import org.openide.util.Exceptions; import org.python.icu.impl.Assert; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestModuleError; @@ -53,23 +53,23 @@ public final class IngestUtils { * datasource * @param dataSourcePath the path to the datasource which is being * added - * - * @return errorMessages a list of all error messages as strings which - * encountered while processing the data source */ - public static List addDataSource(AutoIngestDataSourceProcessor dataSourceProcessor, Path dataSourcePath) { - List errorMessages = new ArrayList<>(); + public static void addDataSource(AutoIngestDataSourceProcessor dataSourceProcessor, Path dataSourcePath) { + DataSourceProcessorCallback.DataSourceProcessorResult result = null; try { if (!dataSourcePath.toFile().exists()) { Assert.fail("Data source not found: " + dataSourcePath.toString()); } + DataSourceProcessorRunner.ProcessorCallback callBack = DataSourceProcessorRunner.runDataSourceProcessor(dataSourceProcessor, dataSourcePath); - errorMessages = callBack.getErrorMessages(); + result = callBack.getResult(); + if (result.equals(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS)) { + Assert.fail("Critical errors occurred while running the data source processor."); + } } catch (AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException | InterruptedException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } - return errorMessages; } /**