Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge branch 'issues/dependencies' into releases/3.0.0-M1"
This reverts commit 88e833f.
- Loading branch information
1 parent
88e833f
commit 1eb79e6
Showing
14 changed files
with
318 additions
and
1,738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...ance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPSparqlUpdateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.repository.http; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.eclipse.rdf4j.model.vocabulary.FOAF; | ||
import org.eclipse.rdf4j.query.QueryLanguage; | ||
import org.eclipse.rdf4j.query.Update; | ||
import org.eclipse.rdf4j.query.parser.sparql.SPARQLUpdateTest; | ||
import org.eclipse.rdf4j.repository.Repository; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author jeen | ||
*/ | ||
public class HTTPSparqlUpdateTest extends SPARQLUpdateTest { | ||
|
||
private static HTTPMemServer server; | ||
|
||
@BeforeClass | ||
public static void startServer() throws Exception { | ||
server = new HTTPMemServer(); | ||
try { | ||
server.start(); | ||
} catch (Exception e) { | ||
server.stop(); | ||
throw e; | ||
} | ||
} | ||
|
||
@AfterClass | ||
public static void stopServer() throws Exception { | ||
server.stop(); | ||
} | ||
|
||
@Override | ||
protected Repository newRepository() throws Exception { | ||
return new HTTPRepository(HTTPMemServer.REPOSITORY_URL); | ||
} | ||
|
||
@Ignore | ||
@Test | ||
@Override | ||
public void testAutoCommitHandling() { | ||
// transaction isolation is not supported for HTTP connections. disabling | ||
// test. | ||
System.err.println("temporarily disabled testAutoCommitHandling() for HTTPRepository. See SES-1652"); | ||
} | ||
|
||
@Test | ||
public void testBindingsInUpdateTransaction() throws Exception { | ||
// See issue SES-1889 | ||
logger.debug("executing test testBindingsInUpdateTransaction"); | ||
|
||
StringBuilder update1 = new StringBuilder(); | ||
update1.append(getNamespaceDeclarations()); | ||
update1.append("DELETE { ?x foaf:name ?y } WHERE {?x foaf:name ?y }"); | ||
|
||
try { | ||
assertTrue(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); | ||
assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); | ||
|
||
con.begin(); | ||
Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update1.toString()); | ||
operation.setBinding("x", bob); | ||
|
||
operation.execute(); | ||
|
||
con.commit(); | ||
|
||
// only bob's name should have been deleted (due to the binding) | ||
assertFalse(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); | ||
assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); | ||
|
||
} catch (Exception e) { | ||
if (con.isActive()) { | ||
con.rollback(); | ||
} | ||
} | ||
} | ||
|
||
@Ignore | ||
@Test | ||
@Override | ||
public void testConsecutiveUpdatesInSameTransaction() { | ||
// transaction isolation is not supported for HTTP connections. disabling | ||
// test. | ||
System.err.println( | ||
"temporarily disabled testConsecutiveUpdatesInSameTransaction() for HTTPRepository. See SES-1652"); | ||
} | ||
} |
208 changes: 208 additions & 0 deletions
208
...sitory/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLServiceEvaluationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.repository.sparql; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.eclipse.rdf4j.model.IRI; | ||
import org.eclipse.rdf4j.model.Value; | ||
import org.eclipse.rdf4j.model.ValueFactory; | ||
import org.eclipse.rdf4j.model.vocabulary.FOAF; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.MalformedQueryException; | ||
import org.eclipse.rdf4j.query.QueryEvaluationException; | ||
import org.eclipse.rdf4j.query.QueryLanguage; | ||
import org.eclipse.rdf4j.query.TupleQuery; | ||
import org.eclipse.rdf4j.query.TupleQueryResult; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverImpl; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory; | ||
import org.eclipse.rdf4j.repository.Repository; | ||
import org.eclipse.rdf4j.repository.RepositoryConnection; | ||
import org.eclipse.rdf4j.repository.RepositoryException; | ||
import org.eclipse.rdf4j.repository.http.HTTPMemServer; | ||
import org.eclipse.rdf4j.repository.http.HTTPRepository; | ||
import org.eclipse.rdf4j.repository.sail.SailRepository; | ||
import org.eclipse.rdf4j.rio.RDFParseException; | ||
import org.eclipse.rdf4j.rio.Rio; | ||
import org.eclipse.rdf4j.sail.Sail; | ||
import org.eclipse.rdf4j.sail.memory.MemoryStore; | ||
import org.eclipse.rdf4j.sail.memory.config.MemoryStoreConfig; | ||
import org.eclipse.rdf4j.sail.memory.config.MemoryStoreFactory; | ||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Test suite for evaluation of SPARQL queries involving SERVICE clauses. The test suite starts up an embedded Jetty | ||
* server running Sesame, which functions as the SPARQL endpoint to test against. | ||
* | ||
* @author Jeen Broekstra | ||
*/ | ||
public class SPARQLServiceEvaluationTest { | ||
|
||
static final Logger logger = LoggerFactory.getLogger(SPARQLServiceEvaluationTest.class); | ||
|
||
private static HTTPMemServer server; | ||
|
||
private HTTPRepository remoteRepository; | ||
|
||
private SailRepository localRepository; | ||
|
||
private ValueFactory f; | ||
|
||
private IRI bob; | ||
|
||
private IRI alice; | ||
|
||
private IRI william; | ||
|
||
protected static final String EX_NS = "http://example.org/"; | ||
|
||
/** | ||
* @throws java.lang.Exception | ||
*/ | ||
@BeforeClass | ||
public static void startServer() throws Exception { | ||
server = new HTTPMemServer(); | ||
|
||
try { | ||
server.start(); | ||
} catch (Exception e) { | ||
server.stop(); | ||
throw e; | ||
} | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
remoteRepository = new HTTPRepository(HTTPMemServer.REPOSITORY_URL); | ||
remoteRepository.initialize(); | ||
loadDataSet(remoteRepository, "/testdata-query/graph1.ttl"); | ||
loadDataSet(remoteRepository, "/testdata-query/graph2.ttl"); | ||
|
||
localRepository = new SailRepository(new MemoryStore()); | ||
localRepository.initialize(); | ||
|
||
prepareLocalRepository(); | ||
} | ||
|
||
private void prepareLocalRepository() throws IOException { | ||
loadDataSet(localRepository, "/testdata-query/defaultgraph.ttl"); | ||
|
||
f = localRepository.getValueFactory(); | ||
|
||
bob = f.createIRI(EX_NS, "bob"); | ||
alice = f.createIRI(EX_NS, "alice"); | ||
william = f.createIRI(EX_NS, "william"); | ||
} | ||
|
||
protected void loadDataSet(Repository rep, String datasetFile) | ||
throws RDFParseException, RepositoryException, IOException { | ||
logger.debug("loading dataset..."); | ||
InputStream dataset = SPARQLServiceEvaluationTest.class.getResourceAsStream(datasetFile); | ||
|
||
RepositoryConnection con = rep.getConnection(); | ||
try { | ||
con.add(dataset, "", | ||
Rio.getParserFormatForFileName(datasetFile).orElseThrow(Rio.unsupportedFormat(datasetFile))); | ||
} finally { | ||
dataset.close(); | ||
con.close(); | ||
} | ||
logger.debug("dataset loaded."); | ||
} | ||
|
||
/** | ||
* @throws java.lang.Exception | ||
*/ | ||
@After | ||
public void tearDown() throws Exception { | ||
localRepository.shutDown(); | ||
} | ||
|
||
@AfterClass | ||
public static void stopServer() throws Exception { | ||
server.stop(); | ||
server = null; | ||
} | ||
|
||
@Test | ||
public void testSimpleServiceQuery() throws RepositoryException { | ||
StringBuilder qb = new StringBuilder(); | ||
qb.append(" SELECT * \n"); | ||
qb.append(" WHERE { \n"); | ||
qb.append(" SERVICE <" + HTTPMemServer.REPOSITORY_URL + "> { \n"); | ||
qb.append(" ?X <" + FOAF.NAME + "> ?Y \n "); | ||
qb.append(" } \n "); | ||
qb.append(" ?X a <" + FOAF.PERSON + "> . \n"); | ||
qb.append(" } \n"); | ||
|
||
try (RepositoryConnection conn = localRepository.getConnection()) { | ||
TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, qb.toString()); | ||
|
||
TupleQueryResult tqr = tq.evaluate(); | ||
|
||
assertNotNull(tqr); | ||
assertTrue(tqr.hasNext()); | ||
|
||
int count = 0; | ||
while (tqr.hasNext()) { | ||
BindingSet bs = tqr.next(); | ||
count++; | ||
|
||
Value x = bs.getValue("X"); | ||
Value y = bs.getValue("Y"); | ||
|
||
assertFalse(william.equals(x)); | ||
|
||
assertTrue(bob.equals(x) || alice.equals(x)); | ||
if (bob.equals(x)) { | ||
f.createLiteral("Bob").equals(y); | ||
} else if (alice.equals(x)) { | ||
f.createLiteral("Alice").equals(y); | ||
} | ||
} | ||
|
||
assertEquals(2, count); | ||
|
||
} catch (MalformedQueryException e) { | ||
fail(e.getMessage()); | ||
} catch (QueryEvaluationException e) { | ||
fail(e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* The provided FederatedServiceResolver should finds it way to the {@link EvaluationStrategy} | ||
*/ | ||
@Test | ||
public void testRepositoryConfigurationSetup() throws Exception { | ||
tearDown(); | ||
MemoryStoreFactory factory = new MemoryStoreFactory(); | ||
MemoryStoreConfig config = new MemoryStoreConfig(); | ||
config.setEvaluationStrategyFactoryClassName(StrictEvaluationStrategyFactory.class.getName()); | ||
Sail sail = factory.getSail(config); | ||
localRepository = new SailRepository(sail); | ||
localRepository.setFederatedServiceResolver(new FederatedServiceResolverImpl()); | ||
localRepository.initialize(); | ||
prepareLocalRepository(); | ||
testSimpleServiceQuery(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
|
||
<modules> | ||
<module>rio</module> | ||
<module>repository</module> | ||
</modules> | ||
</project> | ||
|
Oops, something went wrong.