--- a/src/test/scala/SparqlToSqlTest.scala Sun Jan 31 11:50:54 2010 -0500
+++ b/src/test/scala/SparqlToSqlTest.scala Sun Jan 31 12:00:40 2010 -0500
@@ -1,4 +1,4 @@
-/* SparqlToScalaTest: transform SPARQL to SQL and compare against a reference query.
+/* SparqlToSqlTest: transform SPARQL to SQL and compare against a reference query.
* $Id$
*/
@@ -8,12 +8,12 @@
import java.net.URI
import w3c.sw.sql.{Sql,DatabaseDesc,Relation,RelationDesc,Attribute,Value,Datatype,ForeignKey,Name}
import w3c.sw.sparql.Sparql
-import w3c.sw.sparql2sql.{SparqlToScala,StemURI}
+import w3c.sw.sparql2sql.{SparqlToSql,StemURI}
-/* The SparqlToScalaTest class transforms SPARQL queries to a relational data
+/* The SparqlToSqlTest class transforms SPARQL queries to a relational data
* structure and compares them to a structure parsed from SQL.
*/
-class SparqlToScalaTest extends FunSuite {
+class SparqlToSqlTest extends FunSuite {
/* These tests use a schema and queries designed to work with this
* example database:
@@ -126,22 +126,22 @@
test("decompose a predicate uri in stem, rel and attr") {
val uri = sparql.Uri("http://hr.example/our/favorite/DB/Employee#lastName")
- val puri:SparqlToScala.PUri = SparqlToScala.parsePredicateURI(uri)
- assert(puri === SparqlToScala.PUri(SparqlToScala.Stem("http://hr.example/our/favorite/DB"),
- SparqlToScala.Rel("Employee"),
- SparqlToScala.Attr("lastName")))
+ val puri:SparqlToSql.PUri = SparqlToSql.parsePredicateURI(uri)
+ assert(puri === SparqlToSql.PUri(SparqlToSql.Stem("http://hr.example/our/favorite/DB"),
+ SparqlToSql.Rel("Employee"),
+ SparqlToSql.Attr("lastName")))
}
test("decompose a object uri in stem, rel and attr") {
val uri = sparql.Uri("http://hr.example/our/favorite/DB/Employee/id.18#record")
- val objuri:SparqlToScala.NodeUri = SparqlToScala.parseObjectURI(uri)
- assert(objuri === SparqlToScala.NodeUri(SparqlToScala.Stem("http://hr.example/our/favorite/DB"),
- SparqlToScala.Rel("Employee"),
- SparqlToScala.Attr("id"),
- SparqlToScala.CellValue("18")))
+ val objuri:SparqlToSql.NodeUri = SparqlToSql.parseObjectURI(uri)
+ assert(objuri === SparqlToSql.NodeUri(SparqlToSql.Stem("http://hr.example/our/favorite/DB"),
+ SparqlToSql.Rel("Employee"),
+ SparqlToSql.Attr("id"),
+ SparqlToSql.CellValue("18")))
}
- /* Disable turtle string-izing (SparqlToScala parm 5) and return native format: */
+ /* Disable turtle string-izing (SparqlToSql parm 5) and return native format: */
test("?s <p> <x>") {
val sparqlParser = Sparql()
val sparqlSelect = sparqlParser.parseAll(sparqlParser.select, """
@@ -157,7 +157,7 @@
INNER JOIN Employee AS R_empid18
WHERE R_empid18.empid=R_emp.manager AND R_empid18.empid=18 AND R_emp.empid IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+-----+
@@ -184,7 +184,7 @@
INNER JOIN Employee AS R_empid18
WHERE R_empid18.empid=R_emp.manager AND R_empid18.empid=18 AND R_emp.empid IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, true)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, true)
assert(generated === parsed)
val output = """
+------------------------------------------------+
@@ -210,7 +210,7 @@
FROM Employee AS R_emp
WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, true)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, true)
assert(generated === parsed)
val output = """
+----------------------------------------------------+
@@ -240,7 +240,7 @@
INNER JOIN Employee AS R_manager
WHERE R_manager.empid=R_empid253.manager AND R_empid253.empid=253
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+---------+
@@ -269,7 +269,7 @@
INNER JOIN Employee AS R_18
WHERE R_18.empid=R_emp.manager AND R_18.empid=18 AND R_emp.empid IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+-----+
@@ -298,7 +298,7 @@
INNER JOIN TaskAssignments AS R_task2 ON R_who.empid=R_task2.employee
WHERE R_task1.id<R_task2.id
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+-------+-------+
@@ -329,7 +329,7 @@
INNER JOIN Employee AS R_manager ON R_manager.empid=R_emp.manager
WHERE R_emp .lastName IS NOT NULL AND R_manager.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+---------+------------+
@@ -357,7 +357,7 @@
FROM Employee AS R_emp
WHERE R_emp.manager=18 AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
+---------+
@@ -384,7 +384,7 @@
INNER JOIN Employee AS R_empid18
WHERE R_empid18.empid=R_emp.manager AND R_empid18.empid=18 AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+---------+
@@ -414,7 +414,7 @@
INNER JOIN Employee AS R_manager
WHERE R_manager.empid=R_emp.manager AND R_manager.lastName="Johnson" AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+---------+
@@ -460,7 +460,7 @@
WHERE R_taskLead.birthday<R_emp.birthday AND R_grandManager.birthday<R_taskLead.birthday
AND R_emp.lastName IS NOT NULL AND R_grandManager.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
val output = """
+---------+----------------+
@@ -521,7 +521,7 @@
AND (G_union1._DISJOINT_!=0 OR G_union1.who=R_who.empid)
AND (G_union1._DISJOINT_!=1 OR G_union1.who=R_who.empid)
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
+---------+
@@ -585,7 +585,7 @@
AND (G_union0._DISJOINT_!=1 OR R_who.empid=G_union0.who)
AND R_who.lastName="Smith"
""").get // !!! AND (G_union0.bday IS NOT NULL) AND (G_union0.who IS NOT NULL)
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -640,7 +640,7 @@
AND (G_union1._DISJOINT_!=1 OR G_union1.who=R_who.empid)
AND R_who.birthday IS NOT NULL AND R_who.lastName="Smith"
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -695,7 +695,7 @@
AND (G_union1._DISJOINT_!=1 OR R_who.birthday=G_union1.bday)
AND R_who.lastName="Smith"
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -726,7 +726,7 @@
) AS G_opt1 ON G_opt1.emp=R_emp.empid
WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -757,7 +757,7 @@
WHERE (G_opt1._DISJOINT_ IS NULL OR R_emp.empid=G_opt1.emp)
AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -795,7 +795,7 @@
) AS G_opt1 ON G_opt1.emp=R_emp.empid
WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -840,7 +840,7 @@
AND R_emp2.empid IS NOT NULL AND R_emp2.lastName<R_emp3.lastName
AND R_emp3.lastName<R_emp4.lastName AND R_emp1.empid IS NOT NULL
""").get
- val generated = SparqlToScala(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = SparqlToSql(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -949,7 +949,7 @@
AND R_patient.MiddleName IS NOT NULL
AND R_sexEntry.EntryName IS NOT NULL
""").get // AND G_opt6.patient IS NULL
- val generated = SparqlToScala(hosp1, sparqlSelect, StemURI("http://hospital.example/DB/"), false, false)
+ val generated = SparqlToSql(hosp1, sparqlSelect, StemURI("http://hospital.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""
@@ -1026,7 +1026,7 @@
AND R_patient.MiddleName IS NOT NULL
AND R_sexEntry.EntryName IS NOT NULL
""").get
- val generated = SparqlToScala(hosp1, sparqlSelect, StemURI("http://hospital.example/DB/"), false, false)
+ val generated = SparqlToSql(hosp1, sparqlSelect, StemURI("http://hospital.example/DB/"), false, false)
assert(generated === parsed)
val output = """
"""