Skip to content

Commit 3445a64

Browse files
committed
convert submodule "uritemplate-test" to simple folder
1 parent 15f5226 commit 3445a64

10 files changed

Lines changed: 1203 additions & 6 deletions

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

buildtools/bin/submodule.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

uritemplate-test

Lines changed: 0 additions & 1 deletion
This file was deleted.

uritemplate-test/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
URI Template Tests
3+
==================
4+
5+
This is a set of tests for implementations of
6+
[RFC6570](http://tools.ietf.org/html/rfc6570) - URI Template. It is designed
7+
to be reused by any implementation, to improve interoperability and
8+
implementation quality.
9+
10+
If your project uses Git for version control, you can make uritemplate-tests into a [submodule](http://help.github.com/submodules/).
11+
12+
Test Format
13+
-----------
14+
15+
Each test file is a [JSON](http://tools.ietf.org/html/RFC6627) document
16+
containing an object whose properties are groups of related tests.
17+
Alternatively, all tests are available in XML as well, with the XML files
18+
being generated by transform-json-tests.xslt which uses json2xml.xslt as a
19+
general-purpose JSON-to-XML parsing library.
20+
21+
Each group, in turn, is an object with three children:
22+
23+
* level - the level of the tests covered, as per the RFC (optional; if absent,
24+
assume level 4).
25+
* variables - an object representing the variables that are available to the
26+
tests in the suite
27+
* testcases - a list of testcases, where each case is a two-member list, the
28+
first being the template, the second being the result of expanding the
29+
template with the provided variables.
30+
31+
Note that the result string can be a few different things:
32+
33+
* string - if the second member is a string, the result of expansion is
34+
expected to match it, character-for-character.
35+
* list - if the second member is a list of strings, the result of expansion
36+
is expected to match one of them; this allows for templates that can
37+
expand into different, equally-acceptable URIs.
38+
* false - if the second member is boolean false, expansion is expected to
39+
fail (i.e., the template was invalid).
40+
41+
For example:
42+
43+
{
44+
"Level 1 Examples" :
45+
{
46+
"level": 1,
47+
"variables": {
48+
"var" : "value",
49+
"hello" : "Hello World!"
50+
},
51+
"testcases" : [
52+
["{var}", "value"],
53+
["{hello}", "Hello%20World%21"]
54+
]
55+
}
56+
}
57+
58+
59+
Tests Included
60+
--------------
61+
62+
The following test files are included:
63+
64+
* spec-examples.json - The complete set of example templates from the RFC
65+
* spec-examples-by-section.json - The examples, section by section
66+
* extended-tests.json - more complex test cases
67+
* negative-tests.json - invalid templates
68+
69+
For all these test files, XML versions with the names *.xml can be
70+
generated with the transform-json-tests.xslt XSLT stylesheet. The XSLT
71+
contains the names of the above test files as a parameter, and can be
72+
started with any XML as input (i.e., the XML input is ignored).
73+
74+
License
75+
-------
76+
77+
Copyright 2011-2012 The Authors
78+
79+
Licensed under the Apache License, Version 2.0 (the "License");
80+
you may not use this file except in compliance with the License.
81+
You may obtain a copy of the License at
82+
83+
http://www.apache.org/licenses/LICENSE-2.0
84+
85+
Unless required by applicable law or agreed to in writing, software
86+
distributed under the License is distributed on an "AS IS" BASIS,
87+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
88+
See the License for the specific language governing permissions and
89+
limitations under the License.
90+
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"Additional Examples 1":{
3+
"level":4,
4+
"variables":{
5+
"id" : "person",
6+
"token" : "12345",
7+
"fields" : ["id", "name", "picture"],
8+
"format" : "json",
9+
"q" : "URI Templates",
10+
"page" : "5",
11+
"lang" : "en",
12+
"geocode" : ["37.76","-122.427"],
13+
"first_name" : "John",
14+
"last.name" : "Doe",
15+
"Some%20Thing" : "foo",
16+
"number" : 6,
17+
"long" : 37.76,
18+
"lat" : -122.427,
19+
"group_id" : "12345",
20+
"query" : "PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?book ?who WHERE { ?book dc:creator ?who }",
21+
"uri" : "http://example.org/?uri=http%3A%2F%2Fexample.org%2F",
22+
"word" : "drücken",
23+
"Stra%C3%9Fe" : "Grüner Weg",
24+
"random" : "šö䟜ñꀣ¥‡ÑÒÓÔÕÖרÙÚàáâãäåæçÿ",
25+
"assoc_special_chars" :
26+
{ "šö䟜ñꀣ¥‡ÑÒÓÔÕ" : "ÖרÙÚàáâãäåæçÿ" }
27+
},
28+
"testcases":[
29+
30+
[ "{/id*}" , "/person" ],
31+
[ "{/id*}{?fields,first_name,last.name,token}" , [
32+
"/person?fields=id,name,picture&first_name=John&last.name=Doe&token=12345",
33+
"/person?fields=id,picture,name&first_name=John&last.name=Doe&token=12345",
34+
"/person?fields=picture,name,id&first_name=John&last.name=Doe&token=12345",
35+
"/person?fields=picture,id,name&first_name=John&last.name=Doe&token=12345",
36+
"/person?fields=name,picture,id&first_name=John&last.name=Doe&token=12345",
37+
"/person?fields=name,id,picture&first_name=John&last.name=Doe&token=12345"]
38+
],
39+
["/search.{format}{?q,geocode,lang,locale,page,result_type}",
40+
[ "/search.json?q=URI%20Templates&geocode=37.76,-122.427&lang=en&page=5",
41+
"/search.json?q=URI%20Templates&geocode=-122.427,37.76&lang=en&page=5"]
42+
],
43+
["/test{/Some%20Thing}", "/test/foo" ],
44+
["/set{?number}", "/set?number=6"],
45+
["/loc{?long,lat}" , "/loc?long=37.76&lat=-122.427"],
46+
["/base{/group_id,first_name}/pages{/page,lang}{?format,q}","/base/12345/John/pages/5/en?format=json&q=URI%20Templates"],
47+
["/sparql{?query}", "/sparql?query=PREFIX%20dc%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%20SELECT%20%3Fbook%20%3Fwho%20WHERE%20%7B%20%3Fbook%20dc%3Acreator%20%3Fwho%20%7D"],
48+
["/go{?uri}", "/go?uri=http%3A%2F%2Fexample.org%2F%3Furi%3Dhttp%253A%252F%252Fexample.org%252F"],
49+
["/service{?word}", "/service?word=dr%C3%BCcken"],
50+
["/lookup{?Stra%C3%9Fe}", "/lookup?Stra%C3%9Fe=Gr%C3%BCner%20Weg"],
51+
["{random}" , "%C5%A1%C3%B6%C3%A4%C5%B8%C5%93%C3%B1%C3%AA%E2%82%AC%C2%A3%C2%A5%E2%80%A1%C3%91%C3%92%C3%93%C3%94%C3%95%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%BF"],
52+
["{?assoc_special_chars*}", "?%C5%A1%C3%B6%C3%A4%C5%B8%C5%93%C3%B1%C3%AA%E2%82%AC%C2%A3%C2%A5%E2%80%A1%C3%91%C3%92%C3%93%C3%94%C3%95=%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%BF"]
53+
]
54+
},
55+
"Additional Examples 2":{
56+
"level":4,
57+
"variables":{
58+
"id" : ["person","albums"],
59+
"token" : "12345",
60+
"fields" : ["id", "name", "picture"],
61+
"format" : "atom",
62+
"q" : "URI Templates",
63+
"page" : "10",
64+
"start" : "5",
65+
"lang" : "en",
66+
"geocode" : ["37.76","-122.427"]
67+
},
68+
"testcases":[
69+
70+
[ "{/id*}" , ["/person/albums","/albums/person"] ],
71+
[ "{/id*}{?fields,token}" , [
72+
"/person/albums?fields=id,name,picture&token=12345",
73+
"/person/albums?fields=id,picture,name&token=12345",
74+
"/person/albums?fields=picture,name,id&token=12345",
75+
"/person/albums?fields=picture,id,name&token=12345",
76+
"/person/albums?fields=name,picture,id&token=12345",
77+
"/person/albums?fields=name,id,picture&token=12345",
78+
"/albums/person?fields=id,name,picture&token=12345",
79+
"/albums/person?fields=id,picture,name&token=12345",
80+
"/albums/person?fields=picture,name,id&token=12345",
81+
"/albums/person?fields=picture,id,name&token=12345",
82+
"/albums/person?fields=name,picture,id&token=12345",
83+
"/albums/person?fields=name,id,picture&token=12345"]
84+
]
85+
]
86+
},
87+
"Additional Examples 3: Empty Variables":{
88+
"variables" : {
89+
"empty_list" : [],
90+
"empty_assoc" : {}
91+
},
92+
"testcases":[
93+
[ "{/empty_list}", [ "" ] ],
94+
[ "{/empty_list*}", [ "" ] ],
95+
[ "{?empty_list}", [ ""] ],
96+
[ "{?empty_list*}", [ "" ] ],
97+
[ "{?empty_assoc}", [ "" ] ],
98+
[ "{?empty_assoc*}", [ "" ] ]
99+
]
100+
},
101+
"Additional Examples 4: Numeric Keys":{
102+
"variables" : {
103+
"42" : "The Answer to the Ultimate Question of Life, the Universe, and Everything",
104+
"1337" : ["leet", "as","it", "can","be"],
105+
"german" : {
106+
"11": "elf",
107+
"12": "zwölf"
108+
}
109+
},
110+
"testcases":[
111+
[ "{42}", "The%20Answer%20to%20the%20Ultimate%20Question%20of%20Life%2C%20the%20Universe%2C%20and%20Everything"],
112+
[ "{?42}", "?42=The%20Answer%20to%20the%20Ultimate%20Question%20of%20Life%2C%20the%20Universe%2C%20and%20Everything"],
113+
[ "{1337}", "leet,as,it,can,be"],
114+
[ "{?1337*}", "?1337=leet&1337=as&1337=it&1337=can&1337=be"],
115+
[ "{?german*}", [ "?11=elf&12=zw%C3%B6lf", "?12=zw%C3%B6lf&11=elf"] ]
116+
]
117+
},
118+
"Additional Examples 5: Explode Combinations":{
119+
"variables" : {
120+
"id" : "admin",
121+
"token" : "12345",
122+
"tab" : "overview",
123+
"keys" : {
124+
"key1": "val1",
125+
"key2": "val2"
126+
}
127+
},
128+
"testcases":[
129+
[ "{?id,token,keys*}", [
130+
"?id=admin&token=12345&key1=val1&key2=val2",
131+
"?id=admin&token=12345&key2=val2&key1=val1"]
132+
],
133+
[ "{/id}{?token,keys*}", [
134+
"/admin?token=12345&key1=val1&key2=val2",
135+
"/admin?token=12345&key2=val2&key1=val1"]
136+
],
137+
[ "{?id,token}{&keys*}", [
138+
"?id=admin&token=12345&key1=val1&key2=val2",
139+
"?id=admin&token=12345&key2=val2&key1=val1"]
140+
],
141+
[ "/user{/id}{?token,tab}{&keys*}", [
142+
"/user/admin?token=12345&tab=overview&key1=val1&key2=val2",
143+
"/user/admin?token=12345&tab=overview&key2=val2&key1=val1"]
144+
]
145+
]
146+
}
147+
}

0 commit comments

Comments
 (0)