Introduce support for JSON as a test result type, including sample test case.
Change-Id: If2e0454e30b62f52311e156beed0024f615669ce
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/92
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <westmann@gmail.com>
diff --git a/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java b/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java
index 8cca085..b3e4de9e 100644
--- a/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java
+++ b/asterix-test-framework/src/main/java/edu/uci/ics/asterix/testframework/context/TestCaseContext.java
@@ -28,6 +28,47 @@
import edu.uci.ics.asterix.testframework.xml.TestSuiteParser;
public class TestCaseContext {
+
+ /**
+ * For specifying the desired output formatting of results.
+ */
+ public enum OutputFormat {
+ NONE ("", ""),
+ ADM ("adm", "application/adm"),
+ JSON ("json", "application/json");
+
+ private final String extension;
+ private final String mimetype;
+ OutputFormat(String ext, String mime) {
+ this.extension = ext;
+ this.mimetype = mime;
+ }
+
+ public String extension() {
+ return extension;
+ }
+
+ public String mimeType() {
+ return mimetype;
+ }
+
+ //
+ public static OutputFormat forCompilationUnit(CompilationUnit cUnit) {
+ switch (cUnit.getOutputDir().getCompare()) {
+ case TEXT:
+ return OutputFormat.ADM;
+ case JSON:
+ return OutputFormat.JSON;
+ case INSPECT:
+ case IGNORE:
+ return OutputFormat.NONE;
+ default:
+ assert false: "Unknown ComparisonEnum!";
+ return OutputFormat.NONE;
+ }
+ }
+ };
+
public static final String DEFAULT_TESTSUITE_XML_NAME = "testsuite.xml";
private File tsRoot;
@@ -108,7 +149,8 @@
File path = actualResultsBase;
path = new File(path, testSuite.getResultOffsetPath());
path = new File(path, testCase.getFilePath());
- return new File(path, cUnit.getOutputDir().getValue() + ".adm");
+ return new File(path, cUnit.getOutputDir().getValue() + "." +
+ OutputFormat.forCompilationUnit(cUnit).extension());
}
public static class Builder {
diff --git a/asterix-test-framework/src/main/resources/Catalog.xsd b/asterix-test-framework/src/main/resources/Catalog.xsd
index 763309e..78c401e 100644
--- a/asterix-test-framework/src/main/resources/Catalog.xsd
+++ b/asterix-test-framework/src/main/resources/Catalog.xsd
@@ -186,6 +186,7 @@
<xs:enumeration value="Text"/>
<xs:enumeration value="Inspect"/>
<xs:enumeration value="Ignore"/>
+ <xs:enumeration value="JSON"/>
</xs:restriction>
</xs:simpleType>