[tracker] libtracker-data: Test subqueries



commit 0415d933bbc29ff4ffbfbc6594fe7f0c24525180
Author: Jürg Billeter <j bitron ch>
Date:   Thu Dec 10 11:17:09 2009 +0100

    libtracker-data: Test subqueries

 configure.ac                                      |    1 +
 tests/libtracker-data/Makefile.am                 |    1 +
 tests/libtracker-data/subqueries/Makefile.am      |    8 +++++
 tests/libtracker-data/subqueries/data-1.ontology  |   31 +++++++++++++++++++++
 tests/libtracker-data/subqueries/data-1.ttl       |   28 +++++++++++++++++++
 tests/libtracker-data/subqueries/subqueries-1.out |    2 +
 tests/libtracker-data/subqueries/subqueries-1.rq  |   10 +++++++
 tests/libtracker-data/tracker-sparql-test.c       |    1 +
 8 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 859ba4a..9e3282b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,7 @@ AC_CONFIG_FILES([
 	tests/libtracker-data/optional/Makefile
 	tests/libtracker-data/regex/Makefile
 	tests/libtracker-data/sort/Makefile
+	tests/libtracker-data/subqueries/Makefile
 	tests/libtracker-data/error/Makefile
 	tests/libtracker-data/turtle/Makefile
 	tests/libtracker-db/Makefile
diff --git a/tests/libtracker-data/Makefile.am b/tests/libtracker-data/Makefile.am
index 8461b1c..18cac27 100644
--- a/tests/libtracker-data/Makefile.am
+++ b/tests/libtracker-data/Makefile.am
@@ -11,6 +11,7 @@ SUBDIRS = 			\
 	optional		\
 	regex			\
 	sort			\
+	subqueries		\
 	error			\
 	turtle
 
diff --git a/tests/libtracker-data/subqueries/Makefile.am b/tests/libtracker-data/subqueries/Makefile.am
new file mode 100644
index 0000000..73eeb29
--- /dev/null
+++ b/tests/libtracker-data/subqueries/Makefile.am
@@ -0,0 +1,8 @@
+include $(top_srcdir)/Makefile.decl
+
+EXTRA_DIST =             \
+	data-1.ontology  \
+	data-1.ttl       \
+	subqueries-1.out \
+	subqueries-1.rq
+
diff --git a/tests/libtracker-data/subqueries/data-1.ontology b/tests/libtracker-data/subqueries/data-1.ontology
new file mode 100644
index 0000000..5f22245
--- /dev/null
+++ b/tests/libtracker-data/subqueries/data-1.ontology
@@ -0,0 +1,31 @@
+ prefix example: <http://example.org/ns#> .
+ prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
+ prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+ prefix tracker: <http://www.tracker-project.org/ontologies/tracker#> .
+ prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+example: a tracker:Namespace ;
+	tracker:prefix "example" .
+
+example:Message a rdfs:Class ;
+	rdfs:subClassOf rdfs:Resource .
+
+example:Group a rdfs:Class ;
+	rdfs:subClassOf rdfs:Resource .
+
+example:date a rdf:Property ;
+	nrl:maxCardinality 1 ;
+	rdfs:domain example:Message ;
+	rdfs:range xsd:dateTime .
+
+example:group a rdf:Property ;
+	nrl:maxCardinality 1 ;
+	rdfs:domain example:Message ;
+	rdfs:range example:Group .
+
+example:lastDate a rdf:Property ;
+	nrl:maxCardinality 1 ;
+	rdfs:domain example:Group ;
+	rdfs:range xsd:dateTime .
+
diff --git a/tests/libtracker-data/subqueries/data-1.ttl b/tests/libtracker-data/subqueries/data-1.ttl
new file mode 100644
index 0000000..f616e55
--- /dev/null
+++ b/tests/libtracker-data/subqueries/data-1.ttl
@@ -0,0 +1,28 @@
+ prefix : <http://example.org/ns#> .
+
+:group1 a :Group ;
+	:lastDate "2009-12-02T00:00:00Z" .
+
+:msg1 a :Message ;
+	:date "2009-12-01T00:00:00Z" ;
+	:group :group1 .
+
+:msg2 a :Message ;
+	:date "2009-12-02T00:00:00Z" ;
+	:group :group1 .
+
+:group2 a :Group ;
+	:lastDate "2009-12-05T00:00:00Z" .
+
+:msg3 a :Message ;
+	:date "2009-12-03T00:00:00Z" ;
+	:group :group2 .
+
+:msg4 a :Message ;
+	:date "2009-12-04T00:00:00Z" ;
+	:group :group2 .
+
+:msg5 a :Message ;
+	:date "2009-12-05T00:00:00Z" ;
+	:group :group2 .
+
diff --git a/tests/libtracker-data/subqueries/subqueries-1.out b/tests/libtracker-data/subqueries/subqueries-1.out
new file mode 100644
index 0000000..905166a
--- /dev/null
+++ b/tests/libtracker-data/subqueries/subqueries-1.out
@@ -0,0 +1,2 @@
+"http://example.org/ns#group2";	"2009-12-05T00:00:00Z"	"http://example.org/ns#msg5";	"3"
+"http://example.org/ns#group1";	"2009-12-02T00:00:00Z"	"http://example.org/ns#msg2";	"2"
diff --git a/tests/libtracker-data/subqueries/subqueries-1.rq b/tests/libtracker-data/subqueries/subqueries-1.rq
new file mode 100644
index 0000000..c32f975
--- /dev/null
+++ b/tests/libtracker-data/subqueries/subqueries-1.rq
@@ -0,0 +1,10 @@
+SELECT ?group ?last_date ?last_message
+    (SELECT COUNT(?message) AS ?message_count WHERE { ?message example:group ?group })
+WHERE {
+    SELECT ?group ?last_date
+        (SELECT ?message WHERE { ?message example:group ?group ; example:date ?date } ORDER BY DESC(?date) LIMIT 1) AS ?last_message
+    WHERE {
+        ?group example:lastDate ?last_date .
+    } ORDER BY DESC(?last_date)
+}
+
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 35792e6..abad601 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -72,6 +72,7 @@ const TestInfo tests[] = {
 	{ "sort/query-sort-3", "sort/data-sort-3", FALSE },
 	{ "sort/query-sort-4", "sort/data-sort-4", FALSE },
 	{ "sort/query-sort-5", "sort/data-sort-4", FALSE }, 
+	{ "subqueries/subqueries-1", "subqueries/data-1", FALSE },
 	/* Bracket error after WHERE */
 	{ "error/query-error-1", "error/query-error-1", TRUE }, 
 	/* Unknown property */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]