Skip to content

Commit

Permalink
added XSLT and generated XML, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Wilde committed Dec 11, 2012
1 parent 75616a2 commit e2127e0
Show file tree
Hide file tree
Showing 7 changed files with 1,544 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,9 @@ Test Format


Each test file is a [JSON](http://tools.ietf.org/html/RFC6627) document Each test file is a [JSON](http://tools.ietf.org/html/RFC6627) document
containing an object whose properties are groups of related tests. containing an object whose properties are groups of related tests.
Alternatively, all tests are available in XML as well, with the XML files
being generated by transform-json-tests.xslt which uses json2xml.xslt as a
general-purpose JSON-to-XML parsing library.


Each group, in turn, is an object with three children: Each group, in turn, is an object with three children:


Expand Down Expand Up @@ -63,6 +66,8 @@ The following test files are included:
* extended-tests.json - more complex test cases * extended-tests.json - more complex test cases
* negative-tests.json - invalid templates * negative-tests.json - invalid templates


For all these test files, versions name *.xml are available as well.

License License
------- -------


Expand Down
200 changes: 200 additions & 0 deletions extended-tests.xml
@@ -0,0 +1,200 @@
<?xml version="1.0" encoding="UTF-8"?>
<tests>
<test name="Additional Examples 1" level="4">
<variables>
<variable name="id">
<string>person</string>
</variable>
<variable name="token">
<string>12345</string>
</variable>
<variable name="fields">
<array>
<string>id</string>
<string>name</string>
<string>picture</string>
</array>
</variable>
<variable name="format">
<string>json</string>
</variable>
<variable name="q">
<string>URI Templates</string>
</variable>
<variable name="page">
<string>5</string>
</variable>
<variable name="lang">
<string>en</string>
</variable>
<variable name="geocode">
<array>
<string>37.76</string>
<string>-122.427</string>
</array>
</variable>
<variable name="first_name">
<string>John</string>
</variable>
<variable name="last.name">
<string>Doe</string>
</variable>
<variable name="Some%20Thing">
<string>foo</string>
</variable>
<variable name="number">
<integer>6</integer>
</variable>
<variable name="long">
<double>37.76</double>
</variable>
<variable name="lat">
<double>-122.427</double>
</variable>
<variable name="group_id">
<string>12345</string>
</variable>
<variable name="query">
<string>PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt; SELECT ?book ?who WHERE { ?book dc:creator ?who }</string>
</variable>
<variable name="word">
<string>drücken</string>
</variable>
<variable name="Stra%C3%9Fe">
<string>Grüner Weg</string>
</variable>
<variable name="random">
<string>šö䟜ñꀣ¥‡ÑÒÓÔÕÖ×ØÙÚàáâãäåæçÿ</string>
</variable>
<variable name="assoc_special_chars">
<object>
<field name="šö䟜ñꀣ¥‡ÑÒÓÔÕ">
<string>Ö×ØÙÚàáâãäåæçÿ</string>
</field>
</object>
</variable>
</variables>
<testcases>
<testcase template="{/id*}" result="/person"/>
<testcase template="{/id*}{?fields,first_name,last.name,token}"
result="/person?fields=id,name,picture&amp;first_name=John&amp;last.name=Doe&amp;token=12345/person?fields=id,picture,name&amp;first_name=John&amp;last.name=Doe&amp;token=12345/person?fields=picture,name,id&amp;first_name=John&amp;last.name=Doe&amp;token=12345/person?fields=picture,id,name&amp;first_name=John&amp;last.name=Doe&amp;token=12345/person?fields=name,picture,id&amp;first_name=John&amp;last.name=Doe&amp;token=12345/person?fields=name,id,picture&amp;first_name=John&amp;last.name=Doe&amp;token=12345"/>
<testcase template="/search.{format}{?q,geocode,lang,locale,page,result_type}"
result="/search.json?q=URI%20Templates&amp;geocode=37.76,-122.427&amp;lang=en&amp;page=5/search.json?q=URI%20Templates&amp;geocode=-122.427,37.76&amp;lang=en&amp;page=5"/>
<testcase template="/test{/Some%20Thing}" result="/test/foo"/>
<testcase template="/set{?number}" result="/set?number=6"/>
<testcase template="/loc{?long,lat}" result="/loc?long=37.76&amp;lat=-122.427"/>
<testcase template="/base{/group_id,first_name}/pages{/page,lang}{?format,q}"
result="/base/12345/John/pages/5/en?format=json&amp;q=URI%20Templates"/>
<testcase template="/sparql{?query}"
result="/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"/>
<testcase template="/service{?word}" result="/service?word=dr%C3%BCcken"/>
<testcase template="/lookup{?Stra%C3%9Fe}"
result="/lookup?Stra%C3%9Fe=Gr%C3%BCner%20Weg"/>
<testcase template="{random}"
result="%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"/>
<testcase template="{?assoc_special_chars*}"
result="?%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"/>
</testcases>
</test>
<test name="Additional Examples 2" level="4">
<variables>
<variable name="id">
<array>
<string>person</string>
<string>albums</string>
</array>
</variable>
<variable name="token">
<string>12345</string>
</variable>
<variable name="fields">
<array>
<string>id</string>
<string>name</string>
<string>picture</string>
</array>
</variable>
<variable name="format">
<string>atom</string>
</variable>
<variable name="q">
<string>URI Templates</string>
</variable>
<variable name="page">
<string>10</string>
</variable>
<variable name="start">
<string>5</string>
</variable>
<variable name="lang">
<string>en</string>
</variable>
<variable name="geocode">
<array>
<string>37.76</string>
<string>-122.427</string>
</array>
</variable>
</variables>
<testcases>
<testcase template="{/id*}" result="/person/albums/albums/person"/>
<testcase template="{/id*}{?fields,token}"
result="/person/albums?fields=id,name,picture&amp;token=12345/person/albums?fields=id,picture,name&amp;token=12345/person/albums?fields=picture,name,id&amp;token=12345/person/albums?fields=picture,id,name&amp;token=12345/person/albums?fields=name,picture,id&amp;token=12345/person/albums?fields=name,id,picture&amp;token=12345/albums/person?fields=id,name,picture&amp;token=12345/albums/person?fields=id,picture,name&amp;token=12345/albums/person?fields=picture,name,id&amp;token=12345/albums/person?fields=picture,id,name&amp;token=12345/albums/person?fields=name,picture,id&amp;token=12345/albums/person?fields=name,id,picture&amp;token=12345"/>
</testcases>
</test>
<test name="Additional Examples 3: Empty Variables">
<variables>
<variable name="empty_list">
<array/>
</variable>
<variable name="empty_assoc">
<object/>
</variable>
</variables>
<testcases>
<testcase template="{/empty_list}" result=""/>
<testcase template="{/empty_list*}" result=""/>
<testcase template="{?empty_list}" result="?empty_list="/>
<testcase template="{?empty_list*}" result=""/>
<testcase template="{?empty_assoc}" result="?empty_assoc="/>
<testcase template="{?empty_assoc*}" result=""/>
</testcases>
</test>
<test name="Additional Examples 4: Numeric Keys">
<variables>
<variable name="42">
<string>The Answer to the Ultimate Question of Life, the Universe, and Everything</string>
</variable>
<variable name="1337">
<array>
<string>leet</string>
<string>as</string>
<string>it</string>
<string>can</string>
<string>be</string>
</array>
</variable>
<variable name="german">
<object>
<field name="11">
<string>elf</string>
</field>
<field name="12">
<string>zwölf</string>
</field>
</object>
</variable>
</variables>
<testcases>
<testcase template="{42}"
result="The%20Answer%20to%20the%20Ultimate%20Question%20of%20Life%2C%20the%20Universe%2C%20and%20Everything"/>
<testcase template="{?42}"
result="?42=The%20Answer%20to%20the%20Ultimate%20Question%20of%20Life%2C%20the%20Universe%2C%20and%20Everything"/>
<testcase template="{1337}" result="leet,as,it,can,be"/>
<testcase template="{?1337*}"
result="?1337=leet&amp;1337=as&amp;1337=it&amp;1337=can&amp;1337=be"/>
<testcase template="{?german*}"
result="?11=elf&amp;12=zw%C3%B6lf?12=zw%C3%B6lf&amp;11=elf"/>
</testcases>
</test>
</tests>

0 comments on commit e2127e0

Please sign in to comment.