From 7fe574f34d8062843f70493b0b742afb0c743a36 Mon Sep 17 00:00:00 2001 From: akhabutdinova Date: Fri, 14 Jun 2019 15:07:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sparql-post-without-context.js | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/rdf4j-tests/sparql-post-without-context.js diff --git a/src/rdf4j-tests/sparql-post-without-context.js b/src/rdf4j-tests/sparql-post-without-context.js new file mode 100644 index 000000000..37f59a0d7 --- /dev/null +++ b/src/rdf4j-tests/sparql-post-without-context.js @@ -0,0 +1,94 @@ +describe('test Get', function() { + const data = ' 69'; + var params = + 'action=exec&' + + 'queryLn=SPARQL&' + + 'query=' + + encodeURIComponent( + 'PREFIX foaf: ' + 'SELECT ?Subject ' + 'WHERE{ ' + data + '}', + ) + + '&' + + 'limit_query=100&' + + 'infer=true&'; + + it('insert data to rdf repository without context', async () => { + var urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/query' + '?' + params; + //проверка до добавления + var dataSel = await fetch(urlprefix, { + method: 'GET', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/sparql-results+json', + }, + }).then((r) => r.json()); + expect(dataSel.results.bindings.length).toEqual(0); + + //добавление + urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/update'; + var result = await fetch(urlprefix, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/sparql-results+json', + }, + body: 'update=' + encodeURIComponent('INSERT DATA' + '{' + data + '}'), + }).then((r) => { + console.log(r); + expect(r).toBeInstanceOf(Response); + expect(r['status']).toEqual(200); + return r; + }); + }); + + it('check data after insert to rdf repository without context', async () => { + //проверка после + var urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/query' + '?' + params; + var dataSel = await fetch(urlprefix, { + method: 'GET', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/sparql-results+json', + }, + }).then((r) => r.json()); + expect(dataSel.results.bindings.length).toBeGreaterThan(0); + }); + + it('delete data to rdf repository without context', async () => { + var urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/query' + '?' + params; + //проверка до + var dataSel = await fetch(urlprefix, { + method: 'GET', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/sparql-results+json', + }, + }).then((r) => r.json()); + expect(dataSel.results.bindings.length).toBeGreaterThan(0); + + //удаление + urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/update'; + var result = await fetch(urlprefix, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/sparql-results+json', + }, + body: 'update=' + encodeURIComponent('DELETE DATA' + '{' + data + '}'), + }).then((r) => { + console.log(r); + expect(r).toBeInstanceOf(Response); + expect(r['status']).toEqual(200); + return r; + }); + + //проверка после + dataSel = await fetch(urlprefix, { + method: 'GET', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: 'application/sparql-results+json', + }, + }).then((r) => r.json()); + expect(dataSel.results.bindings.length).toEqual(0); + }); + }); \ No newline at end of file