mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-30 14:29:51 +00:00
removed collections dependency
This commit is contained in:
@@ -17,7 +17,6 @@ file.reference.c3p0-0.9.5.jar=release\\modules\\ext\\c3p0-0.9.5.jar
|
||||
file.reference.checker-compat-qual-2.5.3.jar=release\\modules\\ext\\checker-compat-qual-2.5.3.jar
|
||||
file.reference.commons-beanutils-1.9.2.jar=release\\modules\\ext\\commons-beanutils-1.9.2.jar
|
||||
file.reference.commons-codec-1.11.jar=release\\modules\\ext\\commons-codec-1.11.jar
|
||||
file.reference.commons-collections-3.2.2.jar=release\\modules\\ext\\commons-collections-3.2.2.jar
|
||||
file.reference.commons-dbcp2-2.1.1.jar=release\\modules\\ext\\commons-dbcp2-2.1.1.jar
|
||||
file.reference.commons-digester-1.8.1.jar=release\\modules\\ext\\commons-digester-1.8.1.jar
|
||||
file.reference.commons-logging-1.2.jar=release\\modules\\ext\\commons-logging-1.2.jar
|
||||
|
||||
+2
-3
@@ -20,7 +20,6 @@ import java.util.stream.Stream;
|
||||
import org.apache.cxf.common.util.CollectionUtils;
|
||||
import org.openide.util.Pair;
|
||||
import org.sleuthkit.autopsy.ingest.IngestJobSettings;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactoryService;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleTemplate;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.ConfigDeserializer;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.ParameterizedResourceConfig;
|
||||
@@ -100,7 +99,7 @@ public class ConfigurationModuleManager {
|
||||
}
|
||||
|
||||
Type configurationModuleType = Stream.of(clazz.getGenericInterfaces())
|
||||
.filter(type -> type.getClass().equals(ConfigurationModule.class) && type instanceof ParameterizedType && type instanceof Class)
|
||||
.filter(type -> type instanceof ParameterizedType && ((ParameterizedType) type).getRawType().equals(ConfigurationModule.class))
|
||||
.map(type -> ((ParameterizedType) type).getActualTypeArguments()[0])
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
@@ -121,7 +120,7 @@ public class ConfigurationModuleManager {
|
||||
}
|
||||
|
||||
if (result instanceof IngestJobSettings) {
|
||||
return Pair.of(curConfig, configModuleObj);
|
||||
return Pair.of((IngestJobSettings) result, configModuleObj);
|
||||
} else {
|
||||
logger.log(Level.SEVERE, String.format("Could not retrieve IngestJobSettings from %s", configModule.getResource()));
|
||||
return null;
|
||||
|
||||
+5
-2
@@ -3,9 +3,12 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.ingest;
|
||||
package org.sleuthkit.autopsy.integrationtesting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openide.util.Lookup;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -13,6 +16,6 @@ import java.util.List;
|
||||
*/
|
||||
public class IngestModuleFactoryService {
|
||||
public List<IngestModuleFactory> getFactories() {
|
||||
return IngestModuleFactoryLoader.getIngestModuleFactories();
|
||||
return new ArrayList<>(Lookup.getDefault().lookupAll(IngestModuleFactory.class));
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -26,7 +26,6 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.sleuthkit.autopsy.ingest.IngestJobSettings;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactoryService;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleTemplate;
|
||||
|
||||
/**
|
||||
@@ -65,7 +64,7 @@ public class IngestModuleSetupManager implements ConfigurationModule<IngestModul
|
||||
|
||||
List<IngestModuleTemplate> newTemplates = new ArrayList<>(curTemplates.values());
|
||||
|
||||
if (parameters != null && CollectionUtils.isEmpty(parameters.getModules())) {
|
||||
if (parameters != null && !CollectionUtils.isEmpty(parameters.getModules())) {
|
||||
List<IngestModuleTemplate> templatesToAdd = parameters.getModules().stream()
|
||||
.filter((className) -> !curTemplates.containsKey(className))
|
||||
.map((className) -> allFactories.get(className))
|
||||
|
||||
+6
-1
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.integrationtesting;
|
||||
|
||||
import java.io.File;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.TestSuiteConfig;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.IntegrationTestConfig;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.IntegrationCaseType;
|
||||
@@ -36,7 +37,6 @@ import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.cxf.common.util.CollectionUtils;
|
||||
import org.netbeans.junit.NbModuleSuite;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.Lookup;
|
||||
import org.openide.util.Pair;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
@@ -54,6 +54,7 @@ import org.sleuthkit.autopsy.integrationtesting.config.EnvConfig;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.TestingConfig;
|
||||
import org.sleuthkit.autopsy.testutils.IngestUtils;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import static ucar.unidata.util.Format.i;
|
||||
|
||||
/**
|
||||
* Main entry point for running integration tests. Handles processing
|
||||
@@ -159,6 +160,10 @@ public class MainTestRunner extends TestCase {
|
||||
String uniqueCaseName = String.format("%s_%s", caseName, TimeStampUtils.createTimeStamp());
|
||||
String outputFolder = PathUtil.getAbsolutePath(envConfig.getWorkingDirectory(), envConfig.getRootCaseOutputPath());
|
||||
String caseOutputFolder = Paths.get(outputFolder, uniqueCaseName).toString();
|
||||
File caseOutputFolderFile = new File(caseOutputFolder);
|
||||
if (!caseOutputFolderFile.exists()) {
|
||||
caseOutputFolderFile.mkdirs();
|
||||
}
|
||||
|
||||
switch (caseType) {
|
||||
case SINGLE_USER_CASE: {
|
||||
|
||||
+12
-5
@@ -101,12 +101,12 @@ class OutputResults {
|
||||
}
|
||||
return curValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A mapping of package -> test suite -> test -> output data
|
||||
*/
|
||||
private final Map<String, Map<String, Map<String, Object>>> data = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* Adds a result for a particular test in a test suite.
|
||||
*
|
||||
@@ -193,20 +193,27 @@ class OutputResults {
|
||||
public void serializeToFile(String outputFolder, String caseName, Case.CaseType caseType) {
|
||||
serializeToFile(getSerializationPath(outputFolder, caseName, caseType));
|
||||
}
|
||||
|
||||
|
||||
private String getSerializationPath(String outputFolder, String caseName, Case.CaseType caseType) {
|
||||
String outputExtension = ".yml";
|
||||
Path outputPath = Paths.get(outputFolder, String.format("%s-%s%s", caseName, getCaseTypeId(caseType), outputExtension));
|
||||
return outputPath.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes results of a test to a yaml file.
|
||||
*
|
||||
* @param outputPath The output path.
|
||||
*/
|
||||
public void serializeToFile(String outputPath) {
|
||||
File outputFile = new File(outputPath);
|
||||
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
outputFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
FileWriter writer = new FileWriter(new File(outputPath));
|
||||
FileWriter writer = new FileWriter(outputFile);
|
||||
YAML_SERIALIZER.dump(getSerializableData(), writer);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "There was an error writing results to outputPath: " + outputPath, ex);
|
||||
|
||||
+65
-4
@@ -25,10 +25,17 @@ import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.fasterxml.jackson.databind.node.TextNode;
|
||||
import com.fasterxml.jackson.databind.node.ValueNode;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.sleuthkit.autopsy.integrationtesting.config.ParameterizedResourceConfig.ParameterizedResourceConfigDeserializer;
|
||||
|
||||
@@ -61,14 +68,68 @@ public class ParameterizedResourceConfig {
|
||||
} else if (node instanceof TextNode) {
|
||||
return new ParameterizedResourceConfig(((TextNode) node).textValue());
|
||||
} else {
|
||||
String resource = (node.get("resource") != null) ? node.get("resource").asText() : null;
|
||||
Map<String, Object> parameters = (node.get("parameters") != null) ?
|
||||
node.get("parameters").traverse().readValueAs(Map.class) :
|
||||
null;
|
||||
JsonNode resourceNode = node.get("resource");
|
||||
String resource = (resourceNode != null) ? resourceNode.asText() : null;
|
||||
|
||||
Map<String, Object> parameters = null;
|
||||
JsonNode parametersNode = node.get("parameters");
|
||||
if (parametersNode != null && parametersNode.isObject()) {
|
||||
parameters = readMap((ObjectNode) parametersNode);
|
||||
}
|
||||
|
||||
return new ParameterizedResourceConfig(resource, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> readMap(ObjectNode node) {
|
||||
Map<String, Object> jsonObject = new LinkedHashMap<>();
|
||||
Iterator<Map.Entry<String, JsonNode>> keyValIter = node.fields();
|
||||
while (keyValIter.hasNext()) {
|
||||
Map.Entry<String, JsonNode> keyVal = keyValIter.next();
|
||||
jsonObject.put(keyVal.getKey(), readItem(keyVal.getValue()));
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
List<Object> readList(ArrayNode node) {
|
||||
List<Object> objArr = new ArrayList<>();
|
||||
for (JsonNode childNode : node) {
|
||||
objArr.add(readItem(childNode));
|
||||
}
|
||||
return objArr;
|
||||
}
|
||||
|
||||
Object readJsonPrimitive(ValueNode vNode) {
|
||||
if (vNode.isTextual()) {
|
||||
return vNode.asText();
|
||||
} else if (vNode.isBoolean()) {
|
||||
return vNode.asBoolean();
|
||||
} else if (vNode.isLong()) {
|
||||
return vNode.asLong();
|
||||
} else if (vNode.isInt()) {
|
||||
return vNode.asInt();
|
||||
} else if (vNode.isDouble()) {
|
||||
return vNode.asDouble();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Object readItem(JsonNode node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (node.isObject()) {
|
||||
return readMap((ObjectNode) node);
|
||||
} else if (node.isArray()) {
|
||||
return readList((ArrayNode) node);
|
||||
} else if (node.isValueNode()) {
|
||||
return readJsonPrimitive((ValueNode) node);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final String resource;
|
||||
|
||||
Reference in New Issue
Block a user