Skip to content

Commit

Permalink
Merge branch 'develop' into feature/eclipse-rdf4j#743-add-support-for…
Browse files Browse the repository at this point in the history
…-SHACL

Signed-off-by: Heshan Jayasinghe <shanujse@gmail.com>
  • Loading branch information
heshanjse committed Jun 20, 2017
2 parents 05d880f + 893c4f2 commit b88a752
Show file tree
Hide file tree
Showing 586 changed files with 5,112 additions and 696 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -5,6 +5,7 @@ script: mvn verify
branches:
only:
- master
- develop
- /^releases.*$/
env:
- MAVEN_OPTS=-Xmx1024M
Expand Up @@ -81,10 +81,10 @@ public void testSingleVarResults()
assertRegex(
"\\?a\n" + "<foo:bar>\n"
+ "(2.0(E0)?|\"2.0\"\\^\\^<http://www.w3.org/2001/XMLSchema#double>)\n" + "_:bnode3\n"
+ "\"''single-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"?''single-quoted string(\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"\\\\\"\\\\\"double-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"space at the end \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"space at the end \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"?space at the end (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"?space at the end (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"\\\\\"\\\\\"double-quoted string with no datatype\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"newline at the end \\\\n\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n?",
toString(createTupleSingleVarMultipleBindingSets()));
Expand All @@ -96,11 +96,11 @@ public void testmultipleVarResults()
{
assertRegex(
"\\?a\t\\?b\t\\?c\n"
+ "<foo:bar>\t_:bnode\t\"baz\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "<foo:bar>\t_:bnode\t(baz|\"baz\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)\n"
+ "(1|\"1\"\\^\\^<http://www.w3.org/2001/XMLSchema#integer>)\t\t\"Hello World!\"@en\n"
+ "<http://example.org/test/ns/bindingA>\t\"http://example.com/other/ns/bindingB\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t<http://example.com/other/ns/binding,C>\n"
+ "\"string with newline at the end \\\\n\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"string with space at the end \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\" \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"''single-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"\\\\\"\\\\\"double-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"\\\\t\\\\tunencoded tab characters followed by encoded \\\\t\\\\t\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n?",
+ "<http://example.org/test/ns/bindingA>\t\"?http://example.com/other/ns/bindingB(\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\t<http://example.com/other/ns/binding,C>\n"
+ "\"string with newline at the end \\\\n\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"?string with space at the end (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\t\"? (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"?''single-quoted string(\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\t\"\\\\\"\\\\\"double-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"\\\\t\\\\tunencoded tab characters followed by encoded \\\\t\\\\t\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n?",
toString(createTupleMultipleBindingSets()));
}

Expand Down
Expand Up @@ -70,10 +70,10 @@ public void testSingleVarResults()
assertRegex(
"\\?a\n" + "<foo:bar>\n"
+ "(2.0(E0)?|\"2.0\"\\^\\^<http://www.w3.org/2001/XMLSchema#double>)\n" + "_:bnode3\n"
+ "\"''single-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"?''single-quoted string(\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"\\\\\"\\\\\"double-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"space at the end \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"space at the end \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"?space at the end (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"?space at the end (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"\\\\\"\\\\\"double-quoted string with no datatype\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"newline at the end \\\\n\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n?",
toString(createTupleSingleVarMultipleBindingSets()));
Expand All @@ -85,11 +85,11 @@ public void testmultipleVarResults()
{
assertRegex(
"\\?a\t\\?b\t\\?c\n"
+ "<foo:bar>\t_:bnode\t\"baz\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "<foo:bar>\t_:bnode\t(baz|\"baz\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)\n"
+ "(1|\"1\"\\^\\^<http://www.w3.org/2001/XMLSchema#integer>)\t\t\"Hello World!\"@en\n"
+ "<http://example.org/test/ns/bindingA>\t\"http://example.com/other/ns/bindingB\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t<http://example.com/other/ns/binding,C>\n"
+ "\"string with newline at the end \\\\n\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"string with space at the end \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\" \"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n"
+ "\"''single-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"\\\\\"\\\\\"double-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"\\\\t\\\\tunencoded tab characters followed by encoded \\\\t\\\\t\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n?",
+ "<http://example.org/test/ns/bindingA>\t\"?http://example.com/other/ns/bindingB(\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\t<http://example.com/other/ns/binding,C>\n"
+ "\"string with newline at the end \\\\n\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"?string with space at the end (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\t\"? (\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\n"
+ "\"?''single-quoted string(\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?)?\t\"\\\\\"\\\\\"double-quoted string\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\t\"\\\\t\\\\tunencoded tab characters followed by encoded \\\\t\\\\t\"(\\^\\^<http://www.w3.org/2001/XMLSchema#string>)?\n?",
toString(createTupleMultipleBindingSets()));
}

Expand Down
Expand Up @@ -24,7 +24,7 @@ public class RDFJSONParserCustomTest {
public void testSupportedSettings()
throws Exception
{
assertEquals(17, Rio.createParser(RDFFormat.RDFJSON).getSupportedSettings().size());
assertEquals(18, Rio.createParser(RDFFormat.RDFJSON).getSupportedSettings().size());
}

}
Expand Up @@ -223,6 +223,6 @@ public void testParseCommentAtStart()
public void testSupportedSettings()
throws Exception
{
assertEquals(21, Rio.createParser(RDFFormat.RDFXML).getSupportedSettings().size());
assertEquals(22, Rio.createParser(RDFFormat.RDFXML).getSupportedSettings().size());
}
}
Expand Up @@ -226,7 +226,7 @@ public void testBadPname02()
public void testSupportedSettings()
throws Exception
{
assertEquals(12, Rio.createParser(RDFFormat.TRIG).getSupportedSettings().size());
assertEquals(13, Rio.createParser(RDFFormat.TRIG).getSupportedSettings().size());
}

}
Expand Up @@ -7,19 +7,25 @@
*******************************************************************************/
package org.eclipse.rdf4j.rio.turtle;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.StringReader;
import java.io.StringWriter;
import java.util.Collections;
import java.util.function.Consumer;

import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.Namespace;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
import org.eclipse.rdf4j.model.impl.NamespaceImpl;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.impl.ValueFactoryImpl;
import org.eclipse.rdf4j.model.util.Models;
import org.eclipse.rdf4j.model.vocabulary.RDF;
Expand Down Expand Up @@ -206,7 +212,7 @@ public void testLiteralWithNewlines()
public void testSupportedSettings()
throws Exception
{
assertEquals(12, parser.getSupportedSettings().size());
assertEquals(13, parser.getSupportedSettings().size());
}

@Test
Expand Down Expand Up @@ -507,4 +513,24 @@ public void testParsingNamespacesWithOverride()
assertTrue(model.contains(vf.createIRI("urn:a"), vf.createIRI("urn:not_skos:broader"),
vf.createIRI("urn:b")));
}

@Test
public void test780IRISpace()
throws Exception
{
String ttl = "_:b25978837 a <http://purl.bioontology.org/ontology/UATC/\\u0020SERINE\\u0020\\u0020> .";
try {
Rio.parse(new StringReader(ttl), "", RDFFormat.TURTLE);
fail();
}
catch (RDFParseException e) {
// Invalid IRI
}
Model model = Rio.parse(new StringReader(ttl), "", RDFFormat.TURTLE,
new ParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false),
SimpleValueFactory.getInstance(), new ParseErrorLogger());
assertEquals(1, model.size());
model.filter(null, RDF.TYPE, null).objects().forEach(obj -> assertEquals(
"http://purl.bioontology.org/ontology/UATC/%20SERINE%20%20", obj.stringValue()));
}
}
Expand Up @@ -7,13 +7,10 @@
*******************************************************************************/
package org.eclipse.rdf4j.rio.turtle;

import junit.framework.Test;

import org.eclipse.rdf4j.rio.RDFParser;
import org.eclipse.rdf4j.rio.helpers.TurtleParserSettings;
import org.eclipse.rdf4j.rio.ntriples.NTriplesParser;
import org.eclipse.rdf4j.rio.turtle.TurtleParser;
import org.eclipse.rdf4j.rio.turtle.TurtleParserTestCase;

import junit.framework.Test;

/**
* JUnit test for the Turtle parser that uses the tests that are available
Expand Down
Expand Up @@ -7,9 +7,9 @@
*******************************************************************************/
package org.eclipse.rdf4j.query.parser.sparql;

import junit.framework.TestCase;

import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.RDFS;
import org.eclipse.rdf4j.query.QueryLanguage;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
Expand All @@ -20,6 +20,8 @@
import org.junit.Before;
import org.junit.Test;

import junit.framework.TestCase;

/**
* @author james
*/
Expand Down Expand Up @@ -91,6 +93,35 @@ public void test100000()
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}

@Test
public void testDirection()
throws Exception
{
ValueFactory vf = con.getValueFactory();
con.add(vf.createIRI("urn:test:a"), vf.createIRI("urn:test:rel"), vf.createIRI("urn:test:b"));
con.add(vf.createIRI("urn:test:b"), vf.createIRI("urn:test:rel"), vf.createIRI("urn:test:a"));
String sparql = "ASK { <urn:test:a> <urn:test:rel>* <urn:test:b> . <urn:test:b> <urn:test:rel>* <urn:test:a> }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}

@Test
public void testSimilarPatterns()
throws Exception
{
ValueFactory vf = con.getValueFactory();
con.add(vf.createIRI("urn:test:a"), RDF.TYPE, vf.createIRI("urn:test:c"));
con.add(vf.createIRI("urn:test:b"), RDF.TYPE, vf.createIRI("urn:test:d"));
con.add(vf.createIRI("urn:test:c"), RDFS.SUBCLASSOF, vf.createIRI("urn:test:e"));
con.add(vf.createIRI("urn:test:d"), RDFS.SUBCLASSOF, vf.createIRI("urn:test:f"));
String sparql = "ASK { \n"
+ " values (?expectedTargetClass55555 ?expectedTargetClass5544T) {(<urn:test:e> <urn:test:f>)}.\n"
+ " <urn:test:a> a ?linkTargetClass55555 .\n"
+ " ?linkTargetClass55555 rdfs:subClassOf* ?expectedTargetClass55555 .\n"
+ " <urn:test:b> a ?linkTargetClass55556 .\n"
+ " ?linkTargetClass55556 rdfs:subClassOf* ?expectedTargetClass5544T . }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}

private void populate(int n)
throws RepositoryException
{
Expand Down
Expand Up @@ -26,16 +26,21 @@
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.RDFFormat;
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;
Expand Down Expand Up @@ -100,6 +105,12 @@ public void setUp()
localRepository = new SailRepository(new MemoryStore());
localRepository.initialize();

prepareLocalRepository();
}

private void prepareLocalRepository()
throws IOException
{
loadDataSet(localRepository, "/testdata-query/defaultgraph.ttl");

f = localRepository.getValueFactory();
Expand Down Expand Up @@ -199,4 +210,23 @@ else if (alice.equals(x)) {
conn.close();
}
}

/**
* 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();
}
}
9 changes: 8 additions & 1 deletion core/config/pom.xml
Expand Up @@ -32,5 +32,12 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
11 changes: 10 additions & 1 deletion core/config/src/main/java/org/eclipse/rdf4j/RDF4J.java
Expand Up @@ -14,9 +14,18 @@
*/
public class RDF4J {

private static final String VERSION = MavenUtil.loadVersion("org.eclipse.rdf4j", "rdf4j-config", "dev");
private static final String VERSION = loadVersion();

public final static String getVersion() {
return VERSION;
}

private static String loadVersion() {
String impl = RDF4J.class.getPackage().getImplementationVersion();
if (impl == null) {
return MavenUtil.loadVersion("org.eclipse.rdf4j", "rdf4j-config", "dev");
} else {
return impl;
}
}
}

0 comments on commit b88a752

Please sign in to comment.