Skip to content

Commit aaaf6d2

Browse files
committed
Set up option to run the json-ld-framing test suite
1 parent 7783fc7 commit aaaf6d2

File tree

261 files changed

+8345
-1
lines changed

Some content is hidden

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

261 files changed

+8345
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747
public class JsonLdProcessorTest {
4848

4949
private static final String TEST_DIR = "json-ld-api-tests";
50+
// option: run the json-ld-framing test suite:
51+
// (https://github.com/w3c/json-ld-framing/blob/master/tests/README.md)
52+
// private static final String TEST_DIR = "json-ld-framing-tests";
5053
// option: run the old 1.0 test suite:
54+
// (https://github.com/json-ld/json-ld.org/tree/master/test-suite/tests)
5155
// private static final String TEST_DIR = "json-ld-1.0-tests";
5256

5357
private static final String MANIFEST_FILE = "manifest.jsonld";
@@ -226,7 +230,7 @@ public static Collection<Object[]> data() throws URISyntaxException, IOException
226230

227231
private static List<File> loadManifestFiles(final File testDir) {
228232
List<File> manifestfiles = new ArrayList<File>();
229-
if (testDir.getName().equals("json-ld-api-tests")) {
233+
if (!testDir.getName().equals("json-ld-1.0-tests")) {
230234
final File mainManifestFile = new File(testDir, MANIFEST_FILE);
231235
Map<String, Object> mainManifest;
232236
try {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The JSON-LD Test Suite is covered by the dual-licensing approach described in
2+
[LICENSES FOR W3C TEST SUITES](https://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html).
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Introduction
2+
3+
The JSON-LD Test Suite is a set of tests that can
4+
be used to verify JSON-LD Processor conformance to the set of specifications
5+
that constitute JSON-LD. The goal of the suite is to provide an easy and
6+
comprehensive JSON-LD testing solution for developers creating JSON-LD Processors.
7+
8+
More information and an RDFS definition of the test vocabulary can be found at [vocab](https://w3c.github.io/json-ld-api/tests/vocab).
9+
10+
# Design
11+
12+
Tests driven from a top-level [manifest](manifest.jsonld) and are defined for [frame](frame-manifest.jsonld):
13+
14+
* [frame](frame-manifest.jsonld) tests have _input_, _frame_ and _expected_ documents. The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output. Additionally, if the `ordered` option is not set, result should be expanded and compared with the expanded _expected_ document also using [JSON-LD object comparison](#json-ld-object-comparison).
15+
16+
For *NegativeEvaluationTests*, the result is a string associated with the expected error code.
17+
18+
Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`.
19+
20+
Test results that include a context input presume that the context is provided locally, and not from the referenced location, thus the results will include the content of the context file, rather than a reference.
21+
22+
## JSON-LD Object comparison
23+
24+
If algorithms are invoked with the `ordered` flag set to `true`, simple JSON Object comparison may be used, as the order of all arrays will be preserved (except for _fromRdf_, unless the input quads are also ordered). If `ordered` is `false`, then the following algorithm will ensure arrays other than values of `@list` are compared without regard to order.
25+
26+
JSON-LD Object comparison compares JSON objects, arrays, and values recursively for equality.
27+
28+
* JSON objects are compared member by member without regard to the ordering of members within the object. Each member must have a corresponding member in the object being compared to. Values are compared recursively.
29+
* JSON arrays are generally compared without regard to order (the lone exception being if the referencing key is `@list`). Each item within the array must be equivalent to an item in the array being compared to by using the comparison algorithm recursively. For values of `@list`, the order of these items is significant.
30+
* JSON values are compared using strict equality.
31+
* Values of `@language`, and other places where language tags may be used are specified in lowercase in the test results. Implementations should either normalize language tags for testing purposes, or compare language tags in a case-independent way.
32+
33+
Note that some tests require re-expansion and comparison, as list values may exist as values of properties that have `@container: @list` and the comparison algorithm will not consider ordering significant.
34+
35+
# Running tests
36+
37+
The top-level [manifest](manifest.jsonld) references the specific test manifests, which in turn reference each test associated with a particular type of behavior.
38+
Implementations create their own infrastructure for running the test suite. In particular, the following should be considered:
39+
40+
* Some algorithms, may not preserve the order of statements listed in the input document, and provision should be taken for performing unordered array comparison, for arrays other than values of `@list`. (This may be difficult for compacted results, where array value ordering is dependent on the associated term definition).
41+
* Some implementations may choose an alternative Blank Node Label algorithm, the comparison between documents containing blank node labels should take this into consideration. (One way to do this may be to reduce both results and _expected_ to datsets to extract a bijective mapping of blank node labels between the two datasets as described in [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism)).
42+
* Note that the `"@embed": "@once"` test behavior requires that the `ordered` option be set to `true` for repeatability.
43+
44+
# Contributing
45+
46+
If you would like to contribute a new test or a fix to an existing test,
47+
please follow these steps:
48+
49+
1. Notify the JSON-LD mailing list, public-json-ld-wg@w3.org,
50+
that you will be creating a new test or fix and the purpose of the
51+
change.
52+
2. Clone the git repository: git://github.com/w3c/json-ld-framing.git
53+
3. Make your changes and submit them via github, or via a 'git format-patch'
54+
to the [JSON-LD Working Group mailing list](mailto:json-ld-wg@w3.org).
55+
56+
# Distribution
57+
Distributed under the [W3C Test Suite License](http://www.w3.org/Consortium/Legal/2008/04-testsuite-license). To contribute to a W3C Test Suite, see the [policies and contribution forms](http://www.w3.org/2004/10/27-testcases).
58+
59+
# Disclaimer
60+
UNDER THE EXCLUSIVE LICENSE, THIS DOCUMENT AND ALL DOCUMENTS, TESTS AND SOFTWARE THAT LINK THIS STATEMENT ARE PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
61+
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'bundler/setup'
2+
require 'haml'
3+
require 'json'
4+
task default: %w(
5+
manifest.html
6+
frame-manifest.html)
7+
8+
# Rule to build HTML files
9+
rule '.html' => ['.jsonld', 'template.haml'] do |task|
10+
puts "build #{task.name} from #{task.prerequisites.first}"
11+
@template ||= File.read(File.expand_path('../template.haml', __FILE__))
12+
@engine ||= Haml::Engine.new(@template, format: :html5)
13+
manifest = JSON.parse File.read(File.expand_path("../#{task.prerequisites.first}", __FILE__))
14+
html = @engine.render(self, manifest: manifest, json_file: task.prerequisites.first)
15+
File.open(File.expand_path("../#{task.name}", __FILE__), "w") {|f| f.write(html)}
16+
end

0 commit comments

Comments
 (0)