From 7d1eeba0264eaa6b202bf71f4a44ec1df9f12b5e Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 17 May 2017 14:35:37 -0400 Subject: [PATCH 1/9] Upgrade to rdflib 0.15.0, update PATCH tests --- package.json | 2 +- test/patch-2.js | 46 ++++++++++++++++++++++++++++++++-------------- test/patch.js | 24 +++++++++--------------- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 914cc3996..3d3358732 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "node-forge": "^0.6.38", "nodemailer": "^3.1.4", "nomnom": "^1.8.1", - "rdflib": "^0.12.3", + "rdflib": "^0.15.0", "recursive-readdir": "^2.1.0", "request": "^2.72.0", "rimraf": "^2.5.0", diff --git a/test/patch-2.js b/test/patch-2.js index 0b8bfda80..862c3db29 100644 --- a/test/patch-2.js +++ b/test/patch-2.js @@ -38,7 +38,31 @@ describe('PATCH', function () { describe('DELETE', function () { it('reproduce index 1 bug from pad', function (done) { - var expected = '@prefix dc: .\n@prefix meeting: .\n@prefix card: .\n@prefix xsd: .\n@prefix p: .\n@prefix in: .\n@prefix n: .\n@prefix flow: .\n@prefix ic: .\n@prefix ui: .\n\n<#this>\n dc:author\n card:i;\n dc:created\n "2016-10-25T15:44:42Z"^^xsd:dateTime;\n dc:title\n "Shared Notes";\n a p:Notepad;\n p:next\n <#id1477502276660>.\n in:this flow:participation <#id1477522707481>; meeting:sharedNotes <#this> .\n <#id1477502276660> dc:author card:i; n:content ""; p:next <#this> .\n<#id1477522707481>\n ic:dtstart\n "2016-10-26T22:58:27Z"^^xsd:dateTime;\n flow:participant\n card:i;\n ui:backgroundColor\n "#c1d0c8".\n' + var expected = `@prefix : . +@prefix dc: . +@prefix c: . +@prefix n: . +@prefix p: . +@prefix ic: . +@prefix XML: . +@prefix flow: . +@prefix ui: . +@prefix ind: . +@prefix mee: . + +:id1477502276660 dc:author c:i; n:content ""; p:next :this. + +:id1477522707481 + ic:dtstart "2016-10-26T22:58:27Z"^^XML:dateTime; + flow:participant c:i; + ui:backgroundColor "#c1d0c8". +:this + a p:Notepad; + dc:author c:i; + dc:created "2016-10-25T15:44:42Z"^^XML:dateTime; + dc:title "Shared Notes"; + p:next :id1477502276660. +ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` write(`\n\ @@ -109,10 +133,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/prefixSparql.ttl'), - '@prefix schema: .\n' + - '@prefix profile: .\n' + - '\n' + - ' <#> profile:first_name "Timothy"; a schema:Person .\n') + '@prefix : .\n@prefix schema: .\n@prefix pro: .\n\n: a schema:Person; pro:first_name "Timothy".\n\n') rm('sampleContainer/prefixSparql.ttl') done(err) }) @@ -121,6 +142,8 @@ describe('PATCH', function () { describe('INSERT', function () { it('should add a new triple', function (done) { + let expectedValue = `@prefix : .\n\n:current :temp 123 .\n\n:test :hello 456 .\n\n` + write( '<#current> <#temp> 123 .', 'sampleContainer/addingTriple.ttl') @@ -131,9 +154,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTriple.ttl'), - '\n' + - ' <#current> <#temp> 123 .\n' + - ' <#test> <#hello> 456 .\n') + expectedValue) rm('sampleContainer/addingTriple.ttl') done(err) }) @@ -150,8 +171,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleValue.ttl'), - '\n' + - ' <#current> <#temp> 123, 456 .\n') + '@prefix : .\n\n:current :temp 123, 456 .\n\n') rm('sampleContainer/addingTripleValue.ttl') done(err) }) @@ -168,8 +188,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleSubj.ttl'), - '\n' + - ' <#current> <#temp2> 456; <#temp> 123 .\n') + '@prefix : .\n\n:current :temp 123; :temp2 456 .\n\n') rm('sampleContainer/addingTripleSubj.ttl') done(err) }) @@ -187,8 +206,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/emptyExample.ttl'), - '\n' + - ' <#current> <#temp> 123 .\n') + '@prefix : .\n\n:current :temp 123 .\n\n') rm('sampleContainer/emptyExample.ttl') done(err) }) diff --git a/test/patch.js b/test/patch.js index 485161168..f993874e7 100644 --- a/test/patch.js +++ b/test/patch.js @@ -19,6 +19,8 @@ describe('PATCH', function () { it('should create a new file if file does not exist', function (done) { rm('sampleContainer/notExisting.ttl') + let expectedValue = '@prefix : .\n\n:test :hello 456 .\n\n' + server.patch('/notExisting.ttl') .set('content-type', 'application/sparql-update') .send('INSERT DATA { :test :hello 456 .}') @@ -26,7 +28,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/notExisting.ttl'), - '\n <#test> <#hello> 456 .\n') + expectedValue) rm('sampleContainer/notExisting.ttl') done(err) }) @@ -44,7 +46,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/existingTriple.ttl'), - '\n') + '@prefix : .\n\n') rm('sampleContainer/existingTriple.ttl') done(err) }) @@ -72,10 +74,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/prefixSparql.ttl'), - '@prefix schema: .\n' + - '@prefix profile: .\n' + - '\n' + - ' <#> profile:first_name "Timothy"; a schema:Person .\n') + '@prefix : .\n@prefix schema: .\n@prefix pro: .\n\n: a schema:Person; pro:first_name "Timothy".\n\n') rm('sampleContainer/prefixSparql.ttl') done(err) }) @@ -94,9 +93,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTriple.ttl'), - '\n' + - ' <#current> <#temp> 123 .\n' + - ' <#test> <#hello> 456 .\n') + '@prefix : .\n\n:current :temp 123 .\n\n:test :hello 456 .\n\n') rm('sampleContainer/addingTriple.ttl') done(err) }) @@ -113,8 +110,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleValue.ttl'), - '\n' + - ' <#current> <#temp> 123, 456 .\n') + '@prefix : .\n\n:current :temp 123, 456 .\n\n') rm('sampleContainer/addingTripleValue.ttl') done(err) }) @@ -131,8 +127,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleSubj.ttl'), - '\n' + - ' <#current> <#temp2> 456; <#temp> 123 .\n') + '@prefix : .\n\n:current :temp 123; :temp2 456 .\n\n') rm('sampleContainer/addingTripleSubj.ttl') done(err) }) @@ -150,8 +145,7 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/emptyExample.ttl'), - '\n' + - ' <#current> <#temp> 123 .\n') + '@prefix : .\n\n:current :temp 123 .\n\n') rm('sampleContainer/emptyExample.ttl') done(err) }) From f357fab8247c112b4efdd1f3c88ceca13faddd42 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 17 May 2017 16:50:00 -0400 Subject: [PATCH 2/9] Pass base uri to glob serialization --- lib/handlers/get.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/handlers/get.js b/lib/handlers/get.js index 97cac626c..e52faec64 100644 --- a/lib/handlers/get.js +++ b/lib/handlers/get.js @@ -176,7 +176,7 @@ function globHandler (req, res, next) { var data = $rdf.serialize( undefined, globGraph, - null, + filename, 'text/turtle') // TODO this should be added as a middleware in the routes res.setHeader('Content-Type', 'text/turtle') From bff0c2245f2a6bca2d575b164c1f4120c3352f66 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Fri, 19 May 2017 11:10:48 -0400 Subject: [PATCH 3/9] Fix base serialization uri for glob requests --- lib/handlers/get.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/handlers/get.js b/lib/handlers/get.js index e52faec64..05cc60bb5 100644 --- a/lib/handlers/get.js +++ b/lib/handlers/get.js @@ -7,6 +7,7 @@ var $rdf = require('rdflib') var S = require('string') var async = require('async') var Negotiator = require('negotiator') +const url = require('url') var debug = require('debug')('solid:get') var debugGlob = require('debug')('solid:glob') @@ -132,6 +133,7 @@ function globHandler (req, res, next) { var root = !ldp.idp ? ldp.root : ldp.root + req.hostname + '/' var filename = utils.uriToFilename(req.path, root) var uri = utils.uriBase(req) + const requestUri = url.resolve(uri, req.path) var globOptions = { noext: true, @@ -176,7 +178,7 @@ function globHandler (req, res, next) { var data = $rdf.serialize( undefined, globGraph, - filename, + requestUri, 'text/turtle') // TODO this should be added as a middleware in the routes res.setHeader('Content-Type', 'text/turtle') From 15a680eec274345629f21abe3baaaf6c6dbfcf2b Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Fri, 19 May 2017 11:11:06 -0400 Subject: [PATCH 4/9] Add expected results for glob test --- test/http.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/http.js b/test/http.js index 8306e11af..902c23400 100644 --- a/test/http.js +++ b/test/http.js @@ -286,9 +286,33 @@ describe('HTTP APIs', function () { .expect(200, done) }) it('should have glob support', function (done) { + let expectedValue = `@prefix : <#>. +@prefix rdf: . +@prefix n0: . +@prefix TR: . +@prefix d: . +@prefix n1: . + +n0:a + n0:b + """The first line +The second line + more""", + [ + rdf:first "apple"; + rdf:rest [ rdf:first "banana"; rdf:rest rdf:nil ] + ]. +TR:rdf-syntax-grammar + n0:editor [ n0:fullname "Dave Beckett"; n0:homePage d: ]; + n1:title "RDF/XML Syntax Specification (Revised)". +` server.get('/sampleContainer/example*') .expect('content-type', /text\/turtle/) - .expect(200, done) + .expect(200) + .expect((res) => { + assert.equal(res.text, expectedValue) + }) + .end(done) }) it('should have set acl and describedBy Links for container', function (done) { From c3a7b9efc1274ee99aeeac3c1513a2fd68869fc9 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Fri, 19 May 2017 11:11:19 -0400 Subject: [PATCH 5/9] Fix formatting for PATCH tests --- test/patch-2.js | 20 +++++++++++++------- test/patch.js | 22 +++++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/test/patch-2.js b/test/patch-2.js index 862c3db29..23476936b 100644 --- a/test/patch-2.js +++ b/test/patch-2.js @@ -133,7 +133,10 @@ ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` .end(function (err, res, body) { assert.equal( read('sampleContainer/prefixSparql.ttl'), - '@prefix : .\n@prefix schema: .\n@prefix pro: .\n\n: a schema:Person; pro:first_name "Timothy".\n\n') + '@prefix : .\n' + + '@prefix schema: .\n' + + '@prefix pro: .\n\n' + + ': a schema:Person; pro:first_name "Timothy".\n\n') rm('sampleContainer/prefixSparql.ttl') done(err) }) @@ -142,8 +145,6 @@ ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` describe('INSERT', function () { it('should add a new triple', function (done) { - let expectedValue = `@prefix : .\n\n:current :temp 123 .\n\n:test :hello 456 .\n\n` - write( '<#current> <#temp> 123 .', 'sampleContainer/addingTriple.ttl') @@ -154,7 +155,9 @@ ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTriple.ttl'), - expectedValue) + '@prefix : .\n\n' + + ':current :temp 123 .\n\n' + + ':test :hello 456 .\n\n') rm('sampleContainer/addingTriple.ttl') done(err) }) @@ -171,7 +174,8 @@ ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleValue.ttl'), - '@prefix : .\n\n:current :temp 123, 456 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123, 456 .\n\n') rm('sampleContainer/addingTripleValue.ttl') done(err) }) @@ -188,7 +192,8 @@ ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleSubj.ttl'), - '@prefix : .\n\n:current :temp 123; :temp2 456 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123; :temp2 456 .\n\n') rm('sampleContainer/addingTripleSubj.ttl') done(err) }) @@ -206,7 +211,8 @@ ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n` .end(function (err, res, body) { assert.equal( read('sampleContainer/emptyExample.ttl'), - '@prefix : .\n\n:current :temp 123 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123 .\n\n') rm('sampleContainer/emptyExample.ttl') done(err) }) diff --git a/test/patch.js b/test/patch.js index f993874e7..036544283 100644 --- a/test/patch.js +++ b/test/patch.js @@ -19,7 +19,6 @@ describe('PATCH', function () { it('should create a new file if file does not exist', function (done) { rm('sampleContainer/notExisting.ttl') - let expectedValue = '@prefix : .\n\n:test :hello 456 .\n\n' server.patch('/notExisting.ttl') .set('content-type', 'application/sparql-update') @@ -28,7 +27,8 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/notExisting.ttl'), - expectedValue) + '@prefix : .\n\n' + + ':test :hello 456 .\n\n') rm('sampleContainer/notExisting.ttl') done(err) }) @@ -74,7 +74,10 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/prefixSparql.ttl'), - '@prefix : .\n@prefix schema: .\n@prefix pro: .\n\n: a schema:Person; pro:first_name "Timothy".\n\n') + '@prefix : .\n' + + '@prefix schema: .\n' + + '@prefix pro: .\n\n' + + ': a schema:Person; pro:first_name "Timothy".\n\n') rm('sampleContainer/prefixSparql.ttl') done(err) }) @@ -93,7 +96,9 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTriple.ttl'), - '@prefix : .\n\n:current :temp 123 .\n\n:test :hello 456 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123 .\n\n' + + ':test :hello 456 .\n\n') rm('sampleContainer/addingTriple.ttl') done(err) }) @@ -110,7 +115,8 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleValue.ttl'), - '@prefix : .\n\n:current :temp 123, 456 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123, 456 .\n\n') rm('sampleContainer/addingTripleValue.ttl') done(err) }) @@ -127,7 +133,8 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/addingTripleSubj.ttl'), - '@prefix : .\n\n:current :temp 123; :temp2 456 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123; :temp2 456 .\n\n') rm('sampleContainer/addingTripleSubj.ttl') done(err) }) @@ -145,7 +152,8 @@ describe('PATCH', function () { .end(function (err, res, body) { assert.equal( read('sampleContainer/emptyExample.ttl'), - '@prefix : .\n\n:current :temp 123 .\n\n') + '@prefix : .\n\n' + + ':current :temp 123 .\n\n') rm('sampleContainer/emptyExample.ttl') done(err) }) From 4f7d6208eb3975dc4a7a3231f2b144769f9c55ef Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 31 May 2017 13:49:05 -0400 Subject: [PATCH 6/9] HTTP glob get test - add statement to test serialize base --- test/http.js | 29 ++++++++++++--------- test/resources/sampleContainer/example1.ttl | 2 ++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/http.js b/test/http.js index 902c23400..7ff15a017 100644 --- a/test/http.js +++ b/test/http.js @@ -286,25 +286,28 @@ describe('HTTP APIs', function () { .expect(200, done) }) it('should have glob support', function (done) { - let expectedValue = `@prefix : <#>. -@prefix rdf: . -@prefix n0: . + let expectedValue = `@prefix rdf: . +@prefix dc: . +@prefix ex: . +@prefix e: . @prefix TR: . @prefix d: . -@prefix n1: . -n0:a - n0:b + <> a e:glob . +TR:rdf-syntax-grammar + ex:editor + [ ex:fullname "Dave Beckett"; ex:homePage d: ]; + dc:title + "RDF/XML Syntax Specification (Revised)". +ex:a + ex:b """The first line The second line more""", - [ - rdf:first "apple"; - rdf:rest [ rdf:first "banana"; rdf:rest rdf:nil ] - ]. -TR:rdf-syntax-grammar - n0:editor [ n0:fullname "Dave Beckett"; n0:homePage d: ]; - n1:title "RDF/XML Syntax Specification (Revised)". + [ rdf:first + "apple"; + rdf:rest + [ rdf:first "banana"; rdf:rest rdf:nil ] ]. ` server.get('/sampleContainer/example*') .expect('content-type', /text\/turtle/) diff --git a/test/resources/sampleContainer/example1.ttl b/test/resources/sampleContainer/example1.ttl index c2a488461..d7b41e66e 100644 --- a/test/resources/sampleContainer/example1.ttl +++ b/test/resources/sampleContainer/example1.ttl @@ -2,6 +2,8 @@ @prefix dc: . @prefix ex: . + a :glob. + dc:title "RDF/XML Syntax Specification (Revised)" ; ex:editor [ From 2e4d52acfce348d0a85955fa8b943d3a2606478b Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 31 May 2017 16:11:25 -0400 Subject: [PATCH 7/9] Use compact Collection syntax (per tim's request) --- test/http.js | 29 +++++++++------------ test/resources/sampleContainer/example2.ttl | 6 +---- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/test/http.js b/test/http.js index 7ff15a017..f0fb336e0 100644 --- a/test/http.js +++ b/test/http.js @@ -286,28 +286,23 @@ describe('HTTP APIs', function () { .expect(200, done) }) it('should have glob support', function (done) { - let expectedValue = `@prefix rdf: . -@prefix dc: . -@prefix ex: . -@prefix e: . + let expectedValue = `@prefix : <#>. +@prefix ex: . +@prefix n0: . @prefix TR: . @prefix d: . +@prefix n1: . - <> a e:glob . -TR:rdf-syntax-grammar - ex:editor - [ ex:fullname "Dave Beckett"; ex:homePage d: ]; - dc:title - "RDF/XML Syntax Specification (Revised)". -ex:a - ex:b +<> a ex:glob. + +n0:a + n0:b """The first line The second line - more""", - [ rdf:first - "apple"; - rdf:rest - [ rdf:first "banana"; rdf:rest rdf:nil ] ]. + more""", ( "apple" "banana" ). +TR:rdf-syntax-grammar + n0:editor [ n0:fullname "Dave Beckett"; n0:homePage d: ]; + n1:title "RDF/XML Syntax Specification (Revised)". ` server.get('/sampleContainer/example*') .expect('content-type', /text\/turtle/) diff --git a/test/resources/sampleContainer/example2.ttl b/test/resources/sampleContainer/example2.ttl index 8259de95d..0fa6c75db 100644 --- a/test/resources/sampleContainer/example2.ttl +++ b/test/resources/sampleContainer/example2.ttl @@ -1,7 +1,3 @@ @prefix : . @prefix rdf: . -:a :b - [ rdf:first "apple"; - rdf:rest [ rdf:first "banana"; - rdf:rest rdf:nil ] - ] . +:a :b ("apple" "banana") . From 898339463a2305bb56f0c9db705325d079acce46 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Thu, 1 Jun 2017 13:25:40 -0400 Subject: [PATCH 8/9] Update glob test / expected value --- test/http.js | 25 +++++++++++---------- test/resources/sampleContainer/example1.ttl | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/test/http.js b/test/http.js index f0fb336e0..23a225840 100644 --- a/test/http.js +++ b/test/http.js @@ -286,23 +286,24 @@ describe('HTTP APIs', function () { .expect(200, done) }) it('should have glob support', function (done) { - let expectedValue = `@prefix : <#>. -@prefix ex: . -@prefix n0: . + let expectedValue = `@prefix dc: . +@prefix ex: . +@prefix e: . @prefix TR: . @prefix d: . -@prefix n1: . -<> a ex:glob. - -n0:a - n0:b + e:this dc:title "Test title" . +TR:rdf-syntax-grammar + ex:editor + [ ex:fullname "Dave Beckett"; ex:homePage d: ]; + dc:title + "RDF/XML Syntax Specification (Revised)". +ex:a + ex:b """The first line The second line - more""", ( "apple" "banana" ). -TR:rdf-syntax-grammar - n0:editor [ n0:fullname "Dave Beckett"; n0:homePage d: ]; - n1:title "RDF/XML Syntax Specification (Revised)". + more""", + ( "apple" "banana" ). ` server.get('/sampleContainer/example*') .expect('content-type', /text\/turtle/) diff --git a/test/resources/sampleContainer/example1.ttl b/test/resources/sampleContainer/example1.ttl index d7b41e66e..84508d9b9 100644 --- a/test/resources/sampleContainer/example1.ttl +++ b/test/resources/sampleContainer/example1.ttl @@ -2,7 +2,7 @@ @prefix dc: . @prefix ex: . - a :glob. +<#this> dc:title "Test title" . dc:title "RDF/XML Syntax Specification (Revised)" ; From 9afac6c1afb00c04742691f382429257de7eb2d7 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Thu, 1 Jun 2017 15:15:41 -0400 Subject: [PATCH 9/9] Convert glob test to use rdflib matching --- test/http.js | 41 +++++++++++---------- test/resources/sampleContainer/example2.ttl | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/test/http.js b/test/http.js index 23a225840..3840d1ab7 100644 --- a/test/http.js +++ b/test/http.js @@ -4,6 +4,7 @@ var li = require('li') var ldnode = require('../index') var rm = require('./test-utils').rm var path = require('path') +const rdf = require('rdflib') var suffixAcl = '.acl' var suffixMeta = '.meta' @@ -286,30 +287,30 @@ describe('HTTP APIs', function () { .expect(200, done) }) it('should have glob support', function (done) { - let expectedValue = `@prefix dc: . -@prefix ex: . -@prefix e: . -@prefix TR: . -@prefix d: . - - e:this dc:title "Test title" . -TR:rdf-syntax-grammar - ex:editor - [ ex:fullname "Dave Beckett"; ex:homePage d: ]; - dc:title - "RDF/XML Syntax Specification (Revised)". -ex:a - ex:b - """The first line -The second line - more""", - ( "apple" "banana" ). -` server.get('/sampleContainer/example*') .expect('content-type', /text\/turtle/) .expect(200) .expect((res) => { - assert.equal(res.text, expectedValue) + let kb = rdf.graph() + rdf.parse(res.text, kb, 'https://localhost/', 'text/turtle') + + assert(kb.match( + rdf.namedNode('https://localhost/example1.ttl#this'), + rdf.namedNode('http://purl.org/dc/elements/1.1/title'), + rdf.literal('Test title') + ).length, 'Must contain a triple from example1.ttl') + + assert(kb.match( + rdf.namedNode('http://example.org/stuff/1.0/a'), + rdf.namedNode('http://example.org/stuff/1.0/b'), + rdf.literal('apple') + ).length, 'Must contain a triple from example2.ttl') + + assert(kb.match( + rdf.namedNode('http://example.org/stuff/1.0/a'), + rdf.namedNode('http://example.org/stuff/1.0/b'), + rdf.literal('The first line\nThe second line\n more') + ).length, 'Must contain a triple from example3.ttl') }) .end(done) }) diff --git a/test/resources/sampleContainer/example2.ttl b/test/resources/sampleContainer/example2.ttl index 0fa6c75db..622bd8483 100644 --- a/test/resources/sampleContainer/example2.ttl +++ b/test/resources/sampleContainer/example2.ttl @@ -1,3 +1,3 @@ @prefix : . @prefix rdf: . -:a :b ("apple" "banana") . +:a :b "apple" .