Skip to content

Commit

Permalink
do not use relative IRIs in assembler file; upgrade to TDB2; rename /…
Browse files Browse the repository at this point in the history
…ds to /skosmos-test; fixes #932
  • Loading branch information
kouralex committed Feb 11, 2020
1 parent f2a09c7 commit 1c8320e
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 118 deletions.
30 changes: 15 additions & 15 deletions tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ protected function setUp() {
$this->vocab = $this->model->getVocabulary('test');
$this->graph = $this->vocab->getGraph();
$this->params = $this->getMockBuilder('ConceptSearchParameters')->disableOriginalConstructor()->getMock();
$this->sparql = new GenericSparql('http://localhost:13030/ds/sparql', $this->graph, $this->model);
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
}

/**
* @covers GenericSparql::__construct
*/
public function testConstructor() {
$gs = new GenericSparql('http://localhost:13030/ds/sparql', $this->graph, $this->model);
$gs = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$this->assertInstanceOf('GenericSparql', $gs);
}

/**
* @covers GenericSparql::getGraph
*/
public function testGetGraph() {
$gs = new GenericSparql('http://localhost:13030/ds/sparql', $this->graph, $this->model);
$gs = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$this->assertEquals($this->graph, $gs->getGraph());
}

Expand Down Expand Up @@ -236,7 +236,7 @@ public function testQueryConceptsAlphabeticalFull() {
*/
public function testQueryConceptInfoWithMultipleVocabs()
{
$this->sparql = new GenericSparql('http://localhost:13030/ds/sparql', '?graph', $this->model);
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$voc2 = $this->model->getVocabulary('test');
$voc3 = $this->model->getVocabulary('dates');
$voc4 = $this->model->getVocabulary('groups');
Expand All @@ -258,7 +258,7 @@ public function testQueryConceptInfoWithMultipleVocabs()
*/
public function testQueryConceptInfoWithAllVocabs()
{
$this->sparql = new GenericSparql('http://localhost:13030/ds/sparql', '?graph', $this->model);
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$actual = $this->sparql->queryConceptInfo(array('http://www.skosmos.skos/test/ta121', 'http://www.skosmos.skos/groups/ta111'), null, null, 'en');
$this->assertInstanceOf('Concept', $actual[0]);
$this->assertEquals('http://www.skosmos.skos/test/ta121', $actual[0]->getUri());
Expand Down Expand Up @@ -335,7 +335,7 @@ public function testQueryConceptScheme()
{
$actual = $this->sparql->queryConceptScheme('http://www.skosmos.skos/test/conceptscheme');
$this->assertInstanceOf('EasyRdf\Graph', $actual);
$this->assertEquals('http://localhost:13030/ds/sparql', $actual->getUri());
$this->assertEquals('http://localhost:13030/skosmos-test/sparql', $actual->getUri());
}

/**
Expand All @@ -359,7 +359,7 @@ public function testQueryConceptSchemes()
*/
public function testQueryConceptSchemesSubject()
{
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', 'http://www.skosmos.skos/test-concept-schemes/', $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', 'http://www.skosmos.skos/test-concept-schemes/', $this->model);

$actual = $sparql->queryConceptSchemes('en');
$expected = array(
Expand Down Expand Up @@ -411,7 +411,7 @@ public function testQueryConceptsMultipleVocabs()
$voc2 = $this->model->getVocabulary('groups');
$this->params->method('getSearchTerm')->will($this->returnValue('Carp'));
$this->params->method('getVocabs')->will($this->returnValue(array($voc, $voc2)));
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', '?graph', $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$actual = $sparql->queryConcepts(array($voc, $voc2), null, null, $this->params);
$this->assertEquals(2, sizeof($actual));
$this->assertEquals('http://www.skosmos.skos/groups/ta112', $actual[0]['uri']);
Expand All @@ -434,7 +434,7 @@ public function testQueryConceptsMultipleSchemes()
// returns 3 concepts without the scheme limit, and only 2 with the scheme limit below
$this->params->method('getSearchTerm')->will($this->returnValue('concept*'));
$this->params->method('getSchemeLimit')->will($this->returnValue(array('http://www.skosmos.skos/multiple-schemes/cs1', 'http://www.skosmos.skos/multiple-schemes/cs2')));
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', 'http://www.skosmos.skos/multiple-schemes/', $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', 'http://www.skosmos.skos/multiple-schemes/', $this->model);
$actual = $sparql->queryConcepts(array($voc), null, null, $this->params);
$this->assertEquals(2, sizeof($actual));
$this->assertEquals('http://www.skosmos.skos/multiple-schemes/c1-in-cs1', $actual[0]['uri']);
Expand Down Expand Up @@ -894,7 +894,7 @@ public function testListConceptGroups()
{
$voc = $this->model->getVocabulary('groups');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', $graph, $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$actual = $sparql->ListConceptGroups('http://www.w3.org/2004/02/skos/core#Collection', 'en', false);
$expected = array (0 => array ('prefLabel' => 'Fish', 'uri' => 'http://www.skosmos.skos/groups/fish', 'hasMembers' => true, 'childGroups' => array('http://www.skosmos.skos/groups/sub')), 1 => array ('prefLabel' => 'Freshwater fish', 'uri' => 'http://www.skosmos.skos/groups/fresh', 'hasMembers' => true), 2 => array ('prefLabel' => 'Saltwater fish', 'uri' => 'http://www.skosmos.skos/groups/salt', 'hasMembers' => true),3 => array ('prefLabel' => 'Submarine-like fish', 'uri' => 'http://www.skosmos.skos/groups/sub', 'hasMembers' => true));
$this->assertEquals($expected, $actual);
Expand All @@ -909,7 +909,7 @@ public function testListConceptGroupContentsExcludingDeprecatedConcept()
{
$voc = $this->model->getVocabulary('groups');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', $graph, $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en');
$this->assertEquals('http://www.skosmos.skos/groups/ta113', $actual[0]['uri']);
$this->assertEquals(1, sizeof($actual));
Expand All @@ -924,7 +924,7 @@ public function testListConceptGroupContentsIncludingDeprecatedConcept()
{
$voc = $this->model->getVocabulary('showDeprecated');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', $graph, $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en', $voc->getConfig()->getShowDeprecated());
$expected = array (
0 => array (
Expand Down Expand Up @@ -955,7 +955,7 @@ public function testQueryChangeList()
{
$voc = $this->model->getVocabulary('changes');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', $graph, $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$actual = $sparql->queryChangeList('en', 0, 'dc11:created');
$order = array();
foreach($actual as $concept) {
Expand All @@ -973,7 +973,7 @@ public function testLimitSearchToType()
{
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/ds/sparql', $graph, $this->model);
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$this->params->method('getSearchTerm')->will($this->returnValue('*'));
$this->params->method('getTypeLimit')->will($this->returnValue(array('mads:Topic')));
$actual = $this->sparql->queryConcepts(array($voc), null, true, $this->params);
Expand Down Expand Up @@ -1013,7 +1013,7 @@ public function testQueryConceptsWithExtraFields()
*/
public function testQuerySuperProperties()
{
$this->sparql = new GenericSparql('http://localhost:13030/ds/sparql', '?graph', $this->model);
$this->sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', '?graph', $this->model);
$actual = $this->sparql->querySuperProperties('http://example.com/myns#property');
$this->assertEquals(1, sizeof($actual));
$expected = array('http://example.com/myns#superProperty');
Expand Down
2 changes: 1 addition & 1 deletion tests/GlobalConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp()

public function testGetDefaultEndpoint()
{
$this->assertEquals("http://localhost:13030/ds/sparql", $this->config->getDefaultEndpoint());
$this->assertEquals("http://localhost:13030/skosmos-test/sparql", $this->config->getDefaultEndpoint());
}

public function testGetDefaultSparqlDialect()
Expand Down
6 changes: 3 additions & 3 deletions tests/JenaTextSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ protected function setUp() {
$this->vocab = $this->model->getVocabulary('test');
$this->graph = $this->vocab->getGraph();
$this->params = $this->getMockBuilder('ConceptSearchParameters')->disableOriginalConstructor()->getMock();
$this->sparql = new JenaTextSparql('http://localhost:13030/ds/sparql', $this->graph, $this->model);
$this->sparql = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
}

/**
* @covers JenaTextSparql::__construct
*/
public function testConstructor() {
$gs = new JenaTextSparql('http://localhost:13030/ds/sparql', $this->graph, $this->model);
$gs = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $this->graph, $this->model);
$this->assertInstanceOf('JenaTextSparql', $gs);
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public function testQueryConceptsDefaultGraph()
public function testQueryConceptsAlphabeticalOrderBy() {
$vocab = $this->model->getVocabulary('collation');
$graph = $vocab->getGraph();
$sparql = new JenaTextSparql('http://localhost:13030/ds/sparql', $graph, $this->model);
$sparql = new JenaTextSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$actual = $sparql->queryConceptsAlphabetical('t', 'fi');
$expected = array (
0 => array (
Expand Down
2 changes: 1 addition & 1 deletion tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function testGetVocabularyByGraphUri() {
/**
* @covers Model::getVocabularyByGraph
* @expectedException \Exception
* @expectedExceptionMessage no vocabulary found for graph http://no/address and endpoint http://localhost:13030/ds/sparql
* @expectedExceptionMessage no vocabulary found for graph http://no/address and endpoint http://localhost:13030/skosmos-test/sparql
*/
public function testGetVocabularyByInvalidGraphUri() {
$vocab = $this->model->getVocabularyByGraph('http://no/address');
Expand Down
2 changes: 1 addition & 1 deletion tests/VocabularyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testGetTitle() {
public function testGetEndpoint() {
$vocab = $this->model->getVocabulary('testdiff');
$endpoint = $vocab->getEndpoint();
$this->assertEquals('http://localhost:13030/ds/sparql', $endpoint);
$this->assertEquals('http://localhost:13030/skosmos-test/sparql', $endpoint);
}

/**
Expand Down
108 changes: 55 additions & 53 deletions tests/fuseki-assembler.ttl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,79 +1,81 @@
## Example of a TDB dataset and text index published using Fuseki
@prefix : <http://base/#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2: <http://jena.apache.org/2016/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix text: <http://jena.apache.org/text#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

@prefix : <#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix text: <http://jena.apache.org/text#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
ja:DatasetTxnMem rdfs:subClassOf ja:RDFDataset .
ja:MemoryDataset rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetOne rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetSink rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetZero rdfs:subClassOf ja:RDFDataset .

tdb2:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb2:DatasetTDB2 rdfs:subClassOf ja:RDFDataset .

[] rdf:type fuseki:Server ;
fuseki:services (
<#service_text_tdb>
) .
tdb2:GraphTDB rdfs:subClassOf ja:Model .
tdb2:GraphTDB2 rdfs:subClassOf ja:Model .

# TDB
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
<http://jena.hpl.hp.com/2008/tdb#DatasetTDB>
rdfs:subClassOf ja:RDFDataset .

# Text
[] ja:loadClass "org.apache.jena.query.text.TextQuery" .
text:TextDataset rdfs:subClassOf ja:RDFDataset .
#text:TextIndexSolr rdfs:subClassOf text:TextIndex .
text:TextIndexLucene rdfs:subClassOf text:TextIndex .
<http://jena.hpl.hp.com/2008/tdb#GraphTDB>
rdfs:subClassOf ja:Model .

## ---------------------------------------------------------------
text:TextDataset
rdfs:subClassOf ja:RDFDataset .

<#service_text_tdb> rdf:type fuseki:Service ;
rdfs:label "TDB/text service" ;
fuseki:name "ds" ;
fuseki:serviceQuery "query" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:dataset <#text_dataset> ;
.
:service_tdb_all a fuseki:Service ;
rdfs:label "TDB2+text skosmos" ;
fuseki:dataset :text_dataset ;
fuseki:name "skosmos-test" ;
fuseki:serviceQuery "query" , "" , "sparql" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadQuads "" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadWriteQuads "" ;
fuseki:serviceUpdate "" , "update" ;
fuseki:serviceUpload "upload" .

<#text_dataset> rdf:type text:TextDataset ;
text:dataset <#dataset> ;
text:index <#indexLucene> ;
.
:text_dataset a text:TextDataset ;
text:dataset :tdb_dataset_readwrite ;
text:index :index_lucene .

<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "--mem--" ;
tdb:unionDefaultGraph true ;
.
:tdb_dataset_readwrite
a tdb2:DatasetTDB2 ;
tdb2:unionDefaultGraph true ;
tdb2:location "--mem--" .

<#indexLucene> a text:TextIndexLucene ;
:index_lucene a text:TextIndexLucene ;
##text:directory <file:/tmp/lucene> ;
text:directory "mem" ;
text:entityMap <#entMap> ;
text:storeValues true ;
.
text:entityMap :entity_map ;
text:storeValues true .

<#entMap> a text:EntityMap ;
# Text index configuration
:entity_map a text:EntityMap ;
text:entityField "uri" ;
text:graphField "graph" ; ## enable graph-specific indexing
text:defaultField "pref" ; ## Must be defined in the text:map
text:graphField "graph" ;
text:defaultField "pref" ;
text:uidField "uid" ;
text:langField "lang" ;
text:map (
# skos:prefLabel
[ text:field "pref" ;
text:predicate skos:prefLabel ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ] ]
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
]
# skos:altLabel
[ text:field "alt" ;
text:predicate skos:altLabel ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ] ]
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
]
# skos:hiddenLabel
[ text:field "hidden" ;
text:predicate skos:hiddenLabel ;
text:analyzer [ a text:LowerCaseKeywordAnalyzer ] ]
) .
text:analyzer [ a text:LowerCaseKeywordAnalyzer ]
]
) .
2 changes: 1 addition & 1 deletion tests/init_fuseki.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ done

for fn in ../test-vocab-data/*.ttl; do
name=$(basename "${fn}" .ttl)
$(./bin/s-put http://localhost:13030/ds/data "http://www.skosmos.skos/$name/" "$fn")
$(./bin/s-put http://localhost:13030/skosmos-test/data "http://www.skosmos.skos/$name/" "$fn")
done

cd ..
Expand Down
Loading

0 comments on commit 1c8320e

Please sign in to comment.