add DELETE tests webid
authorHenry Story <henry.story@bblfish.net>
Tue, 10 Apr 2012 19:48:54 +0200
branchwebid
changeset 192 bf32780aa336
parent 191 5cf67ba5c0d4
child 193 5e48ef562a36
add DELETE tests
src/main/scala/ReadWriteWeb.scala
src/test/scala/CreateContentSpecs.scala
src/test/scala/OtherSpecs.scala
src/test/scala/util/utiltest.scala
--- a/src/main/scala/ReadWriteWeb.scala	Tue Apr 10 15:50:51 2012 +0200
+++ b/src/main/scala/ReadWriteWeb.scala	Tue Apr 10 19:48:54 2012 +0200
@@ -118,7 +118,7 @@
                   case PostRDF(model) => {
                     logger.info("RDF content:\n" + model.toString())
                     for {
-                      model <- rNew.save(model) failMap {
+                      _ <- rNew.save(model) failMap {
                         t => InternalServerError ~> ResponseString(t.getStackTraceString)
                       }
                     } yield Created ~> ResponseHeader("Location",Seq(rNew.name.toString))
--- a/src/test/scala/CreateContentSpecs.scala	Tue Apr 10 15:50:51 2012 +0200
+++ b/src/test/scala/CreateContentSpecs.scala	Tue Apr 10 19:48:54 2012 +0200
@@ -30,7 +30,7 @@
       model must beIsomorphicWith (referenceModel)
     }
   }
-  
+
 }
 
 
@@ -71,6 +71,7 @@
     }
   }
 
+
   "POSTing an RDF document to a Joe's directory/collection" should {
     "succeed and create a resource on disk" in {
       val handler = dirUri.post(diffRDF, RDFXML) >+ { req =>
@@ -79,18 +80,14 @@
           (status_code,loc)
       }
       val (code, head) = Http(handler)
-      System.out.println("code="+code)
-      System.out.println("head="+head)
       code must_== 201
       val headURI = new URL(head.trim)
-      System.out.println("root="+root)
       val file = new File(root, headURI.getPath.substring(baseURL.size))
       file must exist
     }
 
-    "create a resource on disk" in {
-//      joeProfileOnDisk must be file
-    }
+
+
   }
   
 }
--- a/src/test/scala/OtherSpecs.scala	Tue Apr 10 15:50:51 2012 +0200
+++ b/src/test/scala/OtherSpecs.scala	Tue Apr 10 19:48:54 2012 +0200
@@ -19,11 +19,27 @@
 
 object DeleteResourceSpec extends SomeDataInStore {
 
-  """a DELETE request""" should {
-    "not delete the resource" in {
-      val statusCode = Http.when(_ == 204)(uri.copy(method="DELETE") get_statusCode)
-      statusCode must_== 204
+
+  "DELETEing Joe's URI" should {
+    "before doing it his resource must" in {
+      "be created and return a 201" in {
+        val httpCode = Http(uri.put(RDFXML, rdfxml) get_statusCode)
+        httpCode must_== 201
+      }
+      "create a document on disk" in {
+        resourceOnDisk must exist
+      }
+    }
+
+    "succeed" in {
+      val httpCode:Int = Http(uri.delete get_statusCode)
+      httpCode must_== 204
+    }
+
+    "delete the document on disk" in {
+      resourceOnDisk mustNot exist
     }
   }
 
+
 }
--- a/src/test/scala/util/utiltest.scala	Tue Apr 10 15:50:51 2012 +0200
+++ b/src/test/scala/util/utiltest.scala	Tue Apr 10 19:48:54 2012 +0200
@@ -61,6 +61,8 @@
     def get_header(header: String): Handler[String] = req >:> { _(header).head }
 
     def get: Request = req.copy(method="GET")
+
+    def delete: Request = req.copy(method="DELETE")
     
     def >++ [A, B, C] (block:  Request => (Handler[A], Handler[B], Handler[C])) = {
       Handler(req, { (code, res, opt_ent) =>