| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | Usage=$(cat <<EOF |
|---|
| 4 | Please use the following syntaxe: |
|---|
| 5 | |
|---|
| 6 | ./run.sh <WPSInstance> <ServiceName> |
|---|
| 7 | |
|---|
| 8 | where <WPSInstance> should be the url to a WPS Server and <ServiceName> should |
|---|
| 9 | be the service name you want to run tests with. |
|---|
| 10 | |
|---|
| 11 | For instance to test the Buffer service on a localhost WPS server, use the |
|---|
| 12 | following command: |
|---|
| 13 | |
|---|
| 14 | ./run.sh http://localhost/cgi-bin/zoo_loader.cgi Buffer |
|---|
| 15 | |
|---|
| 16 | EOF |
|---|
| 17 | ) |
|---|
| 18 | |
|---|
| 19 | if [ -z "$1" ] || [ -z "$2" ]; then |
|---|
| 20 | echo "$Usage" |
|---|
| 21 | exit |
|---|
| 22 | fi |
|---|
| 23 | |
|---|
| 24 | WPSInstance=$1 |
|---|
| 25 | ServiceName=$2 |
|---|
| 26 | |
|---|
| 27 | function kvpRequest { |
|---|
| 28 | echo "Simple KVP request " |
|---|
| 29 | echo "$1" |
|---|
| 30 | curl -o "$2" "$1" |
|---|
| 31 | echo "Checking for ${3} response XML validity..." |
|---|
| 32 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd "$2" |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | function postRequest { |
|---|
| 36 | echo "Simple POST request " |
|---|
| 37 | echo "Checking for ${3} request XML validity..." |
|---|
| 38 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_request.xsd "$4" |
|---|
| 39 | curl -H "Content-type: text/xml" -d@"$4" -o "$2" "$1" |
|---|
| 40 | echo "Checking for ${3} response XML validity..." |
|---|
| 41 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd "$2" |
|---|
| 42 | if [ -z "$5" ]; then |
|---|
| 43 | echo "" |
|---|
| 44 | else |
|---|
| 45 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd "$(xsltproc ./extractStatusLocation.xsl $2)" |
|---|
| 46 | fi |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | # |
|---|
| 51 | # Tests for GetCapabilities using KVP and POST requests |
|---|
| 52 | # |
|---|
| 53 | kvpRequest "${WPSInstance}?request=GetCapabilities&service=WPS" "tmp/outputGC1.xml" "GetCapabilities" |
|---|
| 54 | |
|---|
| 55 | kvpRequest "${WPSInstance}?REQUEST=GetCapabilities&SERVICE=WPS" "tmp/outputGC2.xml" "GetCapabilities" |
|---|
| 56 | |
|---|
| 57 | echo "Check if differences between upper case and lower case parameter names" |
|---|
| 58 | diff -ru tmp/outputGC1.xml tmp/outputGC2.xml |
|---|
| 59 | |
|---|
| 60 | echo "" |
|---|
| 61 | |
|---|
| 62 | curl -o tmp/10_wpsGetCapabilities_request.xml http://schemas.opengis.net/wps/1.0.0/examples/10_wpsGetCapabilities_request.xml |
|---|
| 63 | postRequest "${WPSInstance}" "tmp/outputGCp.xml" "GetCapabilities" "tmp/10_wpsGetCapabilities_request.xml" |
|---|
| 64 | echo "" |
|---|
| 65 | |
|---|
| 66 | # |
|---|
| 67 | # Tests for DescribeProcess using KVP and POST requests |
|---|
| 68 | # |
|---|
| 69 | kvpRequest "${WPSInstance}?request=DescribeProcess&service=WPS&version=1.0.0&Identifier=ALL" "tmp/outputDPall.xml" "DescribeProcess" |
|---|
| 70 | |
|---|
| 71 | kvpRequest "${WPSInstance}?request=DescribeProcess&service=WPS&version=1.0.0&Identifier=${ServiceName}" "tmp/outputDPb1.xml" "DescribeProcess" |
|---|
| 72 | |
|---|
| 73 | echo "" |
|---|
| 74 | |
|---|
| 75 | cat requests/dp.xml | sed "s:ServiceName:${ServiceName}:g" > tmp/dp1.xml |
|---|
| 76 | postRequest "${WPSInstance}" "tmp/outputDPp.xml" "DescribeProcess" "tmp/dp1.xml" |
|---|
| 77 | echo "" |
|---|
| 78 | |
|---|
| 79 | # |
|---|
| 80 | # Tests for Execute using KVP and POST requests |
|---|
| 81 | # |
|---|
| 82 | for i in ijson_o igml_o ir_o ir_o_async ir_or ir_or_async irb_o irb_o_async irb_or irb_or_async; |
|---|
| 83 | do |
|---|
| 84 | cat requests/${i}.xml | sed "s:ServiceName:${ServiceName}:g" > tmp/${i}1.xml |
|---|
| 85 | if [ -z "$(echo $i | grep async)" ]; then |
|---|
| 86 | postRequest "${WPSInstance}" "tmp/outputE${i}.xml" "Execute" "tmp/${i}1.xml" |
|---|
| 87 | else |
|---|
| 88 | postRequest "${WPSInstance}" "tmp/outputE${i}.xml" "Execute" "tmp/${i}1.xml" "async" |
|---|
| 89 | fi |
|---|
| 90 | echo "" |
|---|
| 91 | done |
|---|
| 92 | |
|---|
| 93 | echo "" |
|---|