Skip to content

Commit 60cc303

Browse files
committed
feat: add test spec
- I envision that the spec tests can only test a tree:Node (basic elements of the Tree), or a part of the full tree graph, therefore I made these two categories in the conformance points. - The tests, in my view, need to emphasize the minimum requirements of a TREE implementation (the content of the TREE). - I included the generated HTML in the PR as well. Please feel free to comment on the current version. I would like to collect feedback on the current format and will remove the HTML once the PR is settled.
1 parent b3b47fb commit 60cc303

File tree

2 files changed

+875
-37
lines changed

2 files changed

+875
-37
lines changed

04-tests.bs

Lines changed: 90 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,116 @@ Mailing List Archives: https://lists.w3.org/Archives/Public/public-treecg/
1111
Editor:
1212
- Pieter Colpaert, https://pietercolpaert.be
1313
- Xueying Deng, https://xdxxxdx.github.io/
14-
Abstract: The TREE test specification aims to provide enough resource that for a TREE implementation to be able to test itself against the TREE specification.This test specification will be continuously updated to align with changes and improvements in the TREE specification.
14+
Abstract: The TREE test specification aims to provide resource that for a TREE implementation to be able to test itself against the TREE specification.This test specification will be continuously updated to align with changes and improvements in the TREE specification.
1515
</pre>
1616
# Overview # {#overview}
1717

