Skip to content

Commit 278dce3

Browse files
committed
Set up option to run the old 1.1 test suite
See jsonld-java#265
1 parent 906cdef commit 278dce3

3,220 files changed

Lines changed: 24460 additions & 30 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/main/java/com/github/jsonldjava/core/JsonLdOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public JsonLdOptions copy() {
8585
private Object expandContext = null;
8686
/**
8787
* http://www.w3.org/TR/json-ld-api/#widl-JsonLdOptions-processingMode
88+
* jsonld 1.1: https://www.w3.org/TR/json-ld11/#dfn-processing-mode
8889
*/
8990
private String processingMode = JSON_LD_1_1;
9091
/**

core/src/test/java/com/github/jsonldjava/core/JsonLdProcessorTest.java

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
@RunWith(Parameterized.class)
4646
public class JsonLdProcessorTest {
4747

48-
private static final String TEST_DIR = "json-ld.org";
48+
private static final String TEST_DIR = "json-ld-api-tests";
49+
// option: run the old 1.0 test suite:
50+
// private static final String TEST_DIR = "json-ld.org-tests";
51+
4952
private static final String MANIFEST_FILE = "manifest.jsonld";
5053

5154
private static Map<String, Object> REPORT;
@@ -186,36 +189,8 @@ public static Collection<Object[]> data() throws URISyntaxException, IOException
186189

187190
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
188191
final File testDir = new File(cl.getResource(TEST_DIR).toURI());
189-
final File mainManifestFile = new File(testDir, MANIFEST_FILE);
190-
191-
final Map<String, Object> mainManifest = (Map<String, Object>) JsonUtils
192-
.fromInputStream(new FileInputStream(mainManifestFile));
193192

194-
final List<String> manifestFileNames = (List<String>) mainManifest
195-
.get("sequence");
196-
197-
final List<File> manifestfiles = new ArrayList<File>();
198-
199-
for (final String manifestFileName : manifestFileNames) {
200-
System.out.println("Using manifest: " + testDir + " " + manifestFileName);
201-
manifestfiles.add(new File(testDir, manifestFileName));
202-
}
203-
204-
// final List<File> manifestfiles = Arrays.asList(f.listFiles(new FilenameFilter() {
205-
// @Override
206-
// public boolean accept(File dir, String name) {
207-
// if (name.contains("manifest") && name.endsWith(".jsonld") && !name.equals("manifest.jsonld")) {
208-
// System.out.println("Using manifest: " + dir + " "
209-
// + name);
210-
// // Remote-doc tests are not currently supported
211-
// if (name.contains("remote-doc")) {
212-
// return false;
213-
// }
214-
// return true;
215-
// }
216-
// return false;
217-
// }
218-
// }));
193+
final List<File> manifestfiles = loadManifestFiles(testDir);
219194

220195
final Collection<Object[]> rdata = new ArrayList<Object[]>();
221196
for (final File in : manifestfiles) {
@@ -246,6 +221,40 @@ public static Collection<Object[]> data() throws URISyntaxException, IOException
246221
return rdata;
247222
}
248223

224+
private static List<File> loadManifestFiles(final File testDir) {
225+
List<File> manifestfiles = new ArrayList<File>();
226+
if (testDir.getName().equals("json-ld-api-tests")) {
227+
final File mainManifestFile = new File(testDir, MANIFEST_FILE);
228+
Map<String, Object> mainManifest;
229+
try {
230+
mainManifest = (Map<String, Object>) JsonUtils.fromInputStream(new FileInputStream(mainManifestFile));
231+
final List<String> manifestFileNames = (List<String>) mainManifest.get("sequence");
232+
for (final String manifestFileName : manifestFileNames) {
233+
System.out.println("Using manifest: " + testDir + " " + manifestFileName);
234+
manifestfiles.add(new File(testDir, manifestFileName));
235+
}
236+
} catch (IOException e) {
237+
e.printStackTrace();
238+
}
239+
} else {
240+
manifestfiles = Arrays.asList(testDir.listFiles(new FilenameFilter() {
241+
@Override
242+
public boolean accept(File dir, String name) {
243+
if (name.contains("manifest") && name.endsWith(".jsonld") && !name.equals("manifest.jsonld")) {
244+
System.out.println("Using manifest: " + dir + " " + name);
245+
// Remote-doc tests are not currently supported
246+
if (name.contains("remote-doc")) {
247+
return false;
248+
}
249+
return true;
250+
}
251+
return false;
252+
}
253+
}));
254+
}
255+
return manifestfiles;
256+
}
257+
249258
private class TestDocumentLoader extends DocumentLoader {
250259

251260
private final String base;

core/src/test/resources/json-ld.org/compact-manifest.jsonld renamed to core/src/test/resources/json-ld-api-tests/compact-manifest.jsonld

File renamed without changes.

core/src/test/resources/json-ld.org/compact/0001-context.jsonld renamed to core/src/test/resources/json-ld-api-tests/compact/0001-context.jsonld

File renamed without changes.

core/src/test/resources/json-ld.org/compact/0001-in.jsonld renamed to core/src/test/resources/json-ld-api-tests/compact/0001-in.jsonld

File renamed without changes.

core/src/test/resources/json-ld.org/compact/0001-out.jsonld renamed to core/src/test/resources/json-ld-api-tests/compact/0001-out.jsonld

File renamed without changes.

core/src/test/resources/json-ld.org/compact/0002-context.jsonld renamed to core/src/test/resources/json-ld-api-tests/compact/0002-context.jsonld

File renamed without changes.

core/src/test/resources/json-ld.org/compact/0002-in.jsonld renamed to core/src/test/resources/json-ld-api-tests/compact/0002-in.jsonld

File renamed without changes.

0 commit comments

Comments
 (0)