marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject [3/3] git commit: Moved SesameMatchers to a separate module, might be useful in general (Attention: Not really tested!)
Date Fri, 28 Feb 2014 17:51:29 GMT
Moved SesameMatchers to a separate module, might be useful in general (Attention: Not really tested!)


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/9f8f8f4c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/9f8f8f4c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/9f8f8f4c

Branch: refs/heads/ldp
Commit: 9f8f8f4c23ceebeb6eb9a8a5bd4008f4ec8e7934
Parents: 77eae22
Author: Jakob Frank <jakob@apache.org>
Authored: Fri Feb 28 18:39:35 2014 +0100
Committer: Jakob Frank <jakob@apache.org>
Committed: Fri Feb 28 18:51:01 2014 +0100

----------------------------------------------------------------------
 .../marmotta-sesame-matchers/pom.xml            |  73 ++++++++
 .../commons/sesame/test/SesameMatchers.java     | 184 +++++++++++++++++++
 .../AbstractRepositoryConnectionMatcher.java    |  43 +++++
 .../sesame/test/base/RdfStringMatcher.java      |  88 +++++++++
 .../sesame/test/base/RepositoryMatcher.java     |  74 ++++++++
 .../commons/sesame/test/base/SesameMatcher.java |  28 +++
 .../test/connection/HasStatementMatcher.java    |  64 +++++++
 .../sesame/test/sparql/SparqlAskMatcher.java    |  58 ++++++
 .../test/sparql/SparqlGraphQueryMatcher.java    |  78 ++++++++
 .../sesame/test/sparql/SparqlMatcher.java       |  55 ++++++
 .../test/sparql/SparqlTupleQueryMatcher.java    |  65 +++++++
 commons/marmotta-sesame-tools/pom.xml           |   1 +
 parent/pom.xml                                  |   5 +
 platform/marmotta-ldp/pom.xml                   |   5 +
 .../ldp/webservices/LdpWebServiceTest.java      |  21 +--
 .../ldp/webservices/util/BaseRdfMatcher.java    | 123 -------------
 .../webservices/util/HasStatementMatcher.java   |  67 -------
 .../ldp/webservices/util/HeaderMatchers.java    |  26 ++-
 .../ldp/webservices/util/SparqlAskMatcher.java  |  53 ------
 .../util/SparqlGraphQueryMatcher.java           |  74 --------
 .../ldp/webservices/util/SparqlMatcher.java     |  39 ----
 .../util/SparqlTupleQueryMatcher.java           |  63 -------
 22 files changed, 848 insertions(+), 439 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/pom.xml
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/pom.xml b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/pom.xml
new file mode 100644
index 0000000..709ee01
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.marmotta</groupId>
+        <artifactId>marmotta-parent</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+        <relativePath>../../../parent/</relativePath>
+    </parent>
+
+    <artifactId>marmotta-sesame-matchers</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Marmotta Sesame Test Tools: Hamcrest Matchers</name>
+
+    <description>Set of useful Matchers for Sesame</description>
+
+    <build>
+        <plugins>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <!-- data model -->
+        <dependency>
+            <groupId>org.openrdf.sesame</groupId>
+            <artifactId>sesame-model</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.openrdf.sesame</groupId>
+            <artifactId>sesame-repository-sail</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.openrdf.sesame</groupId>
+            <artifactId>sesame-sail-memory</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java
new file mode 100644
index 0000000..4c2e503
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/SesameMatchers.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test;
+
+import org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher;
+import org.apache.marmotta.commons.sesame.test.base.RepositoryMatcher;
+import org.apache.marmotta.commons.sesame.test.connection.HasStatementMatcher;
+import org.apache.marmotta.commons.sesame.test.sparql.SparqlAskMatcher;
+import org.apache.marmotta.commons.sesame.test.sparql.SparqlGraphQueryMatcher;
+import org.apache.marmotta.commons.sesame.test.sparql.SparqlTupleQueryMatcher;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matcher;
+import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.query.BindingSet;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.Rio;
+import org.openrdf.rio.UnsupportedRDFormatException;
+
+/**
+ * Collection of useful Matchers for Sesame.
+ *
+ * @author Jakob Frank
+ */
+public class SesameMatchers {
+
+    public static <T extends RepositoryConnection> Matcher<T> hasStatement(Resource subject, URI predicate, Value object, Resource... contexts) {
+        return HasStatementMatcher.hasStatement(subject, predicate, object, contexts);
+    }
+
+    public static <T extends Repository> Matcher<T> repositoryHasStatement(Resource subject, URI predicate, Value object, Resource... contexts) {
+        return RepositoryMatcher.wrap(hasStatement(subject, predicate, object,contexts));
+    }
+
+    public static <T extends String> Matcher<T> rdfHasStatement(RDFFormat format, String baseUri, Resource subject, URI predicate, Value object, Resource... contexts) {
+        return RdfStringMatcher.wrap(format, baseUri, hasStatement(subject, predicate, object, contexts));
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlAsk(String askQuery) {
+        return SparqlAskMatcher.sparqlAsk(askQuery);
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlAsk(String baseUri, String askQuery) {
+        return SparqlAskMatcher.sparqlAsk(baseUri, askQuery);
+    }
+
+    public static <T extends Repository> Matcher<T> sparqlAskRepository(String askQuery) {
+        return RepositoryMatcher.wrap(sparqlAsk(askQuery));
+    }
+
+    public static <T extends Repository> Matcher<T> sparqlAskRepository(String baseUri, String askQuery) {
+        return RepositoryMatcher.wrap(sparqlAsk(baseUri, askQuery));
+    }
+
+    public static <T extends String> Matcher<T> sparqlAskRdf(RDFFormat format, String baseUri, String askQuery) {
+        return RdfStringMatcher.wrap(format, baseUri, sparqlAsk(askQuery));
+    }
+
+    public static <T extends String> Matcher<T> sparqlAskRdf(RDFFormat format, String baseUri, String queryBaseUri, String askQuery) {
+        return RdfStringMatcher.wrap(format, baseUri, sparqlAsk(queryBaseUri, askQuery));
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlTupleQuery(String baseUri, String sparqlQuery, Matcher<Iterable<BindingSet>> matcher) {
+        return SparqlTupleQueryMatcher.sparqlQuery(baseUri, sparqlQuery, matcher);
+    }
+
+    @SafeVarargs
+    public static <T extends RepositoryConnection> Matcher<T> sparqlTupleQuery(String baseUri, String sparqlQuery, Matcher<Iterable<BindingSet>>... matchers) {
+        return SparqlTupleQueryMatcher.sparqlQuery(baseUri, sparqlQuery, matchers);
+    }
+
+    public static <T extends Repository> Matcher<T> sparqlTupleQueryRepository(String baseUri, String sparqlQuery, Matcher<Iterable<BindingSet>> matcher) {
+        return RepositoryMatcher.wrap(SparqlTupleQueryMatcher.sparqlQuery(baseUri, sparqlQuery, matcher));
+    }
+
+    @SafeVarargs
+    public static <T extends Repository> Matcher<T> sparqlTupleQueryRepository(String baseUri, String sparqlQuery, Matcher<Iterable<BindingSet>>... matchers) {
+        return RepositoryMatcher.wrap(SparqlTupleQueryMatcher.sparqlQuery(baseUri, sparqlQuery, matchers));
+    }
+
+    public static <T extends String> Matcher<T> sparqlTupleQueryRdf(RDFFormat format, String baseUri, String queryBaseUri, String sparqlQuery, Matcher<Iterable<BindingSet>> matcher) {
+        return RdfStringMatcher.wrap(format, baseUri, SparqlTupleQueryMatcher.sparqlQuery(queryBaseUri, sparqlQuery, matcher));
+    }
+
+    @SafeVarargs
+    public static <T extends String> Matcher<T> sparqlTupleQueryRdf(RDFFormat format, String baseUri, String queryBaseUri, String sparqlQuery, Matcher<Iterable<BindingSet>>... matchers) {
+        return RdfStringMatcher.wrap(format, baseUri, SparqlTupleQueryMatcher.sparqlQuery(queryBaseUri, sparqlQuery, matchers));
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlGraphQuery(String baseUri, String sparqlQuery, Matcher<? extends RepositoryConnection> matcher) {
+        return SparqlGraphQueryMatcher.<T>sparqlGraphQuery(baseUri, sparqlQuery, matcher);
+    }
+
+    @SafeVarargs
+    public static <T extends RepositoryConnection, V extends RepositoryConnection> Matcher<T> sparqlGraphQuery(String baseUri, String sparqlQuery, Matcher<V>... matchers) {
+        return SparqlGraphQueryMatcher.<T>sparqlGraphQuery(baseUri, sparqlQuery, CoreMatchers.allOf(matchers));
+    }
+
+    public static <T extends Repository, V extends RepositoryConnection> Matcher<T> sparqlGraphQueryRepository(String baseUri, String sparqlQuery, Matcher<V> matcher) {
+        return RepositoryMatcher.wrap(sparqlGraphQuery(baseUri, sparqlQuery, matcher));
+    }
+
+    @SafeVarargs
+    public static <T extends Repository, V extends RepositoryConnection> Matcher<T> sparqlGraphQueryRepository(String baseUri, String sparqlQuery, Matcher<V>... matchers) {
+        return RepositoryMatcher.wrap(sparqlGraphQuery(baseUri, sparqlQuery, matchers));
+    }
+
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> sparqlGraphQueryRdf(RDFFormat format, String baseUri, String queryBaseUri, String sparqlQuery, Matcher<V> matcher) {
+        return RdfStringMatcher.wrap(format, baseUri, sparqlGraphQuery(queryBaseUri, sparqlQuery, matcher));
+    }
+
+    @SafeVarargs
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> sparqlGraphQueryRdf(RDFFormat format, String baseUri, String queryBaseUri, String sparqlQuery, Matcher<V>... matchers) {
+        return RdfStringMatcher.wrap(format, baseUri, sparqlGraphQuery(queryBaseUri, sparqlQuery, matchers));
+    }
+
+    public static <T extends Repository, V extends RepositoryConnection> Matcher<T> repositoryMatches(Matcher<V> matcher) {
+        return RepositoryMatcher.wrap(matcher);
+    }
+
+    public static <T extends Repository, V extends RepositoryConnection> Matcher<T> repositoryMatches(Matcher<V> matcher1, Matcher<V> matcher2) {
+        return RepositoryMatcher.wrap(CoreMatchers.allOf(matcher1, matcher2));
+    }
+
+    @SafeVarargs
+    public static <T extends Repository, V extends RepositoryConnection> Matcher<T> repositoryMatches(Matcher<V>... matchers) {
+        return RepositoryMatcher.wrap(CoreMatchers.allOf(matchers));
+    }
+
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(RDFFormat format, String baseUri, Matcher<V> matcher) {
+        return  RdfStringMatcher.wrap(format, baseUri, matcher);
+    }
+
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(RDFFormat format, String baseUri, Matcher<V> matcher1, Matcher<V> matcher2) {
+        return  RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matcher1, matcher2));
+    }
+
+    @SafeVarargs
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(RDFFormat format, String baseUri, Matcher<V>... matchers) {
+        return  RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matchers));
+    }
+
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V> matcher) {
+        final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
+        if (format == null) throw new UnsupportedRDFormatException(mimeType);
+        return  RdfStringMatcher.wrap(format, baseUri, matcher);
+    }
+
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V> matcher1, Matcher<V> matcher2) {
+        final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
+        if (format == null) throw new UnsupportedRDFormatException(mimeType);
+        return  RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matcher1, matcher2));
+    }
+
+    @SafeVarargs
+    public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V>... matchers) {
+        final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
+        if (format == null) throw new UnsupportedRDFormatException(mimeType);
+        return  RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matchers));
+    }
+
+    private SesameMatchers() {
+        // static access only.
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/AbstractRepositoryConnectionMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/AbstractRepositoryConnectionMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/AbstractRepositoryConnectionMatcher.java
new file mode 100644
index 0000000..77df042
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/AbstractRepositoryConnectionMatcher.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.base;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+/**
+ * BaseMatcher for Sesame RepositoryConnections
+ */
+public abstract class AbstractRepositoryConnectionMatcher<T extends RepositoryConnection> extends SesameMatcher<T> implements Matcher<T> {
+
+    @Override
+    protected final boolean matchesSafely(RepositoryConnection connection) {
+        try {
+            return matchesConnection(connection);
+        } catch (RuntimeException r) {
+            throw r;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    protected abstract boolean matchesConnection(RepositoryConnection connection) throws RepositoryException;
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RdfStringMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RdfStringMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RdfStringMatcher.java
new file mode 100644
index 0000000..93dde30
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RdfStringMatcher.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.base;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.sail.memory.MemoryStore;
+
+import java.io.StringReader;
+
+/**
+ * Match an RDF String (various Formats)
+ */
+public class RdfStringMatcher<T extends String> extends SesameMatcher<T> implements Matcher<T> {
+
+    private final Matcher<? extends RepositoryConnection> delegate;
+    private final String baseUri;
+    private final RDFFormat format;
+
+    public RdfStringMatcher(RDFFormat format, String baseUri, Matcher<? extends RepositoryConnection> delegate) {
+        this.delegate = delegate;
+        this.baseUri = baseUri;
+        this.format = format;
+    }
+
+    @Override
+    protected boolean matchesSafely(String rdfString) {
+        if (baseUri == null) throw new IllegalArgumentException("baseUri must not be null");
+        if (format == null) throw new IllegalArgumentException("format must not be null");
+
+        try {
+            Repository repo = new SailRepository(new MemoryStore());
+            repo.initialize();
+            try {
+                final RepositoryConnection con = repo.getConnection();
+                try (final StringReader r = new StringReader(rdfString)) {
+                    con.begin();
+                    con.add(r, baseUri, format);
+                    con.commit();
+
+                    con.begin();
+                    final boolean result = delegate.matches(con);
+                    con.commit();
+                    return result;
+                } catch (final Throwable t) {
+                    con.rollback();
+                    throw t;
+                } finally {
+                    con.close();
+                }
+            } finally {
+                repo.shutDown();
+            }
+        } catch (RuntimeException r) {
+            throw r;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(format.getName()).appendText(" String ").appendDescriptionOf(delegate);
+    }
+
+    public static <T extends String> Matcher<T> wrap(RDFFormat format, String baseUri, Matcher<? extends RepositoryConnection> delegate) {
+        return new RdfStringMatcher<T>(format, baseUri, delegate);
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RepositoryMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RepositoryMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RepositoryMatcher.java
new file mode 100644
index 0000000..306b58b
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/RepositoryMatcher.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.base;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+
+/**
+ * Wrapper for a {@link AbstractRepositoryConnectionMatcher} to accept a {@link Repository}
+ */
+public class RepositoryMatcher<T extends Repository> extends SesameMatcher<T> implements Matcher<T> {
+
+    private final Matcher<? extends RepositoryConnection> delegate;
+
+    /**
+     * @param delegate the Matcher to wrap.
+     */
+    public RepositoryMatcher(Matcher<? extends RepositoryConnection> delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    protected boolean matchesSafely(Repository repository) {
+        try {
+            final RepositoryConnection con = repository.getConnection();
+            try {
+                con.begin();
+                boolean matches = delegate.matches(con);
+                con.commit();
+                return matches;
+            } catch (final Throwable t) {
+                con.rollback();
+                throw t;
+            } finally {
+                con.close();
+            }
+        } catch (RuntimeException r) {
+            throw r;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        delegate.describeTo(description);
+    }
+
+    @Override
+    protected void describeMismatchSafely(T item, Description mismatchDescription) {
+        delegate.describeMismatch(item, mismatchDescription);
+    }
+
+    public static <T extends Repository> Matcher<T> wrap(Matcher<? extends RepositoryConnection> connectionMatcher) {
+        return new RepositoryMatcher<T>(connectionMatcher);
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/SesameMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/SesameMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/SesameMatcher.java
new file mode 100644
index 0000000..fb9fdcc
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/base/SesameMatcher.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.base;
+
+import org.hamcrest.TypeSafeMatcher;
+import org.openrdf.repository.RepositoryConnection;
+
+/**
+ * Shared Superclass for all SesameMatchers.
+ */
+public abstract class SesameMatcher<T> extends TypeSafeMatcher<T> {
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
new file mode 100644
index 0000000..282937e
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.connection;
+
+import org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+/**
+ * Has Statement Matcher
+ */
+public class HasStatementMatcher<T extends RepositoryConnection> extends AbstractRepositoryConnectionMatcher<T> {
+
+    private final Resource subject;
+    private final URI predicate;
+    private final Value object;
+    private final Resource[] contexts;
+
+    protected HasStatementMatcher(Resource subject, URI predicate, Value object, Resource... contexts) {
+        super();
+        this.subject = subject;
+        this.predicate = predicate;
+        this.object = object;
+        this.contexts = contexts;
+    }
+
+    @Override
+    protected boolean matchesConnection(RepositoryConnection con) throws RepositoryException {
+        return con.hasStatement(subject, predicate, object, true, contexts);
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(" to contain Statement(")
+                .appendValue(subject).appendText(" ")
+                .appendValue(predicate).appendText(" ")
+                .appendValue(object).appendText(")");
+    }
+
+
+    public static <T extends RepositoryConnection> Matcher<T> hasStatement(Resource subject, URI predicate, Value object, Resource... contexts) {
+        return new HasStatementMatcher<T>(subject, predicate, object, contexts);
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlAskMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlAskMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlAskMatcher.java
new file mode 100644
index 0000000..0da7f4f
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlAskMatcher.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.sparql;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.query.BooleanQuery;
+import org.openrdf.query.MalformedQueryException;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+/**
+ * Sparql ASK-Query Matcher
+ */
+public class SparqlAskMatcher<T extends RepositoryConnection> extends SparqlMatcher<T> {
+    protected SparqlAskMatcher(String baseUri, String query) {
+        super(baseUri, query);
+    }
+
+    @Override
+    protected boolean matchesSPARQL(RepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException {
+        final BooleanQuery booleanQuery = con.prepareBooleanQuery(QueryLanguage.SPARQL, query, baseUri);
+
+        return booleanQuery.evaluate();
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText("Query ").appendValue(query).appendText(" to match");
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlAsk(String baseUri, String askQuery) {
+        return new SparqlAskMatcher<T>(baseUri, askQuery);
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlAsk(String askQuery) {
+        return sparqlAsk(null, askQuery);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlGraphQueryMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlGraphQueryMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlGraphQueryMatcher.java
new file mode 100644
index 0000000..cc356e5
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlGraphQueryMatcher.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.sparql;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.query.*;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.sail.memory.MemoryStore;
+
+/**
+ *
+ */
+public class SparqlGraphQueryMatcher<T extends RepositoryConnection> extends SparqlMatcher<T> {
+    private final Matcher<? extends RepositoryConnection> matcher;
+
+    protected SparqlGraphQueryMatcher(String baseUri, String query, Matcher<? extends RepositoryConnection> matcher) {
+        super(baseUri, query);
+        this.matcher = matcher;
+    }
+
+    @Override
+    protected boolean matchesSPARQL(RepositoryConnection connection) throws MalformedQueryException, RepositoryException, QueryEvaluationException {
+        final GraphQuery graphQuery = connection.prepareGraphQuery(QueryLanguage.SPARQL, query, baseUri);
+
+        final Repository repo = new SailRepository(new MemoryStore());
+        repo.initialize();
+        try {
+            final RepositoryConnection connection2 = repo.getConnection();
+            try {
+                connection2.begin();
+                final GraphQueryResult graph = graphQuery.evaluate();
+                try {
+                    connection2.add(graph);
+                } finally {
+                    graph.close();
+                }
+                connection2.commit();
+
+                connection2.begin();
+                final boolean result = matcher.matches(connection2);
+                connection2.commit();
+                return result;
+            } finally {
+                connection2.close();
+            }
+        } finally {
+            repo.shutDown();
+        }
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(" Graph ").appendValue(query).appendText(" ").appendDescriptionOf(matcher);
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlGraphQuery(String baseUri, String query, Matcher<? extends RepositoryConnection> matcher) {
+        return new SparqlGraphQueryMatcher<T>(baseUri, query, matcher);
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlMatcher.java
new file mode 100644
index 0000000..cd06d8d
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlMatcher.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.sparql;
+
+import org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher;
+import org.openrdf.query.MalformedQueryException;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+/**
+ * SPARQL Matcher
+ */
+public abstract class SparqlMatcher<T extends RepositoryConnection> extends AbstractRepositoryConnectionMatcher<T> {
+
+    protected final String baseUri;
+    protected final String query;
+
+    protected SparqlMatcher(String baseUri, String query) {
+        super();
+
+        if (query == null) throw new IllegalArgumentException("query must not be null");
+
+        this.baseUri = baseUri;
+        this.query = query;
+    }
+
+    @Override
+    protected final boolean matchesConnection(RepositoryConnection connection) throws RepositoryException {
+        try {
+            return matchesSPARQL(connection);
+        } catch (MalformedQueryException e) {
+            throw new IllegalArgumentException("Invalid SPARQL Query: " + query, e);
+        } catch (QueryEvaluationException e) {
+            throw new RepositoryException(e);
+        }
+    }
+
+    protected abstract boolean matchesSPARQL(RepositoryConnection connection) throws MalformedQueryException, RepositoryException, QueryEvaluationException;
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlTupleQueryMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlTupleQueryMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlTupleQueryMatcher.java
new file mode 100644
index 0000000..1af5540
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/sparql/SparqlTupleQueryMatcher.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.test.sparql;
+
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.openrdf.query.*;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Match against Sparql Tuple Query.
+ */
+public class SparqlTupleQueryMatcher<T extends RepositoryConnection> extends SparqlMatcher<T> {
+    private final Matcher<Iterable<BindingSet>> matcher;
+
+    protected SparqlTupleQueryMatcher(String baseUri, String query, Matcher<Iterable<BindingSet>> matcher) {
+        super(baseUri, query);
+        this.matcher = matcher;
+    }
+
+    @Override
+    protected boolean matchesSPARQL(RepositoryConnection con) throws RepositoryException, QueryEvaluationException, MalformedQueryException {
+        final TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query, baseUri);
+        final TupleQueryResult result = tupleQuery.evaluate();
+        final List<BindingSet> bindingSets = QueryResults.asList(result);
+
+        // FIXME: test this!
+        return matcher.matches(bindingSets);
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(" TupleQuery ").appendValue(query).appendText(" to ").appendDescriptionOf(matcher);
+    }
+
+    public static <T extends RepositoryConnection> Matcher<T> sparqlQuery(String baseUri, String query, Matcher<Iterable<BindingSet>> matcher) {
+        return new SparqlTupleQueryMatcher<T>(baseUri, query, matcher);
+    }
+
+    @SafeVarargs
+    public static <T extends RepositoryConnection> Matcher<T> sparqlQuery(String baseUri, String query, Matcher<Iterable<BindingSet>>... matchers) {
+        return new SparqlTupleQueryMatcher<T>(baseUri, query, CoreMatchers.allOf(matchers));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/commons/marmotta-sesame-tools/pom.xml
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/pom.xml b/commons/marmotta-sesame-tools/pom.xml
index 1566b4e..fb5b0a9 100644
--- a/commons/marmotta-sesame-tools/pom.xml
+++ b/commons/marmotta-sesame-tools/pom.xml
@@ -59,6 +59,7 @@
         <module>marmotta-rio-vcard</module>
         <module>marmotta-sail-contextaware</module>
         <module>marmotta-sail-transactions</module>
+        <module>marmotta-sesame-matchers</module>
         <module>marmotta-util-facading</module>
         <module>marmotta-util-filter</module>
         <module>marmotta-util-tripletable</module>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 157cf07..edc1d89 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1417,6 +1417,11 @@
                 <artifactId>marmotta-model-vocabs</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.marmotta</groupId>
+                <artifactId>marmotta-sesame-matchers</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- parsers -->
             <dependency>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/pom.xml b/platform/marmotta-ldp/pom.xml
index b6632f8..d3147ea 100644
--- a/platform/marmotta-ldp/pom.xml
+++ b/platform/marmotta-ldp/pom.xml
@@ -261,6 +261,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>marmotta-sesame-matchers</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>com.google.code.tempus-fugit</groupId>
             <artifactId>tempus-fugit</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
index 86937bf..4883e8b 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
@@ -19,10 +19,10 @@ package org.apache.marmotta.platform.ldp.webservices;
 
 import com.jayway.restassured.RestAssured;
 import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.commons.sesame.test.SesameMatchers;
 import org.apache.marmotta.commons.vocabulary.LDP;
 import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
 import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
-import org.apache.marmotta.platform.ldp.webservices.util.HasStatementMatcher;
 import org.apache.marmotta.platform.ldp.webservices.util.HeaderMatchers;
 import org.hamcrest.CoreMatchers;
 import org.junit.AfterClass;
@@ -39,8 +39,6 @@ import javax.ws.rs.core.UriBuilder;
 import java.io.IOException;
 import java.net.URISyntaxException;
 
-import static org.apache.marmotta.platform.ldp.webservices.util.HasStatementMatcher.hasStatement;
-
 /**
  * Testing LDP web services
  *
@@ -113,10 +111,10 @@ public class LdpWebServiceTest {
                 )
                 .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific here
                 .contentType(mimeType)
-                .body(
-                        hasStatement(mimeType, baseUrl + container, new URIImpl(baseUrl + container), DCTERMS.MODIFIED, null),
-                        hasStatement(mimeType, baseUrl + container, new URIImpl(baseUrl + container), RDF.TYPE, LDP.BasicContainer)
-                )
+                .body(SesameMatchers.rdfStringMatches(mimeType, baseUrl+container,
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), DCTERMS.MODIFIED, null),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), RDF.TYPE, LDP.BasicContainer)
+                ))
                 .get(container);
 
         // also the new resource exists
@@ -131,10 +129,10 @@ public class LdpWebServiceTest {
                 )
                 .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific here
                 .contentType(mimeType)
-                .body(
-                        hasStatement(mimeType, baseUrl + newResource, new URIImpl(baseUrl + newResource), DCTERMS.MODIFIED, null),
-                        hasStatement(mimeType, baseUrl + newResource, new URIImpl(baseUrl + newResource), RDF.TYPE, LDP.Resource)
-                )
+                .body(SesameMatchers.rdfStringMatches(mimeType, baseUrl + container,
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), DCTERMS.MODIFIED, null),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), RDF.TYPE, LDP.Resource)
+                ))
             .get(newResource);
 
         // delete
@@ -143,6 +141,7 @@ public class LdpWebServiceTest {
                 .statusCode(204)
                 .header("Link", HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport", "describedby"))
                 .header("ETag", HeaderMatchers.headerNotPresent())
+                .header("Last-Modified", HeaderMatchers.headerNotPresent())
             .delete(newResource);
 
         // now the new resource does not exist.

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/BaseRdfMatcher.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/BaseRdfMatcher.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/BaseRdfMatcher.java
deleted file mode 100644
index 0b55d2d..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/BaseRdfMatcher.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.webservices.util;
-
-import com.google.common.base.Preconditions;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-import org.openrdf.rio.Rio;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.io.IOException;
-import java.io.StringReader;
-
-/**
- * Base class for RDF Matchers to be used in Unit-Tests.
- */
-public abstract class BaseRdfMatcher extends TypeSafeMatcher<String> {
-
-    protected final RDFFormat format;
-    protected final String baseUri;
-
-    protected BaseRdfMatcher(String baseUri, RDFFormat format) {
-        this.baseUri = baseUri;
-        this.format = format;
-    }
-
-    protected BaseRdfMatcher(String mimeType, String baseUri) {
-        this(baseUri, Rio.getParserFormatForMIMEType(mimeType));
-    }
-
-    /**
-     * Create an initialized Repository from the provided String data representation using the default RDFFormat
-     *
-     * @param data the rdf data
-     * @param baseUri the baseUri
-     * @return an initialized Repository containing the data
-     */
-    protected Repository createRepository(String data, String baseUri) throws RepositoryException, RDFParseException, IOException {
-        return createRepository(data, baseUri, format);
-    }
-
-    /**
-     * Create an initialized Repository from the provided String data representation using the default RDFFormat
-     *
-     * @param data the rdf data
-     * @param baseUri the baseUri
-     * @param format the RDFFormat
-     * @return an initialized Repository containing the data
-     */
-    protected Repository createRepository(String data, String baseUri, RDFFormat format) throws RepositoryException, RDFParseException, IOException {
-        Preconditions.checkArgument(format != null, "RDFFormat must not be null");
-
-        final Repository repository = new SailRepository(new MemoryStore());
-        repository.initialize();
-
-        final RepositoryConnection con = repository.getConnection();
-        try (final StringReader r = new StringReader(data)) {
-            con.begin();
-            con.add(r, baseUri, format);
-            con.commit();
-        } catch (final Throwable t) {
-            con.rollback();
-            throw t;
-        } finally {
-            con.close();
-        }
-
-        return repository;
-    }
-
-    @Override
-    public final boolean matchesSafely(String item) {
-        boolean isMatching = false;
-        try {
-            final Repository rep = createRepository(item, baseUri);
-            final RepositoryConnection con = rep.getConnection();
-            try {
-                con.begin();
-                isMatching = matches(con);
-                con.commit();
-            } catch (final Throwable t) {
-                con.rollback();
-                throw t;
-            } finally {
-                con.close();
-                rep.shutDown();
-            }
-        } catch (Throwable t) {
-            isMatching = false;
-        }
-
-        return isMatching;
-    }
-
-    protected abstract boolean matches(RepositoryConnection con) throws Exception;
-
-    @Override
-    public void describeTo(Description description) {
-        description.appendText("a RDF ").appendText(format.getName()).appendText(" String");
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HasStatementMatcher.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HasStatementMatcher.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HasStatementMatcher.java
deleted file mode 100644
index 1cbcb1f..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HasStatementMatcher.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.webservices.util;
-
-import org.hamcrest.Description;
-import org.openrdf.model.Resource;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-
-/**
- * Has Statement Matcher
- */
-public class HasStatementMatcher extends BaseRdfMatcher {
-
-    private final Resource subject;
-    private final URI predicate;
-    private final Value object;
-    private final Resource[] contexts;
-
-    protected HasStatementMatcher(String mimeType, String baseUri, Resource subject, URI predicate, Value object, Resource... contexts) {
-        super(mimeType, baseUri);
-        this.subject = subject;
-        this.predicate = predicate;
-        this.object = object;
-        this.contexts = contexts;
-    }
-
-    @Override
-    protected boolean matches(RepositoryConnection con) throws RepositoryException {
-        return con.hasStatement(subject, predicate, object, true, contexts);
-    }
-
-    @Override
-    public void describeTo(Description description) {
-        super.describeTo(description);
-        description.appendText(" containing a Statement(")
-                .appendValue(subject).appendText(" ")
-                .appendValue(predicate).appendText(" ")
-                .appendValue(object).appendText(")");
-    }
-
-
-    public static HasStatementMatcher hasStatement(String mimeType, Resource subject, URI predicate, Value object) {
-        return hasStatement(mimeType, "", subject, predicate, object);
-    }
-
-    public static HasStatementMatcher hasStatement(String mimeType, String baseUri, Resource subject, URI predicate, Value object) {
-        return new HasStatementMatcher(mimeType, baseUri, subject, predicate, object);
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
index e578d1b..a109c3d 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
@@ -19,9 +19,7 @@ package org.apache.marmotta.platform.ldp.webservices.util;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.platform.ldp.util.EntityTagUtils;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.CustomTypeSafeMatcher;
-import org.hamcrest.Matcher;
+import org.hamcrest.*;
 import org.jboss.resteasy.plugins.delegates.EntityTagDelegate;
 import org.jboss.resteasy.plugins.delegates.LinkDelegate;
 
@@ -34,19 +32,29 @@ import javax.ws.rs.core.Link;
 public class HeaderMatchers {
 
     public static Matcher<String> headerPresent() {
-        return new CustomTypeSafeMatcher<String>("not to be empty") {
+        return new BaseMatcher<String>() {
             @Override
-            protected boolean matchesSafely(String item) {
-                return StringUtils.isNotBlank(item);
+            public boolean matches(Object item) {
+                return item != null && StringUtils.isNotBlank(item.toString());
+            }
+
+            @Override
+            public void describeTo(Description description) {
+                description.appendText("set");
             }
         };
     }
 
     public static Matcher<String> headerNotPresent() {
-        return new CustomTypeSafeMatcher<String>("to be emtpy") {
+        return new BaseMatcher<String>() {
             @Override
-            protected boolean matchesSafely(String item) {
-                return StringUtils.isBlank(item);
+            public boolean matches(Object item) {
+                return item == null || StringUtils.isBlank(item.toString());
+            }
+
+            @Override
+            public void describeTo(Description description) {
+                description.appendText("absent or empty");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlAskMatcher.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlAskMatcher.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlAskMatcher.java
deleted file mode 100644
index a8f1559..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlAskMatcher.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.webservices.util;
-
-import org.openrdf.query.BooleanQuery;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.QueryLanguage;
-import org.openrdf.repository.RepositoryConnection;
-
-/**
- * Sparql ASK-Query Matcher
- */
-public class SparqlAskMatcher extends SparqlMatcher {
-    protected SparqlAskMatcher(String baseUri, String mimeType, String query) {
-        super(baseUri, mimeType, query);
-    }
-
-    @Override
-    protected boolean matches(RepositoryConnection con) throws Exception {
-        try {
-            final BooleanQuery booleanQuery = con.prepareBooleanQuery(QueryLanguage.SPARQL, query, baseUri);
-
-            return booleanQuery.evaluate();
-        } catch (MalformedQueryException e) {
-            throw new IllegalArgumentException("Invalid SPARQL Query: " + query, e);
-        }
-    }
-
-    public static SparqlAskMatcher sparqlAsk(String mimeType, String baseUri, String askQuery) {
-        return new SparqlAskMatcher(baseUri, mimeType, askQuery);
-    }
-
-    public static SparqlAskMatcher sparqlAsk(String mimeType, String askQuery) {
-        return sparqlAsk(mimeType, "", askQuery);
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlGraphQueryMatcher.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlGraphQueryMatcher.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlGraphQueryMatcher.java
deleted file mode 100644
index dd29bbe..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlGraphQueryMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.webservices.util;
-
-import org.openrdf.query.GraphQuery;
-import org.openrdf.query.GraphQueryResult;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.QueryLanguage;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.rio.RDFWriter;
-import org.openrdf.rio.Rio;
-
-import java.io.StringWriter;
-import java.util.Map;
-
-/**
- *
- */
-public class SparqlGraphQueryMatcher extends SparqlMatcher {
-    private final BaseRdfMatcher matcher;
-
-    protected SparqlGraphQueryMatcher(String baseUri, String mimeType, String query, BaseRdfMatcher matcher) {
-        super(baseUri, mimeType, query);
-        this.matcher = matcher;
-    }
-
-    @Override
-    protected boolean matches(RepositoryConnection con) throws Exception {
-        try {
-            final GraphQuery graphQuery = con.prepareGraphQuery(QueryLanguage.SPARQL, query, baseUri);
-
-            final GraphQueryResult graph = graphQuery.evaluate();
-            // FIXME: this is not very efficient!
-            try {
-                final StringWriter stringWriter = new StringWriter();
-                final RDFWriter writer = Rio.createWriter(matcher.format, stringWriter);
-
-                writer.startRDF();
-                for (Map.Entry<String, String> namespace : graph.getNamespaces().entrySet()) {
-                    writer.handleNamespace(namespace.getKey(), namespace.getValue());
-                }
-                while (graph.hasNext()) {
-                    writer.handleStatement(graph.next());
-                }
-                writer.endRDF();
-
-                return matcher.matches(stringWriter.toString());
-            } finally {
-                graph.close();
-            }
-        } catch (MalformedQueryException e) {
-            throw new IllegalArgumentException("Invalid SPARQL Query: " + query, e);
-        }
-    }
-
-    public static SparqlGraphQueryMatcher sparqlGraphQuery(String mimeType, String baseUri, String query, BaseRdfMatcher matcher) {
-        return new SparqlGraphQueryMatcher(baseUri, mimeType, query, matcher);
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlMatcher.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlMatcher.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlMatcher.java
deleted file mode 100644
index 7bc46e3..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlMatcher.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.webservices.util;
-
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.rio.RDFParseException;
-
-import java.io.IOException;
-
-/**
- * SPARQL Matcher
- */
-public abstract class SparqlMatcher extends BaseRdfMatcher {
-
-    protected final String query;
-
-    protected SparqlMatcher(String baseUri, String mimeType, String query) {
-        super(baseUri, mimeType);
-        this.query = query;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9f8f8f4c/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlTupleQueryMatcher.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlTupleQueryMatcher.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlTupleQueryMatcher.java
deleted file mode 100644
index 3eb9f77..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/SparqlTupleQueryMatcher.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.webservices.util;
-
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matcher;
-import org.openrdf.query.*;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Match against Sparql Tuple Query.
- */
-public class SparqlTupleQueryMatcher extends SparqlMatcher {
-    private final Matcher<Collection<BindingSet>> matcher;
-
-    protected SparqlTupleQueryMatcher(String baseUri, String mimeType, String query, Matcher<Collection<BindingSet>> matcher) {
-        super(baseUri, mimeType, query);
-        this.matcher = matcher;
-    }
-
-    @Override
-    protected boolean matches(RepositoryConnection con) throws RepositoryException, QueryEvaluationException {
-        try {
-            final TupleQuery tupleQuery;
-            tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query, baseUri);
-            final TupleQueryResult result = tupleQuery.evaluate();
-            final List<BindingSet> bindingSets = QueryResults.asList(result);
-
-            return matcher.matches(bindingSets);
-        } catch (MalformedQueryException e) {
-            throw new IllegalArgumentException("Invalid SPARQL Query: " + query, e);
-        }
-    }
-
-    public static SparqlTupleQueryMatcher sparqlQuery(String mime, String baseUri, String query, Matcher<Collection<BindingSet>> matcher) {
-        return new SparqlTupleQueryMatcher(mime, baseUri, query, matcher);
-    }
-
-    @SafeVarargs
-    public static SparqlTupleQueryMatcher sparqlQuery(String mime, String baseUri, String query, Matcher<Collection<BindingSet>>... matchers) {
-        return new SparqlTupleQueryMatcher(mime, baseUri, query, CoreMatchers.allOf(matchers));
-    }
-
-}


Mime
View raw message