+ ASK support
authorAlexandre Bertails <bertails@gmail.com>
Sun, 28 Aug 2011 14:42:57 -0400
changeset 14 25334ed662e2
parent 13 dc0c44140125
child 15 80c5cebba882
+ ASK support
project/build.scala
src/test/scala/Test.scala
--- a/project/build.scala	Sun Aug 28 14:10:01 2011 -0400
+++ b/project/build.scala	Sun Aug 28 14:42:57 2011 -0400
@@ -58,11 +58,12 @@
       libraryDependencies += unfiltered_jetty,
       libraryDependencies += slf4jSimple,
       libraryDependencies += jena,
-      libraryDependencies += arq
+      libraryDependencies += arq,
+      libraryDependencies += antiXML
     )
 
   lazy val yourProject = Project(
-    id = "your-project",
+    id = "read-write-web",
     base = file("."),
     settings = buildSettings ++ yourProjectSettings ++ sbtassembly.Plugin.assemblySettings
   )
--- a/src/test/scala/Test.scala	Sun Aug 28 14:10:01 2011 -0400
+++ b/src/test/scala/Test.scala	Sun Aug 28 14:42:57 2011 -0400
@@ -7,6 +7,8 @@
 import dispatch._
 import java.io._
 
+import com.codecommit.antixml._
+
 import com.hp.hpl.jena.rdf.model._
 import com.hp.hpl.jena.query._
 import com.hp.hpl.jena.update._
@@ -117,17 +119,30 @@
     }
   }
   
-  val queryFoafName =
+  val selectFoafName =
 """
 PREFIX foaf: <http://xmlns.com/foaf/0.1/>
 SELECT ?name WHERE { [] foaf:name ?name }
 """
   
-  "POSTing a SPARQL query { [] foaf:name ?name } to Joe's URI" should {
+  """POSTing "SELECT ?name WHERE { [] foaf:name ?name }" to Joe's URI""" should {
     "return Joe's name" in {
-      val resultSet = Http(joe.post(queryFoafName) >- { body => ResultSetFactory.fromXML(body) } )
+      val resultSet = Http(joe.post(selectFoafName) >- { body => ResultSetFactory.fromXML(body) } )
       resultSet.next().getLiteral("name").getString must_== "Joe Lambda"
     }
   }
+  
+  val askFoafName =
+"""
+PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+ASK { [] foaf:name ?name }
+"""
+  
+  """POSTing "ASK ?name WHERE { [] foaf:name ?name }" to Joe's URI""" should {
+    "return true" in {
+      val result:Boolean = Http(joe.post(askFoafName) >~ { s => (XML.fromSource(s) \ "boolean" \ text).head.toBoolean } )
+      result must_== true
+    }
+  }
     
 }