-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
template function "file_xml2json" (#74)
* new implementations of marshalling xml into json - use simpler json output without "#seq": - new template function "file_xml2json" - new response format type "xml2" see #64950 * added new testcase for new template exiftool_result.xml: compare result of exiftool request with local xml file; see #64950 * updated README for new xml to json functions * Update README.md * changed response debug output if xml2 format is used: output formatted json instead of xml Co-authored-by: Philipp Hempel <philipp.hempel@programmfabrik.de>
- Loading branch information
Showing
15 changed files
with
358 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Get existing XML file", | ||
"request": { | ||
"server_url": "{{ datastore "req_base_url" }}", | ||
"endpoint": "bounce-json", | ||
"method": "POST", | ||
"body": {{ file_xml2json "sample.xml" }} | ||
}, | ||
"response": { | ||
"statuscode": 200, | ||
"body": { | ||
"header": {}, | ||
"body": {{ file "result_xml2.json" }} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "Get existing XML file", | ||
"request": { | ||
"server_url": "{{ datastore "req_base_url" }}", | ||
"endpoint": "bounce-json", | ||
"method": "POST", | ||
"body": {{ file "result_xml2.json" }} | ||
}, | ||
"response": { | ||
"statuscode": 200, | ||
"body": { | ||
"body": {{ file_xml2json "sample.xml" }} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "bounce xml file, use response format \"xml\"", | ||
"request": { | ||
"server_url": "{{ datastore "req_base_url" }}", | ||
"endpoint": "bounce", | ||
"method": "POST", | ||
"body": { | ||
"file": "@sample.xml" | ||
}, | ||
"body_type": "multipart" | ||
}, | ||
"response": { | ||
"format": { | ||
// uses mxj.NewMapXmlSeq() from https://github.com/clbanning/mxj | ||
"type": "xml" | ||
}, | ||
"body": {{ file "result_xml.json" }} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "bounce xml file, use response format \"xml2\"", | ||
"request": { | ||
"server_url": "{{ datastore "req_base_url" }}", | ||
"endpoint": "bounce", | ||
"method": "POST", | ||
"body": { | ||
"file": "@sample.xml" | ||
}, | ||
"body_type": "multipart" | ||
}, | ||
"response": { | ||
"format": { | ||
// new simpler format without #seq | ||
// uses mxj.NewMapXml from https://github.com/clbanning/mxj | ||
"type": "xml2" | ||
}, | ||
"body": {{ file "result_xml2.json" }} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "preprocess asset berlin.jpg with exiftool in xml format, compare \"exiftool_result.xml\"", | ||
"request": { | ||
// load static file | ||
"server_url": "{{ datastore "req_base_url" }}", | ||
"endpoint": "berlin.jpg", | ||
"method": "GET" | ||
}, | ||
"response": { | ||
"format": { | ||
"pre_process": { | ||
"cmd": { | ||
"name": "exiftool", | ||
"args": [ | ||
"-X", | ||
"-l", | ||
"-" | ||
] | ||
} | ||
}, | ||
"type": "xml2" | ||
}, | ||
"body": {{ file_xml2json "exiftool_result.xml" }} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<rdf:RDF> | ||
<rdf:Description rdf:about="-"> | ||
<File:FileType rdf:parseType="Resource"> | ||
<et:desc>File Type</et:desc> | ||
<et:prt>JPEG</et:prt> | ||
</File:FileType> | ||
<File:FileTypeExtension rdf:parseType="Resource"> | ||
<et:desc>File Type Extension</et:desc> | ||
<et:prt>jpg</et:prt> | ||
<et:val>JPG</et:val> | ||
</File:FileTypeExtension> | ||
<File:MIMEType rdf:parseType="Resource"> | ||
<et:desc>MIME Type</et:desc> | ||
<et:prt>image/jpeg</et:prt> | ||
</File:MIMEType> | ||
<File:ImageWidth rdf:parseType="Resource"> | ||
<et:desc>Image Width</et:desc> | ||
<et:prt>1920</et:prt> | ||
</File:ImageWidth> | ||
<File:ImageHeight rdf:parseType="Resource"> | ||
<et:desc>Image Height</et:desc> | ||
<et:prt>1280</et:prt> | ||
</File:ImageHeight> | ||
<JFIF:XResolution rdf:parseType="Resource"> | ||
<et:desc>X Resolution</et:desc> | ||
<et:prt>1</et:prt> | ||
</JFIF:XResolution> | ||
<JFIF:YResolution rdf:parseType="Resource"> | ||
<et:desc>Y Resolution</et:desc> | ||
<et:prt>1</et:prt> | ||
</JFIF:YResolution> | ||
<Composite:ImageSize rdf:parseType="Resource"> | ||
<et:desc>Image Size</et:desc> | ||
<et:prt>1920x1280</et:prt> | ||
<et:val>1920 1280</et:val> | ||
</Composite:ImageSize> | ||
</rdf:Description> | ||
</rdf:RDF> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{ $local_port:=":9999"}} | ||
{ | ||
"http_server": { | ||
"addr": "{{ $local_port }}", | ||
"dir": ".", | ||
"testmode": false | ||
}, | ||
"store": { | ||
"req_base_url": "http://localhost{{ $local_port }}" | ||
}, | ||
"name": "XML tests", | ||
"tests": [ | ||
"@check_local_file_against_response.json" | ||
, "@check_response_against_local_file.json" | ||
, "@check_response_format_xml.json" | ||
, "@check_response_format_xml2.json" | ||
, "@compare_exiftool_with_xml.json" | ||
] | ||
} |
Oops, something went wrong.