+ SQLbgp
authoreric@ubu
Thu, 10 Dec 2009 17:30:17 -0500
changeset 12 eace1151058d
parent 11 eba6b088b20d
child 13 1356d86f37f9
+ SQLbgp
src/test/scala/SparqlTest.scala
--- a/src/test/scala/SparqlTest.scala	Thu Dec 10 17:23:37 2009 -0500
+++ b/src/test/scala/SparqlTest.scala	Thu Dec 10 17:30:17 2009 -0500
@@ -48,6 +48,35 @@
     assert(tps === a.parseAll(a.triplepatterns, e).get)
   }
 
+  test("SQLbgp") {
+    val a = Sparql()
+    val e = """
+SELECT ?empName ?manageName {
+?emp      <http://hr.example/DB/Employee#lastName>   ?empName .
+?emp      <http://hr.example/DB/Employee#manager>    ?manager .
+?manager  <http://hr.example/DB/Employee#lastName>   ?managName
+}
+"""
+    val tps =
+      SparqlSelect(
+	SparqlAttributeList(List(Var("empName"), Var("manageName"))),
+	TriplePatterns(
+	  List(
+	    TriplePattern(
+	      SVar(Var("emp")),
+		PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("lastName")),
+	      OVar(Var("empName"))),
+	    TriplePattern(
+	      SVar(Var("emp")),
+	      PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("manager")),
+	      OVar(Var("manager"))),
+	    TriplePattern(
+	      SVar(Var("manager")),
+	      PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("lastName")),
+	      OVar(Var("managName"))))))
+    assert(tps === a.parseAll(a.select, e).get)
+  }
+
   test("decompose a predicate uri in stem, rel and attr") {
     val uri = "http://hr.example/DB/Employee#lastName"
     val puri:PUri = Sparql.parsePredicateURI(uri)