--- 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
+ }
+ }
}