--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/scala/RecordAPISpec.scala Wed Aug 24 14:14:48 2011 -0400
@@ -0,0 +1,52 @@
+package org.w3.virtualtrainer
+
+import org.specs._
+import java.net.URL
+
+object RecordAPISpec extends Specification("Specification for the Record API") with unfiltered.spec.jetty.Served {
+ import unfiltered.response._
+ import unfiltered.request._
+
+ import dispatch._
+
+ def setup = { _.filter(VirtualTrainerApp.recordAPI) }
+
+ val record = """
+{
+ "activity":"http://dbpedia.org/resource/Running",
+ "events":
+ [
+ {
+ "t": 1314049555597,
+ "c": [-71.09068298339844,42.361671924591064,66]
+ },
+ {
+ "t": 1314049559622,
+ "s": "pause"
+ },
+ {
+ "t": 1314549555597,
+ "c": [-71.09068298339844,42.361671924591064,66]
+ },
+ {
+ "t": 1315049559622,
+ "s": "pause"
+ }
+ ]
+}
+"""
+
+
+ "POST record" should {
+ val POSTrun = host / "user" / "jdoe" / "run"
+ "return a location header that has same domain and port than the POST url" in {
+ val locationHeader:String = Http((POSTrun <<< record).copy(method="POST") >:> { headers =>
+ headers get "Location" getOrElse sys.error("no Location header") head
+ })
+ val locationURL = new URL(locationHeader)
+ locationURL.getHost must_== POSTrun.host.getHostName
+ locationURL.getPort must_== POSTrun.host.getPort
+ }
+ }
+
+}
\ No newline at end of file