1818
The TREE specification follows the [RFC 2119](https://www.rfc-editor.org/rfc2119.txt) norms for defining conformance requirements.
19-
This document lists all conformance points from the TREE specification, and provides corresponding test cases, test environments, and expected results for implementations.
19+
This document outlines the minimum conformance requirements from the TREE specification and provides corresponding test cases to verify the compliance.
2020
<!-- (#ToBeDecided) The test specification focuses on TREE client behaviors. -->
2121

22-
## Conformance ## {#conformance}
22+
# Conformance Points # {#conformance-points}
2323

2424
The conformance points in this document are based on the [TREE specification](https://w3c.github.io/treecg/specification/) and are intended for testing implementations of the TREE specification.
2525

26-
As TREE is based on hypermedia, the conformance is designed for HTTP-based implementation, the test cases are designed to be executed over HTTP(s), and the expected results are based on the HTTP(s) responses.
26+
TREE conformance is designed for HTTP-based implementations; all test cases are expected to be executed over HTTP(s), and results are determined from the HTTP(s) responses. Since TREE is an RDF (Resource Description Framework) specification, all response payloads must use standard RDF serialization formats, such as Turtle, RDF/XML, or JSON-LD.
2727

28-
Conformance points are divided into two categories: **MUST** and **SHOULD**.
2928

30-
Each conformance point is described in detail, including the expected behavior of the implementation. The test cases used to verify compliance are also provided.
29+
<!-- (#ToBeDecided) Maybe we should only keep must? to keep minimum implementation requirements -->
3130

32-
- **MUST** conformance points are mandatory for all implementations. Implementations that do not meet these requirements are not considered compliant with the specification.
33-
- **SHOULD** conformance points are optional but recommended. Implementations that do not meet these requirements may still be considered compliant, but may not provide the same level of functionality or interoperability.
31+
<!-- (#ToBeDecided) The conformance of the TREE contains only two parts, the basic elements of a single nodes, and how these nodes are linked (search tree) -->
3432

35-
<!-- (#ToBeDecided) Maybe we should only keep must? to keep minimum implementation requirements -->
36-
## MUST Conformance Points## {#must}
33+
## TREE basic elements ## {#1.1}
34+
35+
### Subject of `tree:view` must be a `tree:Collection` ### {#1.1.1}
36+
**Description:** When there is a `tree:view` in the payload of the current HTTP(s) response, the subject of the `tree:view` must be a `tree:Collection`
37+
38+
**SHACL shape against the HTTP(s) response:**
39+
```turtle
40+
@prefix sh: <http://www.w3.org/ns/shacl#> .
41+
@prefix tree: <https://w3id.org/tree#> .
3742

38-
### TREE basic elements ### {#1.1}
43+
tree:ViewSubjectConstraintShape
44+
a sh:NodeShape ;
45+
sh:targetSubjectsOf tree:view ;
46+
sh:class tree:Collection ;
47+
sh:message "Subject of tree:view must be a tree:Collection" .
3948

40-
- When there is a `tree:view` in the payload of the current HTTP response, the subject of the `tree:view` must be a `tree:Collection`
49+
```
50+
### Subject of `tree:member` must be either a `tree:Collection` or a `tree:RootNode` ### {#1.1.2}
51+
**Description:** If a `tree:member` property appears in the payload of the current HTTP(s) response, its subject MUST be either a `tree:Collection` or a `tree:RootNode`.
4152

53+
**SHACL shape against the HTTP(s) response:**
4254
```turtle
4355
@prefix sh: <http://www.w3.org/ns/shacl#> .
4456
@prefix tree: <https://w3id.org/tree#> .
45-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4657

47-
# SHACL Node Shape to validate that any subject having tree:view must be a tree:Collection
58+
tree:MemberSubjectConstraintShape
59+
a sh:NodeShape ;
60+
sh:targetSubjectsOf tree:member ;
61+
sh:or (
62+
[ sh:class tree:Collection ]
63+
[ sh:class tree:RootNode ]
64+
) ;
65+
sh:message "Subject of tree:member must be either a tree:Collection or a tree:RootNode" .
66+
67+
```
68+
### `tree:Relation` properties ### {#1.1.3}
69+
70+
**Description:** If a `tree:Relation` appears in the payload of the current HTTP(s) response, it MUST have a `tree:path` property and a `tree:node` property which pointing to another `tree:Node`.
71+
`tree:Relation` is a superclass for all TREE-supported relation types (such as `tree:GreaterThanRelation`, `tree:LessThanRelation`, `tree:GreaterThanOrEqualToRelation`, etc.).
72+
For the complete list of subclasses of `tree:Relation`, see [tree.ttl](https://github.com/TREEcg/specification/blob/master/tree.ttl).
73+
74+
**SHACL shape against the HTTP(s) response:**
75+
```turtle
76+
@prefix sh: <http://www.w3.org/ns/shacl#> .
77+
@prefix tree: <https://w3id.org/tree#> .
4878

49-
<#TreeViewSubjectMustBeCollectionShape>
79+
tree:RelationConstraintShape
5080
a sh:NodeShape ;
51-
sh:targetSubjectsOf tree:view ;
81+
sh:targetClass tree:Relation ;
82+
sh:property [
83+
sh:path tree:path ;
84+
sh:minCount 1 ;
85+
sh:message "tree:Relation must have a tree:path property"
86+
] ;
5287
sh:property [
53-
sh:path rdf:type ;
54-
sh:hasValue tree:Collection ;
55-
sh:message "Subjects that have a tree:view must be a tree:Collection." ;
88+
sh:path tree:node ;
89+
sh:minCount 1 ;
90+
sh:class tree:Node ;
91+
sh:message "tree:Relation must have a tree:node property pointing to a tree:Node"
5692
] .
93+
```
94+
95+
### Initialization of TREE structure via `tree:view` after dereferencing ### {#1.1.4}
96+
**Description:** When a `tree:view` triple exists in the payload of the final HTTP(s) response (after following all redirects), the final IRI MUST be the object of a `tree:view` triple whose subject is a `tree:Collection`. This ensures that dereferencing a resource leads to a valid TREE view associated with a collection.
97+
98+
**SHACL shape against the HTTP(s) response:**
99+
100+
```turtle
101+
@prefix sh: <http://www.w3.org/ns/shacl#> .
102+
@prefix tree: <https://w3id.org/tree#> .
57103

104+
tree:ViewObjectConstraintShape
105+
a sh:NodeShape ;
106+
sh:targetObjectsOf tree:view ;
107+
sh:sparql [
108+
sh:select """
109+
SELECT $this
110+
WHERE {
111+
?collection a tree:Collection .
112+
?collection tree:view $this .
113+
}
114+
""" ;
115+
sh:message "The final IRI must be the object of a tree:view triple whose subject is a tree:Collection"
116+
] .
58117
```
59-
<!-- (#ToBeDecided) host this under tree domain?-->
60-
- When there is a `tree:member` in the payload of the current HTTP response, the subject of the `tree:member` must be a `tree:Collection` or a `tree:RootNode`
61-
- When there is a `tree:Relation` in the payload of the current HTTP response, the subject of the `tree:Relation` must also point to a `tree:path`
118+
## Search TREE ## {#1.2}
119+
120+
### `tree:Node` inbound link uniqueness ### {#1.2.1}
121+
**Description:** During traversal of the TREE structure, each `tree:Node` MUST NOT be the target of more than one inbound `tree:Relation` (i.e., via the `tree:node` property) from a different `tree:Node`. In other words, no `tree:Node` should have more than one parent node. This requirement ensures that the TREE remains a valid tree structure, where each node has at most one parent.
62122

63-
### Search TREE ### {#1.2}
64-
- At any point in the TREE, each `tree:Node` may have at most one inbound link via a `tree:Relation` from another `tree:Node`.
123+
**SHACL shape against the RDF graph:**
65124

66125
```turtle
67126
@prefix sh: <http://www.w3.org/ns/shacl#> .
@@ -87,24 +146,18 @@ ex:NodeInboundUniquenessShape
87146
] .
88147

89148
````
90-
- Whenever `tree:GreaterThanRelation` is used as a comparator within the TREE, the values pointed by `tree:path` in the members MUST be compared using the rules defined in the [SPARQL algebra functions](https://www.w3.org/TR/sparql11-query/#expressions).
91-
<!--
92-
// ### The member extraction algorithm ### {#1.3}
93-
// ### Traversing the search tree ### {#1.4}
94-
// ### Pruning branches ### {#1.5}
149+
### `tree:GreaterThanRelation` ### {#1.2.2}
150+
**Description:** When traversing a TREE structure by following `tree:Relation` links (after making one or more HTTP(s) requests and aggregating the resulting RDF graphs), if a `tree:GreaterThanRelation` is present, then for each member referenced by the relation, the value of the property specified by `tree:path` MUST be greater than the value specified in the relation, according to the comparison rules defined in the [SPARQL algebra functions](https://www.w3.org/TR/sparql11-query/#expressions). This ensures that the `tree:GreaterThanRelation` accurately represents a "greater than" relationship as defined by SPARQL semantics.
151+
152+
153+
### `xsd:dateTime` literals without a timezone comparisons ### {#1.2.3}
154+
**Description:** When traversing a TREE structure, if an implementation employs `xsd:dateTime` literals without an explicit timezone, it MUST treat these values as representing the entire range from that date and time at UTC-14:00 (inclusive) to UTC+14:00 (exclusive). Comparisons involving such `xsd:dateTime` values MUST be performed as interval comparisons: a value without a timezone matches if and only if the comparison holds for at least one instant within this interval. Implementations MUST NOT assume any default timezone or offset for such values.
95155

96156

97-
// ## SHOULD Conformance Points## {#must}
98157

99-
// ### Initialization ### {#2.1}
100-
// ### The member extraction algorithm ### {#2.2}
101-
// ### Traversing the search tree ### {#2.3}
102-
// ### Pruning branches ### {#2.4}
103-
-->
104158
<!--
159+
// Initial version
105160
// TODO
106-
// * SHOULD: The implementation should support this feature.
107-
108161

109162
// # Tests # {#tests}
110163

0 commit comments

Comments
 (0)