Skip to content

Instantly share code, notes, and snippets.

@kefo
Last active March 27, 2018 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kefo/94430d0e10e283d0ca91d32155f66d5a to your computer and use it in GitHub Desktop.
Save kefo/94430d0e10e283d0ca91d32155f66d5a to your computer and use it in GitHub Desktop.
Bash script to reveal float-related bug.
#!/bin/bash
pfx="http://localhost:8080/rest/kefo_test"
uuid=$(uuidgen)
container="${pfx}/${uuid}"
echo; echo; echo "Creating root {$pfx}"
curl -iXPUT "${pfx}"
echo; echo; echo "Creating Container ${container}."
curl -iXPUT "${container}"
echo; echo; echo "Creating resource 'a'."
curl -iXPUT -d "@float_bug_base_resource.ttl" -H "Content-type: text/turtle" "${container}/a"
echo; echo; echo "GET the container, observe lat/long values."
curl -i "${container}/a"
echo; echo; echo "Preparing to update resource 'a' with this resource. Note that the lat/long values are different than the base resource."
cat float_bug_updated_01.ttl
echo; echo; echo "Updating resource 'a' via PUT (lenient handling)."
curl -iXPUT -d "@float_bug_updated_01.ttl" -H "Content-type: text/turtle" -H "Prefer: handling=lenient; received=\"minimal\"" "${container}/a"
echo; echo; echo "GET the container, observe lat/long values. They should be unchanged."
curl -i "${container}/a"
echo; echo; echo "Creating resource 'b'."
curl -iXPUT -d @float_bug_base_resource.ttl -H "Content-type: text/turtle" "${container}/b"
echo; echo; echo "GET the container, observe lat/long values."
curl -i "${container}/b"
echo; echo; echo "Preparing to update resource 'a' with this resource. Note that the lat/long values are different than the base resource."
cat float_bug_updated_02.ttl
echo; echo; echo "Updating resource 'b' via PUT (lenient handling)."
curl -iXPUT -d @float_bug_updated_02.ttl -H "Content-type: text/turtle" -H "Prefer: handling=lenient; received=\"minimal\"" "${container}/b"
echo; echo; echo "GET the container, observe lat/long values. They should be changed."
curl -i "${container}/b"
echo; echo
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<> geo:lat "9.123456"^^xsd:float ;
geo:long "-9.123456"^^xsd:float ;
rdfs:label "New"^^xsd:string .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<> geo:lat "9.123456123456"^^xsd:float ;
geo:long "-9.123456123456"^^xsd:float ;
rdfs:label "Updated? No."^^xsd:string .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<> geo:lat "9.12345678910"^^xsd:float ;
geo:long "-9.12345678910"^^xsd:float ;
rdfs:label "Updated? Yes."^^xsd:string .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment