[tracker/wip/carlosg/deserialize-api: 17/17] tests: Add tests for deserialization




commit 62410b9a9dd29582f0a8921f64f03e5edf1ab0ba
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 30 23:53:59 2022 +0200

    tests: Add tests for deserialization
    
    These tests take some RDF, deserialize into a local connection,
    serialize it again, and deserializes it into a dbus connection.
    Then queries are run on both connections to verify data matches.

 tests/libtracker-sparql/deserialize/trig-1.out     |   1 +
 tests/libtracker-sparql/deserialize/trig-1.rq      |   1 +
 tests/libtracker-sparql/deserialize/trig-1.trig    | 605 +++++++++++++++++++++
 tests/libtracker-sparql/deserialize/ttl-1.out      |   1 +
 tests/libtracker-sparql/deserialize/ttl-1.rq       |   1 +
 tests/libtracker-sparql/deserialize/ttl-1.ttl      | 388 +++++++++++++
 tests/libtracker-sparql/meson.build                |  11 +
 tests/libtracker-sparql/tracker-deserialize-test.c | 367 +++++++++++++
 8 files changed, 1375 insertions(+)
---
diff --git a/tests/libtracker-sparql/deserialize/trig-1.out b/tests/libtracker-sparql/deserialize/trig-1.out
new file mode 100644
index 000000000..4f49c887e
--- /dev/null
+++ b/tests/libtracker-sparql/deserialize/trig-1.out
@@ -0,0 +1 @@
+"file:///home/carlos"
diff --git a/tests/libtracker-sparql/deserialize/trig-1.rq b/tests/libtracker-sparql/deserialize/trig-1.rq
new file mode 100644
index 000000000..a69e8cbde
--- /dev/null
+++ b/tests/libtracker-sparql/deserialize/trig-1.rq
@@ -0,0 +1 @@
+SELECT ?u { GRAPH tracker:FileSystem { ?u a nfo:FileDataObject } }
diff --git a/tests/libtracker-sparql/deserialize/trig-1.trig b/tests/libtracker-sparql/deserialize/trig-1.trig
new file mode 100644
index 000000000..afc93adbc
--- /dev/null
+++ b/tests/libtracker-sparql/deserialize/trig-1.trig
@@ -0,0 +1,605 @@
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix nao: <http://tracker.api.gnome.org/ontology/v3/nao#> .
+@prefix nrl: <http://tracker.api.gnome.org/ontology/v3/nrl#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix fts: <http://tracker.api.gnome.org/ontology/v3/fts#> .
+@prefix nmm: <http://tracker.api.gnome.org/ontology/v3/nmm#> .
+@prefix slo: <http://tracker.api.gnome.org/ontology/v3/slo#> .
+@prefix tracker: <http://tracker.api.gnome.org/ontology/v3/tracker#> .
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix nfo: <http://tracker.api.gnome.org/ontology/v3/nfo#> .
+@prefix osinfo: <http://tracker.api.gnome.org/ontology/v3/osinfo#> .
+@prefix nco: <http://tracker.api.gnome.org/ontology/v3/nco#> .
+@prefix nie: <http://tracker.api.gnome.org/ontology/v3/nie#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix mfo: <http://tracker.api.gnome.org/ontology/v3/mfo#> .
+
+GRAPH tracker:FileSystem {
+  <file:///home/carlos> tracker:extractorHash 
"bcfdf10209a8dd3c2031a00fc8d7e4aa8f13992f0eee7321b69311e024db3c07" .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+
+  <file:///home/carlos> nfo:fileLastModified "2022-06-29T17:01:08Z" ;
+    nfo:fileName "carlos" ;
+    nfo:fileSize 28672 ;
+    nfo:fileCreated "2019-05-10T20:52:03Z" ;
+    nfo:fileLastAccessed "2022-06-29T17:01:09Z" .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+
+  <file:///home/carlos> nie:created "2019-05-10T20:52:03Z" .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+}
+
+GRAPH tracker:Audio {
+  <file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Pictures {
+  <file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Video {
+  <file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Documents {
+  <file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:Software {
+  <file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+}
+
+GRAPH tracker:FileSystem {
+  <file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> ;
+    nie:dataSource <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> ;
+    nie:byteSize 28672 .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+
+  <file:///home/carlos> nie:url "file:///home/carlos" ;
+    dc:source <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> ;
+    dc:date "2022-06-29T17:01:08Z", "2022-06-29T17:01:09Z" .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+  <file:///home/carlos> nrl:modified 2 .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+  <file:///home/carlos> nrl:modified 2 .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+  <file:///home/carlos> nrl:modified 2 .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+  <file:///home/carlos> nrl:modified 2 .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+  <file:///home/carlos> nrl:modified 2 .
+}
+
+{
+  rdf:nil nrl:modified 1 .
+
+  nco:default-contact-me nrl:modified 1 .
+
+  nco:gender-male nrl:modified 1 .
+
+  nco:gender-female nrl:modified 1 .
+
+  nco:gender-other nrl:modified 1 .
+
+  nco:presence-status-unset nrl:modified 1 .
+
+  nco:presence-status-offline nrl:modified 1 .
+
+  nco:presence-status-available nrl:modified 1 .
+
+  nco:presence-status-away nrl:modified 1 .
+
+  nco:presence-status-extended-away nrl:modified 1 .
+
+  nco:presence-status-hidden nrl:modified 1 .
+
+  nco:presence-status-busy nrl:modified 1 .
+
+  nco:presence-status-unknown nrl:modified 1 .
+
+  nco:presence-status-error nrl:modified 1 .
+
+  nco:im-capability-text-chat nrl:modified 1 .
+
+  nco:im-capability-media-calls nrl:modified 1 .
+
+  nco:im-capability-audio-calls nrl:modified 1 .
+
+  nco:im-capability-video-calls nrl:modified 1 .
+
+  nco:im-capability-upgrading-calls nrl:modified 1 .
+
+  nco:im-capability-file-transfers nrl:modified 1 .
+
+  nco:im-capability-stream-tubes nrl:modified 1 .
+
+  nco:im-capability-dbus-tubes nrl:modified 1 .
+
+  nco:predefined-auth-status-yes nrl:modified 1 .
+
+  nco:predefined-auth-status-no nrl:modified 1 .
+
+  nco:predefined-auth-status-requested nrl:modified 1 .
+
+  nfo:image-category-screenshot nrl:modified 1 .
+
+  nfo:orientation-top nrl:modified 1 .
+
+  nfo:orientation-top-mirror nrl:modified 1 .
+
+  nfo:orientation-bottom nrl:modified 1 .
+
+  nfo:orientation-bottom-mirror nrl:modified 1 .
+
+  nfo:orientation-left-mirror nrl:modified 1 .
+
+  nfo:orientation-right nrl:modified 1 .
+
+  nfo:orientation-right-mirror nrl:modified 1 .
+
+  nfo:orientation-left nrl:modified 1 .
+
+  nfo:roi-content-face nrl:modified 1 .
+
+  nfo:roi-content-pet nrl:modified 1 .
+
+  nfo:roi-content-focus nrl:modified 1 .
+
+  nfo:roi-content-barcode nrl:modified 1 .
+
+  nfo:roi-content-undefined nrl:modified 1 .
+
+  nmm:flash-on nrl:modified 1 .
+
+  nmm:flash-off nrl:modified 1 .
+
+  nmm:metering-mode-average nrl:modified 1 .
+
+  nmm:metering-mode-center-weighted-average nrl:modified 1 .
+
+  nmm:metering-mode-spot nrl:modified 1 .
+
+  nmm:metering-mode-multispot nrl:modified 1 .
+
+  nmm:metering-mode-pattern nrl:modified 1 .
+
+  nmm:metering-mode-partial nrl:modified 1 .
+
+  nmm:metering-mode-other nrl:modified 1 .
+
+  nmm:white-balance-auto nrl:modified 1 .
+
+  nmm:white-balance-manual nrl:modified 1 .
+
+  nmm:radio-modulation-am nrl:modified 1 .
+
+  nmm:radio-modulation-fm nrl:modified 1 .
+
+  mfo:refresh-now nrl:modified 1 .
+
+  tracker:extractor-data-source nrl:modified 1 .
+
+  nao:predefined-tag-favorite nrl:modified 1 .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+  <file:///home/carlos> nrl:modified 2 .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added 
"2022-06-30T21:48:04Z" .
+
+  <file:///home/carlos> nrl:added "2022-06-30T21:48:04Z" .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added 
"2022-06-30T21:48:04Z" .
+
+  <file:///home/carlos> nrl:added "2022-06-30T21:48:04Z" .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added 
"2022-06-30T21:48:04Z" .
+
+  <file:///home/carlos> nrl:added "2022-06-30T21:48:04Z" .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added 
"2022-06-30T21:48:04Z" .
+
+  <file:///home/carlos> nrl:added "2022-06-30T21:48:04Z" .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added 
"2022-06-30T21:48:04Z" .
+
+  <file:///home/carlos> nrl:added "2022-06-30T21:48:04Z" .
+}
+
+{
+  rdf:nil nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:default-contact-me nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:gender-male nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:gender-female nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:gender-other nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-unset nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-offline nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-available nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-away nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-extended-away nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-hidden nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-busy nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-unknown nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:presence-status-error nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-text-chat nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-media-calls nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-audio-calls nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-video-calls nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-upgrading-calls nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-file-transfers nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-stream-tubes nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:im-capability-dbus-tubes nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:predefined-auth-status-yes nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:predefined-auth-status-no nrl:added "2022-06-30T21:47:50Z" .
+
+  nco:predefined-auth-status-requested nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:image-category-screenshot nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-top nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-top-mirror nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-bottom nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-bottom-mirror nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-left-mirror nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-right nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-right-mirror nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:orientation-left nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:roi-content-face nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:roi-content-pet nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:roi-content-focus nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:roi-content-barcode nrl:added "2022-06-30T21:47:50Z" .
+
+  nfo:roi-content-undefined nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:flash-on nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:flash-off nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-average nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-center-weighted-average nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-spot nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-multispot nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-pattern nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-partial nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:metering-mode-other nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:white-balance-auto nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:white-balance-manual nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:radio-modulation-am nrl:added "2022-06-30T21:47:50Z" .
+
+  nmm:radio-modulation-fm nrl:added "2022-06-30T21:47:50Z" .
+
+  mfo:refresh-now nrl:added "2022-06-30T21:47:50Z" .
+
+  tracker:extractor-data-source nrl:added "2022-06-30T21:47:50Z" .
+
+  nao:predefined-tag-favorite nrl:added "2022-06-30T21:47:50Z" .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added 
"2022-06-30T21:48:04Z" .
+
+  <file:///home/carlos> nrl:added "2022-06-30T21:48:04Z" .
+}
+
+{
+  rdf:nil rdfs:label "nil" .
+
+  tracker:extractor-data-source rdfs:label "Tracker extractor data source" .
+
+  rdf:nil rdfs:comment "The empty list, with no items in it. If the rest of a list is nil then the list has 
no more items in it." .
+}
+
+GRAPH tracker:Audio {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+  <file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
+}
+
+GRAPH tracker:Pictures {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+  <file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
+}
+
+GRAPH tracker:Video {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+  <file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
+}
+
+GRAPH tracker:Documents {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+  <file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
+}
+
+GRAPH tracker:Software {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+  <file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
+}
+
+{
+  rdf:nil rdf:type rdfs:Resource, rdf:List .
+
+  nco:default-contact-me rdf:type rdfs:Resource, nie:InformationElement, nco:Role, nco:Contact, 
nco:PersonContact .
+
+  nco:gender-female rdf:type rdfs:Resource, nco:Gender .
+
+  nco:gender-male rdf:type rdfs:Resource, nco:Gender .
+
+  nco:gender-other rdf:type rdfs:Resource, nco:Gender .
+
+  nco:presence-status-busy rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-hidden rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-extended-away rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-away rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-available rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-error rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-offline rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-unset rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:presence-status-unknown rdf:type rdfs:Resource, nco:PresenceStatus .
+
+  nco:im-capability-video-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-audio-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-media-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-text-chat rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-stream-tubes rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-dbus-tubes rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-file-transfers rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:im-capability-upgrading-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+  nco:predefined-auth-status-requested rdf:type rdfs:Resource, nco:AuthorizationStatus .
+
+  nco:predefined-auth-status-no rdf:type rdfs:Resource, nco:AuthorizationStatus .
+
+  nco:predefined-auth-status-yes rdf:type rdfs:Resource, nco:AuthorizationStatus .
+
+  nfo:image-category-screenshot rdf:type rdfs:Resource, nie:InformationElement, nfo:DataContainer, 
nfo:ImageCategory .
+
+  nfo:orientation-bottom-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-bottom rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-top-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-left rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-top rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-right-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-right rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:orientation-left-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+  nfo:roi-content-barcode rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+  nfo:roi-content-face rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+  nfo:roi-content-focus rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+  nfo:roi-content-undefined rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+  nfo:roi-content-pet rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+  nmm:flash-off rdf:type rdfs:Resource, nmm:Flash .
+
+  nmm:flash-on rdf:type rdfs:Resource, nmm:Flash .
+
+  nmm:metering-mode-average rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:metering-mode-other rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:metering-mode-partial rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:metering-mode-pattern rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:metering-mode-multispot rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:metering-mode-spot rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:metering-mode-center-weighted-average rdf:type rdfs:Resource, nmm:MeteringMode .
+
+  nmm:white-balance-manual rdf:type rdfs:Resource, nmm:WhiteBalance .
+
+  nmm:white-balance-auto rdf:type rdfs:Resource, nmm:WhiteBalance .
+
+  nmm:radio-modulation-am rdf:type rdfs:Resource, nmm:RadioModulation .
+
+  nmm:radio-modulation-fm rdf:type rdfs:Resource, nmm:RadioModulation .
+
+  mfo:refresh-now rdf:type rdfs:Resource, mfo:Action .
+
+  tracker:extractor-data-source rdf:type rdfs:Resource, nie:DataSource .
+
+  nao:predefined-tag-favorite rdf:type rdfs:Resource, nao:Tag .
+}
+
+GRAPH tracker:FileSystem {
+  <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+  <file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
+}
diff --git a/tests/libtracker-sparql/deserialize/ttl-1.out b/tests/libtracker-sparql/deserialize/ttl-1.out
new file mode 100644
index 000000000..4f49c887e
--- /dev/null
+++ b/tests/libtracker-sparql/deserialize/ttl-1.out
@@ -0,0 +1 @@
+"file:///home/carlos"
diff --git a/tests/libtracker-sparql/deserialize/ttl-1.rq b/tests/libtracker-sparql/deserialize/ttl-1.rq
new file mode 100644
index 000000000..4c9651369
--- /dev/null
+++ b/tests/libtracker-sparql/deserialize/ttl-1.rq
@@ -0,0 +1 @@
+SELECT ?u { ?u a nfo:FileDataObject }
diff --git a/tests/libtracker-sparql/deserialize/ttl-1.ttl b/tests/libtracker-sparql/deserialize/ttl-1.ttl
new file mode 100644
index 000000000..e6677e059
--- /dev/null
+++ b/tests/libtracker-sparql/deserialize/ttl-1.ttl
@@ -0,0 +1,388 @@
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix nao: <http://tracker.api.gnome.org/ontology/v3/nao#> .
+@prefix nrl: <http://tracker.api.gnome.org/ontology/v3/nrl#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix fts: <http://tracker.api.gnome.org/ontology/v3/fts#> .
+@prefix nmm: <http://tracker.api.gnome.org/ontology/v3/nmm#> .
+@prefix slo: <http://tracker.api.gnome.org/ontology/v3/slo#> .
+@prefix tracker: <http://tracker.api.gnome.org/ontology/v3/tracker#> .
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix nfo: <http://tracker.api.gnome.org/ontology/v3/nfo#> .
+@prefix osinfo: <http://tracker.api.gnome.org/ontology/v3/osinfo#> .
+@prefix nco: <http://tracker.api.gnome.org/ontology/v3/nco#> .
+@prefix nie: <http://tracker.api.gnome.org/ontology/v3/nie#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix mfo: <http://tracker.api.gnome.org/ontology/v3/mfo#> .
+
+<file:///home/carlos> tracker:extractorHash 
"bcfdf10209a8dd3c2031a00fc8d7e4aa8f13992f0eee7321b69311e024db3c07" .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> tracker:available true .
+
+<file:///home/carlos> nfo:fileLastModified "2022-06-29T17:01:08Z" ;
+  nfo:fileName "carlos" ;
+  nfo:fileSize 28672 ;
+  nfo:fileCreated "2019-05-10T20:52:03Z" ;
+  nfo:fileLastAccessed "2022-06-29T17:01:09Z" .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:rootElementOf 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> .
+
+<file:///home/carlos> nie:created "2019-05-10T20:52:03Z" .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:isStoredAs 
<file:///home/carlos> .
+
+<file:///home/carlos> nie:interpretedAs 
<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> ;
+  nie:dataSource <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> ;
+  nie:byteSize 28672 .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nie:mimeType "inode/directory" .
+
+<file:///home/carlos> nie:url "file:///home/carlos" ;
+  dc:source <urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> ;
+  dc:date "2022-06-29T17:01:08Z", "2022-06-29T17:01:09Z" .
+
+rdf:nil nrl:modified 1 .
+
+nco:default-contact-me nrl:modified 1 .
+
+nco:gender-male nrl:modified 1 .
+
+nco:gender-female nrl:modified 1 .
+
+nco:gender-other nrl:modified 1 .
+
+nco:presence-status-unset nrl:modified 1 .
+
+nco:presence-status-offline nrl:modified 1 .
+
+nco:presence-status-available nrl:modified 1 .
+
+nco:presence-status-away nrl:modified 1 .
+
+nco:presence-status-extended-away nrl:modified 1 .
+
+nco:presence-status-hidden nrl:modified 1 .
+
+nco:presence-status-busy nrl:modified 1 .
+
+nco:presence-status-unknown nrl:modified 1 .
+
+nco:presence-status-error nrl:modified 1 .
+
+nco:im-capability-text-chat nrl:modified 1 .
+
+nco:im-capability-media-calls nrl:modified 1 .
+
+nco:im-capability-audio-calls nrl:modified 1 .
+
+nco:im-capability-video-calls nrl:modified 1 .
+
+nco:im-capability-upgrading-calls nrl:modified 1 .
+
+nco:im-capability-file-transfers nrl:modified 1 .
+
+nco:im-capability-stream-tubes nrl:modified 1 .
+
+nco:im-capability-dbus-tubes nrl:modified 1 .
+
+nco:predefined-auth-status-yes nrl:modified 1 .
+
+nco:predefined-auth-status-no nrl:modified 1 .
+
+nco:predefined-auth-status-requested nrl:modified 1 .
+
+nfo:image-category-screenshot nrl:modified 1 .
+
+nfo:orientation-top nrl:modified 1 .
+
+nfo:orientation-top-mirror nrl:modified 1 .
+
+nfo:orientation-bottom nrl:modified 1 .
+
+nfo:orientation-bottom-mirror nrl:modified 1 .
+
+nfo:orientation-left-mirror nrl:modified 1 .
+
+nfo:orientation-right nrl:modified 1 .
+
+nfo:orientation-right-mirror nrl:modified 1 .
+
+nfo:orientation-left nrl:modified 1 .
+
+nfo:roi-content-face nrl:modified 1 .
+
+nfo:roi-content-pet nrl:modified 1 .
+
+nfo:roi-content-focus nrl:modified 1 .
+
+nfo:roi-content-barcode nrl:modified 1 .
+
+nfo:roi-content-undefined nrl:modified 1 .
+
+nmm:flash-on nrl:modified 1 .
+
+nmm:flash-off nrl:modified 1 .
+
+nmm:metering-mode-average nrl:modified 1 .
+
+nmm:metering-mode-center-weighted-average nrl:modified 1 .
+
+nmm:metering-mode-spot nrl:modified 1 .
+
+nmm:metering-mode-multispot nrl:modified 1 .
+
+nmm:metering-mode-pattern nrl:modified 1 .
+
+nmm:metering-mode-partial nrl:modified 1 .
+
+nmm:metering-mode-other nrl:modified 1 .
+
+nmm:white-balance-auto nrl:modified 1 .
+
+nmm:white-balance-manual nrl:modified 1 .
+
+nmm:radio-modulation-am nrl:modified 1 .
+
+nmm:radio-modulation-fm nrl:modified 1 .
+
+mfo:refresh-now nrl:modified 1 .
+
+tracker:extractor-data-source nrl:modified 1 .
+
+nao:predefined-tag-favorite nrl:modified 1 .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:modified 2 .
+
+<file:///home/carlos> nrl:modified 2 .
+
+rdf:nil nrl:added "2022-06-30T21:13:48Z" .
+
+nco:default-contact-me nrl:added "2022-06-30T21:13:48Z" .
+
+nco:gender-male nrl:added "2022-06-30T21:13:48Z" .
+
+nco:gender-female nrl:added "2022-06-30T21:13:48Z" .
+
+nco:gender-other nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-unset nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-offline nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-available nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-away nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-extended-away nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-hidden nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-busy nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-unknown nrl:added "2022-06-30T21:13:48Z" .
+
+nco:presence-status-error nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-text-chat nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-media-calls nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-audio-calls nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-video-calls nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-upgrading-calls nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-file-transfers nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-stream-tubes nrl:added "2022-06-30T21:13:48Z" .
+
+nco:im-capability-dbus-tubes nrl:added "2022-06-30T21:13:48Z" .
+
+nco:predefined-auth-status-yes nrl:added "2022-06-30T21:13:48Z" .
+
+nco:predefined-auth-status-no nrl:added "2022-06-30T21:13:48Z" .
+
+nco:predefined-auth-status-requested nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:image-category-screenshot nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-top nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-top-mirror nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-bottom nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-bottom-mirror nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-left-mirror nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-right nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-right-mirror nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:orientation-left nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:roi-content-face nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:roi-content-pet nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:roi-content-focus nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:roi-content-barcode nrl:added "2022-06-30T21:13:48Z" .
+
+nfo:roi-content-undefined nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:flash-on nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:flash-off nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-average nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-center-weighted-average nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-spot nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-multispot nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-pattern nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-partial nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:metering-mode-other nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:white-balance-auto nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:white-balance-manual nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:radio-modulation-am nrl:added "2022-06-30T21:13:48Z" .
+
+nmm:radio-modulation-fm nrl:added "2022-06-30T21:13:48Z" .
+
+mfo:refresh-now nrl:added "2022-06-30T21:13:48Z" .
+
+tracker:extractor-data-source nrl:added "2022-06-30T21:13:48Z" .
+
+nao:predefined-tag-favorite nrl:added "2022-06-30T21:13:48Z" .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> nrl:added "2022-06-30T21:17:55Z" .
+
+<file:///home/carlos> nrl:added "2022-06-30T21:17:55Z" .
+
+rdf:nil rdfs:label "nil" .
+
+tracker:extractor-data-source rdfs:label "Tracker extractor data source" .
+
+rdf:nil rdfs:comment "The empty list, with no items in it. If the rest of a list is nil then the list has no 
more items in it." ;
+  rdf:type rdfs:Resource, rdf:List .
+
+nco:default-contact-me rdf:type rdfs:Resource, nie:InformationElement, nco:Role, nco:Contact, 
nco:PersonContact .
+
+nco:gender-female rdf:type rdfs:Resource, nco:Gender .
+
+nco:gender-male rdf:type rdfs:Resource, nco:Gender .
+
+nco:gender-other rdf:type rdfs:Resource, nco:Gender .
+
+nco:presence-status-busy rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-hidden rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-extended-away rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-away rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-available rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-error rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-offline rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-unset rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:presence-status-unknown rdf:type rdfs:Resource, nco:PresenceStatus .
+
+nco:im-capability-video-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-audio-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-media-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-text-chat rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-stream-tubes rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-dbus-tubes rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-file-transfers rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:im-capability-upgrading-calls rdf:type rdfs:Resource, nco:IMCapability .
+
+nco:predefined-auth-status-requested rdf:type rdfs:Resource, nco:AuthorizationStatus .
+
+nco:predefined-auth-status-no rdf:type rdfs:Resource, nco:AuthorizationStatus .
+
+nco:predefined-auth-status-yes rdf:type rdfs:Resource, nco:AuthorizationStatus .
+
+nfo:image-category-screenshot rdf:type rdfs:Resource, nie:InformationElement, nfo:DataContainer, 
nfo:ImageCategory .
+
+nfo:orientation-bottom-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-bottom rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-top-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-left rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-top rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-right-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-right rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:orientation-left-mirror rdf:type rdfs:Resource, nfo:Orientation .
+
+nfo:roi-content-barcode rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+nfo:roi-content-face rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+nfo:roi-content-focus rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+nfo:roi-content-undefined rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+nfo:roi-content-pet rdf:type rdfs:Resource, nie:InformationElement, nfo:RegionOfInterestContent .
+
+nmm:flash-off rdf:type rdfs:Resource, nmm:Flash .
+
+nmm:flash-on rdf:type rdfs:Resource, nmm:Flash .
+
+nmm:metering-mode-average rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:metering-mode-other rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:metering-mode-partial rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:metering-mode-pattern rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:metering-mode-multispot rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:metering-mode-spot rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:metering-mode-center-weighted-average rdf:type rdfs:Resource, nmm:MeteringMode .
+
+nmm:white-balance-manual rdf:type rdfs:Resource, nmm:WhiteBalance .
+
+nmm:white-balance-auto rdf:type rdfs:Resource, nmm:WhiteBalance .
+
+nmm:radio-modulation-am rdf:type rdfs:Resource, nmm:RadioModulation .
+
+nmm:radio-modulation-fm rdf:type rdfs:Resource, nmm:RadioModulation .
+
+mfo:refresh-now rdf:type rdfs:Resource, mfo:Action .
+
+tracker:extractor-data-source rdf:type rdfs:Resource, nie:DataSource .
+
+nao:predefined-tag-favorite rdf:type rdfs:Resource, nao:Tag .
+
+<urn:fileid:/dev/mapper/luks-6fbd7095-44f6-4829-9760-fa1380f37947:5373953> rdf:type rdfs:Resource, 
nie:InformationElement, nfo:DataContainer, nfo:Folder, nie:DataSource, tracker:IndexedFolder .
+
+<file:///home/carlos> rdf:type rdfs:Resource, nie:DataObject, nfo:FileDataObject .
diff --git a/tests/libtracker-sparql/meson.build b/tests/libtracker-sparql/meson.build
index 3eef29be9..6bb79ad82 100644
--- a/tests/libtracker-sparql/meson.build
+++ b/tests/libtracker-sparql/meson.build
@@ -85,6 +85,17 @@ tests += {
   'suite': ['sparql'],
 }
 
+tracker_deserialize_test = executable('tracker-deserialize-test',
+  'tracker-deserialize-test.c',
+  dependencies: [tracker_common_dep, tracker_sparql_dep],
+  c_args: libtracker_sparql_test_c_args + test_c_args)
+
+tests += {
+  'name': 'deserialize',
+  'exe': tracker_deserialize_test,
+  'suite': ['sparql'],
+}
+
 tracker_namespaces_test = executable('tracker-namespaces-test',
   'tracker-namespaces-test.c',
   dependencies: [tracker_common_dep, tracker_sparql_dep],
diff --git a/tests/libtracker-sparql/tracker-deserialize-test.c 
b/tests/libtracker-sparql/tracker-deserialize-test.c
new file mode 100644
index 000000000..cd8c9af87
--- /dev/null
+++ b/tests/libtracker-sparql/tracker-deserialize-test.c
@@ -0,0 +1,367 @@
+/*
+ * Copyright (C) 2020, Red Hat Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <libtracker-sparql/tracker-sparql.h>
+
+typedef struct {
+       const gchar *test_name;
+       const gchar *data_file;
+       const gchar *query_file;
+       const gchar *output_file;
+       TrackerRdfFormat format;
+} TestInfo;
+
+TestInfo tests[] = {
+       { "ttl/ttl-1", "deserialize/ttl-1.ttl", "deserialize/ttl-1.rq", "deserialize/ttl-1.out", 
TRACKER_RDF_FORMAT_TURTLE },
+       { "trig/trig-1", "deserialize/trig-1.trig", "deserialize/trig-1.rq", "deserialize/trig-1.out", 
TRACKER_RDF_FORMAT_TRIG },
+};
+
+typedef struct {
+       TestInfo *test;
+       TrackerSparqlConnection *direct;
+       TrackerSparqlConnection *dbus;
+       GMainLoop *loop;
+} TestFixture;
+
+typedef struct {
+       TrackerSparqlConnection *direct;
+       GDBusConnection *dbus_conn;
+} StartupData;
+
+static gboolean started = FALSE;
+static const gchar *bus_name = NULL;
+
+static void
+check_result (TrackerSparqlCursor *cursor,
+              const gchar         *results_filename)
+{
+       GString *test_results;
+       gchar *results;
+       GError *error = NULL;
+       gint col;
+
+       g_file_get_contents (results_filename, &results, NULL, &error);
+       g_assert_no_error (error);
+
+       /* compare results with reference output */
+
+       test_results = g_string_new ("");
+
+       while (tracker_sparql_cursor_next (cursor, NULL, &error)) {
+               GString *row_str = g_string_new (NULL);
+
+               for (col = 0; col < tracker_sparql_cursor_get_n_columns (cursor); col++) {
+                       const gchar *str;
+
+                       if (col > 0) {
+                               g_string_append (row_str, "\t");
+                       }
+
+                       str = tracker_sparql_cursor_get_string (cursor, col, NULL);
+
+                       /* Hack to avoid misc properties that might tamper with
+                        * test reproduceability in DESCRIBE and other unrestricted
+                        * queries.
+                        */
+                       if (g_strcmp0 (str, TRACKER_PREFIX_NRL "modified") == 0 ||
+                           g_strcmp0 (str, TRACKER_PREFIX_NRL "added") == 0) {
+                               g_string_free (row_str, TRUE);
+                               row_str = NULL;
+                               break;
+                       }
+
+                       if (str != NULL) {
+                               /* bound variable */
+                               g_string_append_printf (row_str, "\"%s\"", str);
+                       }
+               }
+
+               if (row_str) {
+                       g_string_append (test_results, row_str->str);
+                       g_string_free (row_str, TRUE);
+                       g_string_append (test_results, "\n");
+               }
+       }
+
+       if (strcmp (results, test_results->str) != 0) {
+               /* print result difference */
+               gchar *quoted_results;
+               gchar *command_line;
+               gchar *quoted_command_line;
+               gchar *shell;
+               gchar *diff;
+
+               quoted_results = g_shell_quote (test_results->str);
+               command_line = g_strdup_printf ("echo -n %s | diff -u %s -", quoted_results, 
results_filename);
+               quoted_command_line = g_shell_quote (command_line);
+               shell = g_strdup_printf ("sh -c %s", quoted_command_line);
+               g_spawn_command_line_sync (shell, &diff, NULL, NULL, &error);
+               g_assert_no_error (error);
+
+               g_error ("%s", diff);
+
+               g_free (quoted_results);
+               g_free (command_line);
+               g_free (quoted_command_line);
+               g_free (shell);
+               g_free (diff);
+       }
+
+       g_string_free (test_results, TRUE);
+       g_free (results);
+}
+
+static void
+setup (TestFixture   *fixture,
+       gconstpointer  context)
+{
+       const TestFixture *test = context;
+
+       *fixture = *test;
+}
+
+static void
+deserialize_dbus_cb (GObject      *source,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+       TestFixture *test_fixture = user_data;
+       gboolean retval;
+       GError *error = NULL;
+
+       retval = tracker_sparql_connection_deserialize_finish (TRACKER_SPARQL_CONNECTION (source),
+                                                              res, &error);
+       g_assert_true (retval);
+       g_assert_no_error (error);
+
+       g_main_loop_quit (test_fixture->loop);
+}
+
+static void
+serialize_direct_cb (GObject      *source,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+       TestFixture *test_fixture = user_data;
+       GInputStream *istream;
+       GError *error = NULL;
+
+       istream = tracker_sparql_connection_serialize_finish (TRACKER_SPARQL_CONNECTION (source),
+                                                            res, &error);
+       g_assert_no_error (error);
+       g_assert_nonnull (istream);
+
+       /* Load RDF data into other connection */
+       tracker_sparql_connection_deserialize_async (test_fixture->dbus,
+                                                    TRACKER_DESERIALIZE_FLAGS_NONE,
+                                                    test_fixture->test->format,
+                                                    NULL,
+                                                    istream,
+                                                    NULL,
+                                                    deserialize_dbus_cb,
+                                                    test_fixture);
+}
+
+static void
+deserialize_direct_cb (GObject      *source,
+                       GAsyncResult *res,
+                       gpointer      user_data)
+{
+       TestFixture *test_fixture = user_data;
+       gboolean retval;
+       GError *error = NULL;
+
+       retval = tracker_sparql_connection_deserialize_finish (TRACKER_SPARQL_CONNECTION (source),
+                                                              res, &error);
+       g_assert_true (retval);
+       g_assert_no_error (error);
+
+       /* Read RDF data back */
+       tracker_sparql_connection_serialize_async (test_fixture->direct,
+                                                  TRACKER_SERIALIZE_FLAGS_NONE,
+                                                  test_fixture->test->format,
+                                                  "DESCRIBE ?u WHERE { ?u a rdfs:Resource }",
+                                                  NULL,
+                                                  serialize_direct_cb,
+                                                  user_data);
+}
+
+static void
+test (TestFixture   *test_fixture,
+      gconstpointer  context)
+{
+       GError *error = NULL;
+       gchar *path, *query_path, *query;
+       TestInfo *test_info = test_fixture->test;
+       TrackerSparqlCursor *cursor;
+       GInputStream *istream;
+       GFile *file;
+
+       test_fixture->loop = g_main_loop_new (NULL, FALSE);
+
+       path = g_build_filename (TOP_SRCDIR, "tests", "libtracker-sparql",
+                                test_info->data_file, NULL);
+       file = g_file_new_for_path (path);
+       istream = G_INPUT_STREAM (g_file_read (file, NULL, &error));
+       g_object_unref (file);
+       g_assert_no_error (error);
+       g_free (path);
+
+       /* Load RDF data */
+       tracker_sparql_connection_deserialize_async (test_fixture->direct,
+                                                    TRACKER_DESERIALIZE_FLAGS_NONE,
+                                                    test_fixture->test->format,
+                                                    NULL,
+                                                    istream,
+                                                    NULL,
+                                                    deserialize_direct_cb,
+                                                    test_fixture);
+
+       g_main_loop_run (test_fixture->loop);
+
+       query_path = g_build_filename (TOP_SRCDIR, "tests", "libtracker-sparql",
+                                      test_info->query_file, NULL);
+       path = g_build_filename (TOP_SRCDIR, "tests", "libtracker-sparql",
+                                test_info->output_file, NULL);
+
+       g_file_get_contents (query_path, &query, NULL, &error);
+       g_assert_no_error (error);
+       g_free (query_path);
+
+       cursor = tracker_sparql_connection_query (test_fixture->direct,
+                                                 query,
+                                                 NULL,
+                                                 &error);
+       g_assert_no_error (error);
+       g_assert_nonnull (cursor);
+       check_result (cursor, path);
+       g_object_unref (cursor);
+
+       cursor = tracker_sparql_connection_query (test_fixture->dbus,
+                                                 query,
+                                                 NULL,
+                                                 &error);
+       g_assert_no_error (error);
+       g_assert_nonnull (cursor);
+       check_result (cursor, path);
+       g_object_unref (cursor);
+
+       g_free (path);
+       g_free (query);
+}
+
+TrackerSparqlConnection *
+create_local_connection (GError **error)
+{
+        TrackerSparqlConnection *conn;
+        GFile *ontology;
+
+        ontology = g_file_new_for_path (TEST_ONTOLOGIES_DIR);
+
+        conn = tracker_sparql_connection_new (0, NULL, ontology, NULL, error);
+        g_object_unref (ontology);
+
+        return conn;
+}
+
+static gpointer
+thread_func (gpointer user_data)
+{
+       StartupData *data = user_data;
+       TrackerEndpointDBus *endpoint;
+       GMainContext *context;
+       GMainLoop *main_loop;
+
+       context = g_main_context_new ();
+       g_main_context_push_thread_default (context);
+
+       main_loop = g_main_loop_new (context, FALSE);
+
+       endpoint = tracker_endpoint_dbus_new (data->direct, data->dbus_conn, NULL, NULL, NULL);
+       if (!endpoint)
+               return NULL;
+
+       started = TRUE;
+       g_main_loop_run (main_loop);
+
+       return NULL;
+}
+
+static gboolean
+create_connections (TrackerSparqlConnection **dbus,
+                    TrackerSparqlConnection **direct,
+                    GError                  **error)
+{
+       StartupData data;
+       GThread *thread;
+
+       data.direct = create_local_connection (NULL);
+       if (!data.direct)
+               return FALSE;
+       data.dbus_conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+       if (!data.dbus_conn)
+               return FALSE;
+
+       thread = g_thread_new (NULL, thread_func, &data);
+
+       while (!started)
+               g_usleep (100);
+
+       bus_name = g_dbus_connection_get_unique_name (data.dbus_conn);
+       *dbus = tracker_sparql_connection_bus_new (bus_name,
+                                                  NULL, data.dbus_conn, error);
+       *direct = create_local_connection (error);
+       g_thread_unref (thread);
+
+       return TRUE;
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+       TrackerSparqlConnection *dbus = NULL, *direct = NULL;
+       GError *error = NULL;
+       guint i;
+
+       g_test_init (&argc, &argv, NULL);
+
+       g_assert_true (create_connections (&dbus, &direct, &error));
+       g_assert_no_error (error);
+
+       for (i = 0; i < G_N_ELEMENTS (tests); i++) {
+               TestFixture *fixture;
+               gchar *testpath;
+
+               fixture = g_new0 (TestFixture, 1);
+               fixture->direct = direct;
+               fixture->dbus = dbus;
+               fixture->test = &tests[i];
+               testpath = g_strconcat ("/libtracker-sparql/deserialize/", tests[i].test_name, NULL);
+               g_test_add (testpath, TestFixture, fixture, setup, test, NULL);
+               g_free (testpath);
+       }
+
+       return g_test_run ();
+}


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