Remote document
These tests implement the requirements for JSON-LD Remote Document and Context Retrieval.
This is an HTML version of a test manifest. The JSON-LD version of this manifest may be found at
remote-doc-manifest.jsonld. The manifest vocabulary is described in the JSON-LD Test Vocabulary (JSON-LD, Turtle) and is based on the RDF Test Vocabulary.
The JSON-LD Test Suite is a set of tests that can
be used to verify JSON-LD Processor conformance to the set of specifications
that constitute JSON-LD. The goal of the suite is to provide an easy and
comprehensive JSON-LD testing solution for developers creating JSON-LD Processors.
The JSON-LD Framing Specification maintains its own
test suite.
General instructions for running the JSON-LD Test suites
expand tests have input and expected documents.
The expected results can be compared using JSON-LD object comparison with the processor output.
Expansion tests may have a expandContext
option, which is treated
as an IRI relative to the manifest.
For NegativeEvaluationTests, the result is a string associated with the expected error code.
remote-doc tests have input and expected documents.
The expected results can be compared using JSON-LD object comparison with the processor output.
For NegativeEvaluationTests, the result is a string associated with the expected error code.
Options may be present to describe the intended HTTP behavior:
- contentType: Content-Type of the returned HTTP payload, defaults to the appropriate type for the input suffix.
- httpStatus: The HTTP status code to return, defaults to
200
.
- redirectTo: The HTTP Content-Location header value.
- httpLink: The HTTP Link header value.
Unless processingMode
is set explicitly in a test entry, processingMode
is compatible with both json-ld-1.0
and json-ld-1.1
.
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.
Developers are encouraged to make a local copy of the test suite (available on GitHub) and simulate the behavior of fetching test files remotely and setting HTTP headers as described in a particular test entry.
JSON-LD Object comparison
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.
JSON-LD Object comparison compares JSON objects, arrays, and values recursively for equality.
- JSON objects are compared entry by entry without regard to the ordering of entries within the object. Each entry must have a corresponding entry in the object being compared to. Values are compared recursively.
- 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.
- JSON values are compared using strict equality.
- 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.
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.
Running tests
The top-level manifest references the specific test manifests, which in turn reference each test associated with a particular type of behavior.
Implementations create their own infrastructure for running the test suite. In particular, the following should be considered:
- remote-doc tests will likely not return expected HTTP headers, so the options should be used to determine what headers are associated with the input document.
- Test case properties identifying a file (input, output, context, expectContext, and frame) are presumed to have a media type appropriate for the file extension.
application/ld+json
for .jsonld
text/html
for .html
application/n-quads
for .nq
- The media type for the file associated with the input property can be overridden using the
contentType
option.
- Some algorithms, particularly fromRdf, 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).
- Some toRdf tests require the use of JSON Canonicalization Scheme to properly generate RDF Literals from JSON literal values. This algorithm is non-normative, but is assumed to be used to properly compare results using RDF Dataset Isomorphism. These tests are marked using the
useJCS
option.
- When comparing documents after flattening, framing or generating RDF, blank node identifiers may not be predictable. Implementations using the JSON-LD 1.0 algorithm, where output is always sorted and blank node identifiers are generated sequentially from
_:b0
may continue to use a simple object comparison. Otherwise, implementations 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).
- Some tests may have a
requires
property, indicating some optional behavior described by a test vocabulary term.
Contributing Tests
If you would like to contribute a new test or a fix to an existing test,
please follow these steps:
- Notify the JSON-LD mailing list, public-json-ld-wg@w3.org,
that you will be creating a new test or fix and the purpose of the
change.
- Clone the git repository: git://github.com/w3c/json-ld-api.git
- Make your changes and submit them via github, or via a 'git format-patch'
to the JSON-LD Working Group mailing list.
Distribution
Distributed under the W3C Test Suite License. To contribute to a W3C Test Suite, see the policies and contribution forms.
Disclaimer
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.
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.
- baseIri
- https://w3c.github.io/json-ld-api/tests/
Test sequence:
-
Test t0001 load JSON-LD document
-
- id
- #t0001
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Document loader loads a JSON-LD document.
- input
-
remote-doc/0001-in.jsonld
- expect
-
remote-doc/0001-out.jsonld
-
Test t0002 load JSON document
-
- id
- #t0002
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Document loader loads a JSON document.
- input
-
remote-doc/0002-in.json
- expect
-
remote-doc/0002-out.jsonld
-
Test t0003 load JSON document with extension-type
-
- id
- #t0003
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Document loader loads a JSON document having an extension mime-subtype.
- input
-
remote-doc/0003-in.jldt
- expect
-
remote-doc/0003-out.jsonld
- Options
-
- contentType
- application/jldTest+json
-
Test t0004 loading an unknown type raises loading document failed
-
- id
- #t0004
- Type
- jld:NegativeEvaluationTest, jld:ExpandTest
- Purpose
- Loading a document with a non-JSON mime type raises loading document failed
- input
-
remote-doc/0004-in.jldte
- expect
-
loading document failed
- Options
-
- contentType
- application/jldTest
-
Test t0005 Load JSON-LD through 301 redirect
-
- id
- #t0005
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Loading a document with a redirect should use the redirected URL as document base
- input
-
remote-doc/0005-in.jsonld
- expect
-
remote-doc/0001-out.jsonld
- Options
-
- redirectTo
- remote-doc/0001-in.jsonld
- httpStatus
- 301
-
Test t0006 Load JSON-LD through 303 redirect
-
- id
- #t0006
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Loading a document with a redirect should use the redirected URL as document base
- input
-
remote-doc/0006-in.jsonld
- expect
-
remote-doc/0001-out.jsonld
- Options
-
- redirectTo
- remote-doc/0001-in.jsonld
- httpStatus
- 303
-
Test t0007 Load JSON-LD through 307 redirect
-
- id
- #t0007
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Loading a document with a redirect should use the redirected URL as document base
- input
-
remote-doc/0007-in.jsonld
- expect
-
remote-doc/0001-out.jsonld
- Options
-
- redirectTo
- remote-doc/0001-in.jsonld
- httpStatus
- 307
-
Test t0008 Non-existant file (404)
-
- id
- #t0008
- Type
- jld:NegativeEvaluationTest, jld:ExpandTest
- Purpose
- Loading a non-existant file raises loading document failed error
- input
-
remote-doc/missing-in.jsonld
- expect
-
loading document failed
-
Test t0009 load JSON-LD document with link
-
- id
- #t0009
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- If a context is specified in a link header, it is not used for JSON-LD.
- input
-
remote-doc/0009-in.jsonld
- expect
-
remote-doc/0009-out.jsonld
- Options
-
- httpLink
- <0009-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"
-
Test t0010 load JSON document with link
-
- id
- #t0010
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- If a context is specified in a link header, it is used for JSON.
- input
-
remote-doc/0010-in.json
- expect
-
remote-doc/0010-out.jsonld
- Options
-
- httpLink
- <0010-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"
-
Test t0011 load JSON document with extension-type with link
-
- id
- #t0011
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- If a context is specified in a link header, it is used for a JSON extension type.
- input
-
remote-doc/0011-in.jldt
- expect
-
remote-doc/0011-out.jsonld
- Options
-
- contentType
- application/jldTest+json
- httpLink
- <0011-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"
-
Test t0012 Multiple context link headers
-
- id
- #t0012
- Type
- jld:NegativeEvaluationTest, jld:ExpandTest
- Purpose
- Loading a file when multiple link headers are returned is an error
- input
-
remote-doc/0012-in.json
- expect
-
multiple context link headers
- Options
-
- httpLink
- ["<0012-context1.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"", "<0012-context2.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\""]
-
Test t0013 load JSON document with link to HTML document
-
- id
- #t0013
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- If a context is specified in a link header, it is used for JSON, extracting from HTML.
- input
-
remote-doc/0013-in.json
- expect
-
remote-doc/0013-out.jsonld
- Options
-
- httpLink
- <0013-context.html>; rel="http://www.w3.org/ns/json-ld#context"
-
Test tla01 Redirects if type is text/html
-
- id
- #tla01
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Load an alternate link if type is not ld+json and rel=alternate.
- input
-
remote-doc/la01-in.html
- expect
-
remote-doc/la01-out.jsonld
- Options
-
- httpLink
- <la01-alternate.jsonld>; rel="alternate"; type="application/ld+json"
-
Test tla02 Does not redirect if type is application/ld+json
-
- id
- #tla02
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Load an alternate link if type is not ld+json and rel=alternate.
- input
-
remote-doc/la02-in.jsonld
- expect
-
remote-doc/la02-out.jsonld
- Options
-
- httpLink
- <la02-alternate.jsonld>; rel="alternate"; type="application/ld+json"
- processorFeature
- HTML Script Extraction
-
Test tla03 Does not redirect if link type is not application/ld+json
-
- id
- #tla03
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Load an alternate link if type is not ld+json and rel=alternate.
- input
-
remote-doc/la03-in.json
- expect
-
remote-doc/la03-out.jsonld
- Options
-
- httpLink
- <la03-alternate.json>; rel="alternate"; type="application/json"
-
Test tla04 Does not redirect if type is application/json
-
- id
- #tla04
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Load an alternate link if type is not ld+json and rel=alternate.
- input
-
remote-doc/la04-in.json
- expect
-
remote-doc/la04-out.jsonld
- Options
-
- httpLink
- <la04-alternate.jsonld>; rel="alternate"; type="application/ld+json"
-
Test tla05 Base is that of the alternate URL
-
- id
- #tla05
- Type
- jld:PositiveEvaluationTest, jld:ExpandTest
- Purpose
- Load an alternate link if type is not ld+json and rel=alternate.
- input
-
remote-doc/la05-in.html
- expect
-
remote-doc/la05-out.jsonld
- Options
-
- httpLink
- <la05-alternate.jsonld>; rel="alternate"; type="application/ld+json"
- processorFeature
- HTML Script Extraction