Skip to content

Commit 7043ae1

Browse files
committed
Set up tests for multiple test suites and 1.1 development
- Set up tests for json-ld-api, json-ld-framing, and json-ld-1.0 - Run only json-ld-1.0 suite in Maven build (by naming convention) - Run all suites for development of 1.1 features (AllSuites.java)
1 parent aaaf6d2 commit 7043ae1

File tree

5 files changed

+218
-73
lines changed

5 files changed

+218
-73
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.github.jsonldjava.specs;
2+
3+
import org.junit.runner.RunWith;
4+
import org.junit.runners.Suite;
5+
import org.junit.runners.Suite.SuiteClasses;
6+
7+
@RunWith(Suite.class)
8+
@SuiteClasses({ JsonLdApiSuite.class, JsonLdFramingSuite.class, JsonLd1Tests.class })
9+
public class AllSuites {
10+
11+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.github.jsonldjava.specs;
2+
3+
import java.io.IOException;
4+
import java.net.URISyntaxException;
5+
import java.util.Collection;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import org.junit.AfterClass;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
import org.junit.runners.Parameterized;
13+
import org.junit.runners.Parameterized.Parameters;
14+
15+
import com.fasterxml.jackson.core.JsonGenerationException;
16+
import com.fasterxml.jackson.databind.JsonMappingException;
17+
import com.github.jsonldjava.core.JsonLdError;
18+
import com.github.jsonldjava.utils.SuiteUtils;
19+
20+
/**
21+
* Run the test suite from
22+
* https://github.com/json-ld/json-ld.org/tree/master/test-suite/tests
23+
*/
24+
@RunWith(Parameterized.class)
25+
public class JsonLd1Tests {
26+
private static final String TEST_DIR = "json-ld-1.0-tests";
27+
private static final String REPORT_OUT = "reports/" + TEST_DIR + "-report";
28+
29+
private static Map<String, Object> REPORT = SuiteUtils.generateReport();
30+
@SuppressWarnings("unchecked")
31+
private static List<Object> REPORT_GRAPH = (List<Object>) REPORT.get("@graph");
32+
33+
private final String group;
34+
private final Map<String, Object> test;
35+
36+
public JsonLd1Tests(final String group, final String id, final Map<String, Object> test) {
37+
this.group = group;
38+
this.test = test;
39+
}
40+
41+
@Parameters(name = "{0}|{1}")
42+
public static Collection<Object[]> data() throws URISyntaxException, IOException {
43+
return SuiteUtils.getData(TEST_DIR);
44+
}
45+
46+
@Test
47+
public void runTest() throws URISyntaxException, IOException, JsonLdError {
48+
SuiteUtils.run(TEST_DIR, group, test, REPORT_GRAPH);
49+
}
50+
51+
@AfterClass
52+
public static void writeReport()
53+
throws JsonGenerationException, JsonMappingException, IOException, JsonLdError {
54+
// pass VM param: -Dreport.format=jsonld
55+
SuiteUtils.writeReport(REPORT, REPORT_OUT);
56+
}
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.github.jsonldjava.specs;
2+
3+
import java.io.IOException;
4+
import java.net.URISyntaxException;
5+
import java.util.Collection;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import org.junit.AfterClass;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
import org.junit.runners.Parameterized;
13+
import org.junit.runners.Parameterized.Parameters;
14+
15+
import com.fasterxml.jackson.core.JsonGenerationException;
16+
import com.fasterxml.jackson.databind.JsonMappingException;
17+
import com.github.jsonldjava.core.JsonLdError;
18+
import com.github.jsonldjava.utils.SuiteUtils;
19+
20+
/**
21+
* Run the test suite from
22+
* https://github.com/w3c/json-ld-api/blob/master/tests/README.md
23+
*/
24+
@RunWith(Parameterized.class)
25+
public class JsonLdApiSuite {
26+
private static final String TEST_DIR = "json-ld-api-tests";
27+
private static final String REPORT_OUT = "reports/" + TEST_DIR + "-report";
28+
29+
private static Map<String, Object> REPORT = SuiteUtils.generateReport();
30+
@SuppressWarnings("unchecked")
31+
private static List<Object> REPORT_GRAPH = (List<Object>) REPORT.get("@graph");
32+
33+
private final String group;
34+
private final Map<String, Object> test;
35+
36+
public JsonLdApiSuite(final String group, final String id, final Map<String, Object> test) {
37+
this.group = group;
38+
this.test = test;
39+
}
40+
41+
@Parameters(name = "{0}|{1}")
42+
public static Collection<Object[]> data() throws URISyntaxException, IOException {
43+
return SuiteUtils.getData(TEST_DIR);
44+
}
45+
46+
@Test
47+
public void runTest() throws URISyntaxException, IOException, JsonLdError {
48+
SuiteUtils.run(TEST_DIR, group, test, REPORT_GRAPH);
49+
}
50+
51+
@AfterClass
52+
public static void writeReport()
53+
throws JsonGenerationException, JsonMappingException, IOException, JsonLdError {
54+
// pass VM param: -Dreport.format=jsonld
55+
SuiteUtils.writeReport(REPORT, REPORT_OUT);
56+
}
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.github.jsonldjava.specs;
2+
3+
import java.io.IOException;
4+
import java.net.URISyntaxException;
5+
import java.util.Collection;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import org.junit.AfterClass;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
import org.junit.runners.Parameterized;
13+
import org.junit.runners.Parameterized.Parameters;
14+
15+
import com.fasterxml.jackson.core.JsonGenerationException;
16+
import com.fasterxml.jackson.databind.JsonMappingException;
17+
import com.github.jsonldjava.core.JsonLdError;
18+
import com.github.jsonldjava.utils.SuiteUtils;
19+
20+
/**
21+
* Run the test suite from
22+
* https://github.com/w3c/json-ld-framing/blob/master/tests/README.md
23+
*/
24+
@RunWith(Parameterized.class)
25+
public class JsonLdFramingSuite {
26+
private static final String TEST_DIR = "json-ld-framing-tests";
27+
private static final String REPORT_OUT = "reports/" + TEST_DIR + "-report";
28+
29+
private static Map<String, Object> REPORT = SuiteUtils.generateReport();
30+
@SuppressWarnings("unchecked")
31+
private static List<Object> REPORT_GRAPH = (List<Object>) REPORT.get("@graph");
32+
33+
private final String group;
34+
private final Map<String, Object> test;
35+
36+
public JsonLdFramingSuite(final String group, final String id, final Map<String, Object> test) {
37+
this.group = group;
38+
this.test = test;
39+
}
40+
41+
@Parameters(name = "{0}|{1}")
42+
public static Collection<Object[]> data() throws URISyntaxException, IOException {
43+
return SuiteUtils.getData(TEST_DIR);
44+
}
45+
46+
@Test
47+
public void runTest() throws URISyntaxException, IOException, JsonLdError {
48+
SuiteUtils.run(TEST_DIR, group, test, REPORT_GRAPH);
49+
}
50+
51+
@AfterClass
52+
public static void writeReport()
53+
throws JsonGenerationException, JsonMappingException, IOException, JsonLdError {
54+
// pass VM param: -Dreport.format=jsonld
55+
SuiteUtils.writeReport(REPORT, REPORT_OUT);
56+
}
57+
}

0 commit comments

Comments
 (0)