[tracker/libtracker-bus: 26/51] tests/functional-tests: Add update tests



commit cdc652b217035798e994afb43d0ee61255904622
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Jul 21 17:42:18 2010 +0200

    tests/functional-tests: Add update tests

 tests/functional-tests/.gitignore              |    6 ++-
 tests/functional-tests/Makefile.am             |   23 ++++++++++-
 tests/functional-tests/bus-update-test.vala    |   48 ++++++++++++++++++++++++
 tests/functional-tests/direct-update-test.vala |   41 ++++++++++++++++++++
 4 files changed, 114 insertions(+), 4 deletions(-)
---
diff --git a/tests/functional-tests/.gitignore b/tests/functional-tests/.gitignore
index 6856488..2d405c8 100644
--- a/tests/functional-tests/.gitignore
+++ b/tests/functional-tests/.gitignore
@@ -1,5 +1,7 @@
-bus-test
-bus-test.c
+bus-query-test
+bus-query-test.c
+bus-update-test
+bus-update-test.c
 ttl
 force-sqlite-misused-batch.sh
 force-sqlite-misused.sh
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 7674f7b..2982a7a 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -49,7 +49,7 @@ bashscripts_SCRIPTS = 				\
 	@sed -e "s|@topsrcdir[ ]|${top_srcdir}|" \
 	     -e "s|@libexecdir[ ]|${libexecdir}|" $< > $@
 
-noinst_PROGRAMS = busy-handling-test bus-test
+noinst_PROGRAMS = busy-handling-test bus-query-test bus-update-test
 
 busy_handling_test_VALASOURCES = busy-handling-test.vala
 
@@ -73,12 +73,24 @@ MAINTAINERCLEANFILES =					\
 	$(BUILT_SOURCES)				\
 	$(busy_handling_test_VALASOURCES:.vala=.c)
 
+direct_update_test_VALASOURCES = direct-update-test.vala
+
+direct_update_test_SOURCES = \
+	direct_update_test.vala.stamp \
+	$(direct_update_test_VALASOURCES:.vala=.c)
+
 bus_query_test_VALASOURCES = bus-query-test.vala
 
 bus_query_test_SOURCES = \
 	bus_query_test.vala.stamp \
 	$(bus_query_test_VALASOURCES:.vala=.c)
 
+bus_update_test_VALASOURCES = bus-update-test.vala
+
+bus_update_test_SOURCES = \
+	bus_update_test.vala.stamp \
+	$(bus_update_test_VALASOURCES:.vala=.c)
+
 bus_vapi_sources = \
 	$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
 	$(top_srcdir)/src/libtracker-bus/tracker-bus-$(TRACKER_API_VERSION).vapi
@@ -87,6 +99,10 @@ bus-query-test.vala.stamp: $(bus_query_test_VALASOURCES) $(bus_vapi_sources)
 	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 $^
 	$(AM_V_GEN)touch $@
 
+bus-update-test.vala.stamp: $(bus_update_test_VALASOURCES) $(bus_vapi_sources)
+	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 $^
+	$(AM_V_GEN)touch $@
+
 bus_query_test_LDADD = \
 	$(top_builddir)/src/libtracker-bus/libtracker-bus.la \
 	$(top_builddir)/src/libtracker-sparql/libtracker-sparql-$(TRACKER_API_VERSION).la \
@@ -97,7 +113,10 @@ bus_query_test_LDADD = \
 
 BUILT_SOURCES = \
 	busy-handling-test.vala.stamp \
-	bus-query-test.vala.stamp
+	bus-query-test.vala.stamp \
+	bus-update-test.vala.stamp
+
+bus_update_test_LDADD = $(bus_query_test_LDADD)
 
 EXTRA_DIST = 					\
 	$(config_SCRIPTS) 			\
diff --git a/tests/functional-tests/bus-update-test.vala b/tests/functional-tests/bus-update-test.vala
new file mode 100644
index 0000000..6514fdb
--- /dev/null
+++ b/tests/functional-tests/bus-update-test.vala
@@ -0,0 +1,48 @@
+using Tracker;
+using Tracker.Sparql;
+
+private int iter_cursor (Cursor cursor)
+{
+	try {
+		while (cursor.next()) {
+			int i;
+
+			for (i = 0; i < cursor.n_columns; i++) {
+				print ("%s%s", i != 0 ? ",":"", cursor.get_string (i));
+			}
+
+			print ("\n");
+		}
+	} catch (GLib.Error e) {
+		warning ("Couldn't iterate query results: %s", e.message);
+		return -1;
+	}
+
+	return (0);
+}
+
+int
+main( string[] args )
+{
+	Sparql.Connection con = new Tracker.Bus.Connection ();
+	Cursor cursor;
+	int a;
+
+	try {
+		con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
+	} catch (GLib.Error e) {
+		warning ("Couldn't perform query: %s", e.message);
+		return -1;
+	}
+
+	try {
+		cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }");
+	} catch (GLib.Error e) {
+		warning ("Couldn't perform query: %s", e.message);
+		return -1;
+	}
+
+	a = iter_cursor (cursor);
+
+	return a;
+}
diff --git a/tests/functional-tests/direct-update-test.vala b/tests/functional-tests/direct-update-test.vala
new file mode 100644
index 0000000..d676c1c
--- /dev/null
+++ b/tests/functional-tests/direct-update-test.vala
@@ -0,0 +1,41 @@
+using Tracker;
+using Tracker.Sparql;
+
+private int iter_cursor (Cursor cursor)
+{
+	try {
+		while (cursor.next()) {
+			int i;
+
+			for (i = 0; i < cursor.n_columns; i++) {
+				print ("%s%s", i != 0 ? ",":"", cursor.get_string (i));
+			}
+
+			print ("\n");
+		}
+	} catch (GLib.Error e) {
+		warning ("Couldn't iterate query results: %s", e.message);
+		return -1;
+	}
+
+	return (0);
+}
+
+int
+main( string[] args )
+{
+	Sparql.Connection con = new Tracker.Direct.Connection ();
+	Cursor cursor;
+	int a;
+
+	try {
+		con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
+		cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }");
+		a = iter_cursor (cursor);
+	} catch (GLib.Error e) {
+		warning ("Couldn't perform query: %s", e.message);
+		return -1;
+	}
+
+	return a;
+}



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