Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created July 19, 2013 02:55
Show Gist options
  • Save pnorman/6034769 to your computer and use it in GitHub Desktop.
Save pnorman/6034769 to your computer and use it in GitHub Desktop.
package osmapi
/*
This file is part of openstreetmap-api-testsuite
Copyright (c) 2013 Paul Norman, released under the MIT license.
Defines various test cases for nodes with diff processing
*/
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import bootstrap._
object NodeDiffScenario {
def stripZero = (s:Option[String]) => s.map(_.replaceAll("0+$",""))
val nodeDiffScn = scenario("Node diff tests")
.group("Node diff tests") {
group("Status tests") {
exec(
http("deleted")
.get("/node/2001")
.check(
status.is(410),
header("Cache-Control").is("no-cache"),
header("Content-Length").is("0"),
sha1.is("da39a3ee5e6b4b0d3255bfef95601890afd80709")
))
.exec(
http("recreated")
.get("/node/2002")
.check(
status.is(200),
header("Content-Type").is("text/xml; charset=utf-8"),
xpath("""/osm/*""").count.is(1),
xpath("""/osm/node[@id="2002"]""").count.is(1),
xpath("""/osm/node[@id="2002"]/@*""").count.is(9),
xpath("""/osm/node[@id="2002"]/@version""").is("3"),
xpath("""/osm/node[@id="2002"]/@changeset""").is("2202"),
xpath("""/osm/node[@id="2002"]/@lat""").transform(s => stripZero(s)).is("1.001"),
xpath("""/osm/node[@id="2002"]/@lon""").transform(s => stripZero(s)).is("1.102"),
xpath("""/osm/node[@id="2002"]/@user""").is("user_2202"),
xpath("""/osm/node[@id="2002"]/@uid""").is("2202"),
xpath("""/osm/node[@id="2002"]/@visible""").is("true")
))
.exec(
http("deleted tagged")
.get("/node/2003")
.check(
status.is(410),
header("Cache-Control").is("no-cache"),
header("Content-Length").is("0"),
sha1.is("da39a3ee5e6b4b0d3255bfef95601890afd80709")
))
.exec(
http("recreated as untagged")
.get("/node/2004")
.check(
status.is(200),
header("Content-Type").is("text/xml; charset=utf-8"),
xpath("""/osm/*""").count.is(1),
xpath("""/osm/node[@id="2004"]""").count.is(1),
xpath("""/osm/node[@id="2004"]/@*""").count.is(9),
xpath("""/osm/node[@id="2004"]/@version""").is("3"),
xpath("""/osm/node[@id="2004"]/@changeset""").is("2204"),
xpath("""/osm/node[@id="2004"]/@lat""").transform(s => stripZero(s)).is("1.001"),
xpath("""/osm/node[@id="2004"]/@lon""").transform(s => stripZero(s)).is("1.104"),
xpath("""/osm/node[@id="2004"]/@user""").is("user_2204"),
xpath("""/osm/node[@id="2004"]/@uid""").is("2204"),
xpath("""/osm/node[@id="2004"]/@visible""").is("true"),
xpath("""/osm/node[@id="2004"]/*""").count.is(0) // untagged
))
.exec(
http("diff created")
.get("/node/2005")
.check(
status.is(200),
header("Content-Type").is("text/xml; charset=utf-8"),
xpath("""/osm/*""").count.is(1),
xpath("""/osm/node[@id="2005"]""").count.is(1),
xpath("""/osm/node[@id="2005"]/@*""").count.is(9),
xpath("""/osm/node[@id="2005"]/@version""").is("1"),
xpath("""/osm/node[@id="2005"]/@changeset""").is("2005"),
xpath("""/osm/node[@id="2005"]/@lat""").transform(s => stripZero(s)).is("1.001"),
xpath("""/osm/node[@id="2005"]/@lon""").transform(s => stripZero(s)).is("1.105"),
xpath("""/osm/node[@id="2005"]/@user""").is("user_2005"),
xpath("""/osm/node[@id="2005"]/@uid""").is("2005"),
xpath("""/osm/node[@id="2005"]/@visible""").is("true")
))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment