[tracker/direct-access: 103/121] tests/functional-tests: Add update tests



commit 58ee5896f0d2ba898d3bb5e2ba6c36bbfe984d89
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              |   12 ++++--
 tests/functional-tests/Makefile.am             |   41 +++++++++++++++++---
 tests/functional-tests/bus-update-test.vala    |   48 ++++++++++++++++++++++++
 tests/functional-tests/direct-update-test.vala |   41 ++++++++++++++++++++
 4 files changed, 131 insertions(+), 11 deletions(-)
---
diff --git a/tests/functional-tests/.gitignore b/tests/functional-tests/.gitignore
index 41b6501..6d07005 100644
--- a/tests/functional-tests/.gitignore
+++ b/tests/functional-tests/.gitignore
@@ -1,7 +1,11 @@
-bus-test
-bus-test.c
-direct-test
-direct-test.c
+bus-query-test
+bus-query-test.c
+direct-query-test
+direct-query-test.c
+bus-update-test
+bus-update-test.c
+direct-update-test
+direct-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 2376008..1afdec7 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -2,14 +2,14 @@ include $(top_srcdir)/Makefile.decl
 
 SUBDIRS = data
 
-INCLUDES =									\
+INCLUDES =					\
 	-I$(top_builddir)/src/libtracker-sparql	\
 	-I$(top_builddir)/src/libtracker-direct	\
 	-I$(top_builddir)/src/libtracker-bus	\
-	$(WARN_CFLAGS)							\
-	$(DBUS_CFLAGS)							\
-	$(GLIB2_CFLAGS)							\
-	$(GIO_CFLAGS)							\
+	$(WARN_CFLAGS)				\
+	$(DBUS_CFLAGS)				\
+	$(GLIB2_CFLAGS)				\
+	$(GIO_CFLAGS)				\
 	$(GTHREAD_CFLAGS)
 
 configdir = $(datadir)/tracker-tests
@@ -49,7 +49,7 @@ bashscripts_SCRIPTS = 				\
 	@sed -e "s|@topsrcdir[ ]|${top_srcdir}|" \
 	     -e "s|@libexecdir[ ]|${libexecdir}|" $< > $@
 
-noinst_PROGRAMS = direct-query-test bus-query-test
+noinst_PROGRAMS = direct-query-test bus-query-test direct-update-test bus-update-test
 
 direct_query_test_VALASOURCES = direct-query-test.vala
 
@@ -57,12 +57,24 @@ direct_query_test_SOURCES = \
 	direct_query_test.vala.stamp \
 	$(direct_query_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)
+
 direct_vapi_sources = \
 	$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
 	$(top_srcdir)/src/libtracker-direct/tracker-direct-$(TRACKER_API_VERSION).vapi
@@ -77,6 +89,12 @@ direct_query_test_LDADD = \
 	$(GIO_LIBS) \
 	$(GLIB2_LIBS)
 
+direct-update-test.vala.stamp: $(direct_update_test_VALASOURCES) $(direct_vapi_sources)
+	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 $^
+	$(AM_V_GEN)touch $@
+
+direct_update_test_LDADD = $(direct_query_test_LDADD)
+
 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
@@ -85,6 +103,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 \
@@ -93,7 +115,12 @@ bus_query_test_LDADD = \
 	$(GLIB2_LIBS) \
 	$(DBUS_LIBS)
 
-BUILT_SOURCES = direct-query-test.vala.stamp bus-query-test.vala.stamp
+bus_update_test_LDADD = $(bus_query_test_LDADD)
+
+BUILT_SOURCES = direct-query-test.vala.stamp \
+	bus-query-test.vala.stamp \
+	direct-update-test.vala.stamp \
+	bus-update-test.vala.stamp
 
 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]