MARMOTTA-438: starting to outline a generic ldp test cases' executor

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

Branch: refs/heads/master
Commit: 7e89065efed4cfebe8e0ed7e3d426a229b2efc19
Parents: ca37361
Author: Sergio Fernández <[email protected]>
Authored: Wed Apr 2 12:53:23 2014 +0200
Committer: Sergio Fernández <[email protected]>
Committed: Wed Apr 2 12:53:23 2014 +0200

----------------------------------------------------------------------
 .../platform/ldp/testsuite/LdpManifestTest.java |   70 +
 .../platform/ldp/testsuite/LdpTestCase.java     |  189 +++
 .../platform/ldp/testsuite/LdpTestCases.java    |   33 +
 .../ldp/testsuite/LdpTestCasesExecutor.java     |  114 ++
 .../ldp/testsuite/LdpTestCasesUtils.java        |   91 ++
 .../testsuite/LdpAbstractTestSuite.java         |  168 ---
 .../testsuite/LdpResourcesTestSuite.java        |   51 -
 .../ldp/webservices/testsuite/TestCase.java     |  164 ---
 .../marmotta-ldp/src/test/resources/test.ttl    |    3 +-
 .../LDP-Test-Cases-Custom-20140318.ttl          |   63 -
 .../testsuite/LDP-Test-Cases-WD-20140317.ttl    |   22 +
 .../testsuite/LDP-Test-Cases-WD-20140402.ttl    | 1291 ++++++++++++++++++
 12 files changed, 1811 insertions(+), 448 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpManifestTest.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpManifestTest.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpManifestTest.java
new file mode 100644
index 0000000..50fb767
--- /dev/null
+++ 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpManifestTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.testsuite;
+
+import org.junit.*;
+import org.openrdf.model.Statement;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.RepositoryResult;
+import org.openrdf.rio.RDFParseException;
+
+import java.io.IOException;
+
+/**
+ * LDP Test Cases Manifest test
+ *
+ * @author Sergio Fernández
+ */
+public class LdpManifestTest {
+
+    protected Repository repo;
+
+    @Before
+    public final void before() throws RepositoryException, RDFParseException, 
IOException {
+        repo = LdpTestCasesUtils.loadData();
+        Assume.assumeNotNull(repo);
+    }
+
+    @After
+    public final void after() throws RepositoryException {
+        if (repo != null) {
+            repo.shutDown();
+            repo = null;
+        }
+    }
+
+    @Test
+    public void testNotEmpty() throws RepositoryException, RDFParseException, 
IOException {
+        RepositoryConnection conn = repo.getConnection();
+        try {
+            conn.begin();
+            //ValueFactory vf = conn.getValueFactory();
+            Assert.assertFalse(conn.isEmpty());
+            RepositoryResult<Statement> statements = conn.getStatements(null, 
null, null, false);
+            Assert.assertTrue(statements.hasNext());
+            statements.close();
+            //TODO: check test cases are actually there
+        } finally {
+            conn.commit();
+            conn.close();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCase.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCase.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCase.java
new file mode 100644
index 0000000..33ec7e9
--- /dev/null
+++ 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCase.java
@@ -0,0 +1,189 @@
+/*
+ * 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.testsuite;
+
+import junit.framework.TestCase;
+import org.openrdf.model.URI;
+
+import java.util.List;
+
+/**
+ * LDP Test Case
+ *
+ * @author Sergio Fernández
+ * @see <a 
href="http://www.w3.org/TR/ldp-test-cases/#test-case-description";>LDP Tests 
Cases</a>
+ */
+public class LdpTestCase extends TestCase {
+
+    /**
+     * Test Case Uniform Resource Identifier
+     */
+    private URI uri;
+
+    /**
+     * rdfs:label. The human-readable label of the test.
+     */
+    private String label;
+
+    /**
+     * dc:title. The name of the test.
+     */
+    private String title;
+
+    /**
+     * dc:description. The description of the test.
+     */
+    private String description;
+
+    /**
+     * dc:contributor. The person (foaf:Person) contributing the test.
+     */
+    private URI contributor;
+
+    /**
+     * td:reviewStatus. The status of the test; possible status are: 
td:unreviewed, td:approved or td:rejected.
+     */
+    private URI reviewStatus;
+
+    //td:specificationReference. An excerpt (tn:Excerpt) of the specification 
that is relevant to the test.
+
+    /**
+     * td:input. An input (tn:TestInput) used in the test.
+     */
+    private URI input;
+
+    /**
+     * td:precondition. A precondition that must be satisfied before running 
the test.
+     */
+    private URI precondition;
+
+    /**
+     * tn:output. An output (tn:TestOutput) to be produced by the test.
+     */
+    private URI output;
+
+    /**
+     * tn:testProcess. The list of steps (tn:Step) to be performed during the 
test.
+     */
+    private List<URI> testProcess;
+
+    /**
+     * tn:testAssertion. An assertion (tn:TestAssertion) to be performed over 
the test output.
+     */
+    private URI testAssertion;
+
+    public LdpTestCase(URI uri, String label) {
+        super(label);
+        this.uri = uri;
+        this.label = label;
+    }
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public void setUri(URI uri) {
+        this.uri = uri;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public URI getContributor() {
+        return contributor;
+    }
+
+    public void setContributor(URI contributor) {
+        this.contributor = contributor;
+    }
+
+    public URI getReviewStatus() {
+        return reviewStatus;
+    }
+
+    public void setReviewStatus(URI reviewStatus) {
+        this.reviewStatus = reviewStatus;
+    }
+
+    public URI getInput() {
+        return input;
+    }
+
+    public void setInput(URI input) {
+        this.input = input;
+    }
+
+    public URI getPrecondition() {
+        return precondition;
+    }
+
+    public void setPrecondition(URI precondition) {
+        this.precondition = precondition;
+    }
+
+    public URI getOutput() {
+        return output;
+    }
+
+    public void setOutput(URI output) {
+        this.output = output;
+    }
+
+    public List<URI> getTestProcess() {
+        return testProcess;
+    }
+
+    public void setTestProcess(List<URI> testProcess) {
+        this.testProcess = testProcess;
+    }
+
+    public URI getTestAssertion() {
+        return testAssertion;
+    }
+
+    public void setTestAssertion(URI testAssertion) {
+        this.testAssertion = testAssertion;
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        assertEquals(label.substring(3), uri.getLocalName().substring(2));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCases.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCases.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCases.java
new file mode 100644
index 0000000..247c21d
--- /dev/null
+++ 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCases.java
@@ -0,0 +1,33 @@
+/*
+ * 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.testsuite;
+
+/**
+ * LDP Test Cases metadata (updated on April 2, 2014)
+ *
+ * @author Sergio Fernández
+ */
+public class LdpTestCases {
+
+    public final static String FILES_PATH = "/testsuite/";
+
+    public final static String BASE = "http://www.w3.org/TR/ldp-test-cases/";;
+
+    public final static String MANIFEST_CACHE = "LDP-Test-Cases-WD-20140402";
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesExecutor.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesExecutor.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesExecutor.java
new file mode 100644
index 0000000..1dd0900
--- /dev/null
+++ 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesExecutor.java
@@ -0,0 +1,114 @@
+/*
+ * 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.testsuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.AllTests;
+import org.openrdf.model.URI;
+import org.openrdf.query.*;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.rio.RDFParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * LDP Test Cases Executor
+ *
+ * @author Sergio Fernández
+ */
+@RunWith(AllTests.class)
+public final class LdpTestCasesExecutor {
+
+    private static Logger log = 
LoggerFactory.getLogger(LdpTestCasesExecutor.class);
+
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite();
+        for (Test test : buildTestCasesFromManifest()) {
+            suite.addTest(test);
+        }
+        return suite;
+    }
+
+    private static Collection<Test> buildTestCasesFromManifest() {
+        Collection<Test> tests = new ArrayList<>();
+
+        try {
+            Repository repo = LdpTestCasesUtils.loadData();
+            RepositoryConnection conn = repo.getConnection();
+            try {
+                conn.begin();
+
+                //TODO: this query is not final, it needs to evolve in 
parallel with the test cases
+                String testCasesQuery =
+                        "PREFIX dc: <http://purl.org/dc/terms/> \n" +
+                        "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n" +
+                        "PREFIX ht: <http://www.w3.org/2011/http#> \n" +
+                        "PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
+                        "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
+                        "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
\n" +
+                        "PREFIX td: 
<http://www.w3.org/2006/03/test-description#> \n" +
+                        "PREFIX tn: 
<http://ldp.example.org/NewTestDefinitions#> \n\n" +
+                        "SELECT ?tc ?label \n" +
+                        "WHERE { \n" +
+                        "  ?tc a td:TestCase ; \n" +
+                        "      rdfs:label ?label . \n" +
+                        "}";
+                TupleQuery tupleQuery = 
conn.prepareTupleQuery(QueryLanguage.SPARQL, testCasesQuery);
+                TupleQueryResult results = tupleQuery.evaluate();
+                try {
+                    while (results.hasNext()) {
+                        BindingSet bindings = results.next();
+                        LdpTestCase testCase = new 
LdpTestCase((URI)bindings.getValue("tc"), 
bindings.getValue("label").stringValue());
+
+                        //TODO
+
+                        tests.add(testCase);
+                    }
+                } finally {
+                    results.close();
+                }
+            } catch (RepositoryException e) {
+                log.error("Error loading test cases: {}", e.getMessage(), e);
+                return tests;
+            } catch (QueryEvaluationException | MalformedQueryException e) {
+                log.error("Error performing test cases' query: {}", 
e.getMessage(), e);
+                return tests;
+            } finally {
+                conn.commit();
+                conn.close();
+            }
+        } catch (RDFParseException | IOException e) {
+            log.error("Error loading test cases: {}", e.getMessage(), e);
+            return tests;
+        } catch (RepositoryException e) {
+            log.error("Error connecting with the repository: {}", 
e.getMessage(), e);
+            return tests;
+        }
+
+        return tests;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesUtils.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesUtils.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesUtils.java
new file mode 100644
index 0000000..7ff982e
--- /dev/null
+++ 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesUtils.java
@@ -0,0 +1,91 @@
+/*
+ * 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.testsuite;
+
+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.sail.memory.MemoryStore;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Utils functions for the test cases
+ *
+ * @author Sergio Fernández
+ */
+public class LdpTestCasesUtils {
+
+    /**
+     * Load test cases' data
+     *
+     * @return In-Memory repository with the data
+     * @throws org.openrdf.rio.RDFParseException
+     * @throws org.openrdf.repository.RepositoryException
+     * @throws java.io.IOException
+     */
+    public static Repository loadData() throws RDFParseException, 
RepositoryException, IOException {
+        String path = LdpTestCases.FILES_PATH + LdpTestCases.MANIFEST_CACHE + 
".ttl";
+        Repository repo = new SailRepository(new MemoryStore());
+        repo.initialize();
+        RepositoryConnection conn = repo.getConnection();
+        try {
+            conn.begin();
+            conn.clear();
+            InputStream is = LdpTestCasesUtils.class.getResourceAsStream(path);
+            if (is == null) {
+                throw new IOException("Manifest file not found at: " + path);
+            } else {
+                try {
+                    conn.add(is, LdpTestCases.BASE, RDFFormat.TURTLE);
+                } finally {
+                    is.close();
+                }
+            }
+            addNormativeNamespaces(conn);
+            conn.commit();
+        } finally {
+            conn.close();
+        }
+        return repo;
+    }
+
+    /**
+     * Add some normative namespaces
+     *
+     * @param conn target connection
+     * @throws IOException
+     * @throws RepositoryException
+     *
+     * @see <a 
href="https://dvcs.w3.org/hg/ldpwg/raw-file/default/Test%20Cases/LDP%20Test%20Cases.html#h3_namespaces-used";>Sec.
 4.1 Namespaces used</a>
+     */
+    public static void addNormativeNamespaces(RepositoryConnection conn) 
throws IOException, RepositoryException {
+        String path = LdpTestCases.FILES_PATH + "namespaces.properties";
+        Properties properties = new Properties();
+        properties.load(LdpTestCasesUtils.class.getResourceAsStream(path));
+        for(String key : properties.stringPropertyNames()) {
+            String value = properties.getProperty(key);
+            conn.setNamespace(value, key);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpAbstractTestSuite.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpAbstractTestSuite.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpAbstractTestSuite.java
deleted file mode 100644
index a9427cb..0000000
--- 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpAbstractTestSuite.java
+++ /dev/null
@@ -1,168 +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.testsuite;
-
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.openrdf.model.URI;
-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.sail.memory.MemoryStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * LDP Abstract Test Suite
- *
- * @author Sergio Fernández
- * @see <a 
href="https://dvcs.w3.org/hg/ldpwg/raw-file/default/Test%20Cases/LDP%20Test%20Cases.html";>Linked
 Data Platform 1.0 Test Cases</a>
- */
-public abstract class LdpAbstractTestSuite {
-
-    protected static Logger log = 
LoggerFactory.getLogger(LdpAbstractTestSuite.class);
-
-    public final static String FILES_PATH = "/testsuite/";
-
-    public final static String BASE = "http://www.w3.org/TR/ldp-test-cases/";;
-
-    public final static String TEST_CASES_CACHE = 
"LDP-Test-Cases-Custom-20140318";
-
-    protected Repository repo;
-
-    @Rule
-    public TestName name = new TestName();
-
-    @Before
-    public final void before() throws RepositoryException, RDFParseException, 
IOException {
-        log.info("initializing test case {}...", name.getMethodName());
-        repo = loadData(TEST_CASES_CACHE);
-        Assume.assumeNotNull(repo);
-    }
-
-    @After
-    public final void after() throws RepositoryException {
-        if (repo != null) {
-            repo.shutDown();
-            repo = null;
-        }
-    }
-
-    /**
-     * Load a dataset into a new in-memory repository
-     *
-     * @param file file name
-     * @return connection to the repository
-     * @throws RDFParseException
-     * @throws RepositoryException
-     * @throws IOException
-     */
-    protected Repository loadData(String file) throws RDFParseException, 
RepositoryException, IOException {
-        log.debug("creating new in-memory repository...");
-        Repository repo = new SailRepository(new MemoryStore());
-        repo.initialize();
-        RepositoryConnection conn = repo.getConnection();
-        try {
-            conn.begin();
-            conn.clear();
-            conn.clearNamespaces();
-            addNormativeNamespaces(conn);
-            loadData(conn, file);
-            conn.commit();
-        } finally {
-            conn.close();
-        }
-        return repo;
-    }
-
-    /**
-     * Load a dataset to the connection passed
-     *
-     * @param conn connection
-     * @param file test case identifier
-     * @throws RDFParseException
-     * @throws RepositoryException
-     * @throws IOException
-     */
-    protected void loadData(RepositoryConnection conn, String file) throws 
RDFParseException, RepositoryException, IOException {
-        log.debug("loading test cases {}...", file);
-        String path = FILES_PATH + file + ".ttl";
-        InputStream is = getClass().getResourceAsStream(path);
-        if (is == null) {
-            log.error("test cases data {} not found where expected ({})", 
file, path);
-        } else {
-            try {
-                conn.add(is, BASE, RDFFormat.TURTLE);
-            } finally {
-                is.close();
-            }
-            log.debug("test cases data {} successfully loaded ({} triples)", 
file, conn.size());
-        }
-    }
-
-    /**
-     * Add some normative namespaces
-     *
-     * @param conn target connection
-     * @see <a 
href="https://dvcs.w3.org/hg/ldpwg/raw-file/default/Test%20Cases/LDP%20Test%20Cases.html#h3_namespaces-used";>Sec.
 4.1 Namespaces used</a>
-     */
-    private void addNormativeNamespaces(RepositoryConnection conn) {
-        Properties properties = new Properties();
-        String path = FILES_PATH + "namespaces.properties";
-        try {
-            properties.load(getClass().getResourceAsStream(path));
-            for(String key : properties.stringPropertyNames()) {
-                String value = properties.getProperty(key);
-                try {
-                    conn.setNamespace(value, key);
-                } catch (RepositoryException e) {
-                    log.error("error adding namespace {}: {}", key, 
e.getMessage());
-                }
-            }
-        } catch (IOException | NullPointerException e) {
-            log.error("error loading normative namespaces at {}: {}", path, 
e.getMessage());
-        }
-
-    }
-
-
-    /**
-     * Load a Test Case according the specified format
-     *
-     * @param uri test case uri
-     * @return test case bean
-     * @see <a 
href="http://www.w3.org/TR/ldp-test-cases/#test-case-description";>LDP Tests 
Cases</a>
-     */
-    private TestCase loadTestCase(URI uri) {
-        TestCase tc = new TestCase(uri);
-        //TODO
-        return tc;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpResourcesTestSuite.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpResourcesTestSuite.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpResourcesTestSuite.java
deleted file mode 100644
index 229bf18..0000000
--- 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/LdpResourcesTestSuite.java
+++ /dev/null
@@ -1,51 +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.testsuite;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openrdf.model.URI;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.vocabulary.RDF;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-
-/**
- * LDPRs Test Suite
- *
- * @author Sergio Fernández
- */
-public class LdpResourcesTestSuite extends LdpAbstractTestSuite {
-
-    @Test
-    public void TCR1() throws RepositoryException {
-        //not really used, traces of the initial approach
-        RepositoryConnection conn = repo.getConnection();
-        try {
-            conn.begin();
-            ValueFactory vf = conn.getValueFactory();
-            URI uri = vf.createURI(BASE, name.getMethodName());
-            URI tdTestCase = 
vf.createURI("http://www.w3.org/2006/03/test-description#TestCase";); //TOD: 
import vocab
-            Assert.assertTrue(conn.hasStatement(uri, RDF.TYPE, tdTestCase, 
false));
-            //TestCase tc = loadTestCase(uri);
-        } finally {
-            conn.close();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/TestCase.java
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/TestCase.java
 
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/TestCase.java
deleted file mode 100644
index cb47a8a..0000000
--- 
a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/testsuite/TestCase.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package org.apache.marmotta.platform.ldp.webservices.testsuite;
-
-import org.openrdf.model.URI;
-
-import java.util.List;
-
-/**
- * LDP Test Case
- *
- * @author Sergio Fernández
- * @see <a 
href="http://www.w3.org/TR/ldp-test-cases/#test-case-description";>LDP Tests 
Cases</a>
- */
-public class TestCase {
-
-    /**
-     * Test Case Uniform Resource Identifier
-     */
-    private URI uri;
-
-    /**
-     * rdfs:label. The human-readable label of the test.
-     */
-    private String label;
-
-    /**
-     * dc:title. The name of the test.
-     */
-    private String title;
-
-    /**
-     * dc:description. The description of the test.
-     */
-    private String description;
-
-    /**
-     * dc:contributor. The person (foaf:Person) contributing the test.
-     */
-    private URI contributor;
-
-    /**
-     * td:reviewStatus. The status of the test; possible status are: 
td:unreviewed, td:approved or td:rejected.
-     */
-    private URI reviewStatus;
-
-    //td:specificationReference. An excerpt (tn:Excerpt) of the specification 
that is relevant to the test.
-
-    /**
-     * td:input. An input (tn:TestInput) used in the test.
-     */
-    private URI input;
-
-    /**
-     * td:precondition. A precondition that must be satisfied before running 
the test.
-     */
-    private URI precondition;
-
-    /**
-     * tn:output. An output (tn:TestOutput) to be produced by the test.
-     */
-    private URI output;
-
-    /**
-     * tn:testProcess. The list of steps (tn:Step) to be performed during the 
test.
-     */
-    private List<URI> testProcess;
-
-    /**
-     * tn:testAssertion. An assertion (tn:TestAssertion) to be performed over 
the test output.
-     */
-    private URI testAssertion;
-
-    public TestCase(URI uri) {
-        this.uri = uri;
-    }
-
-    public URI getUri() {
-        return uri;
-    }
-
-    public void setUri(URI uri) {
-        this.uri = uri;
-    }
-
-    public String getLabel() {
-        return label;
-    }
-
-    public void setLabel(String label) {
-        this.label = label;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public URI getContributor() {
-        return contributor;
-    }
-
-    public void setContributor(URI contributor) {
-        this.contributor = contributor;
-    }
-
-    public URI getReviewStatus() {
-        return reviewStatus;
-    }
-
-    public void setReviewStatus(URI reviewStatus) {
-        this.reviewStatus = reviewStatus;
-    }
-
-    public URI getInput() {
-        return input;
-    }
-
-    public void setInput(URI input) {
-        this.input = input;
-    }
-
-    public URI getPrecondition() {
-        return precondition;
-    }
-
-    public void setPrecondition(URI precondition) {
-        this.precondition = precondition;
-    }
-
-    public URI getOutput() {
-        return output;
-    }
-
-    public void setOutput(URI output) {
-        this.output = output;
-    }
-
-    public List<URI> getTestProcess() {
-        return testProcess;
-    }
-
-    public void setTestProcess(List<URI> testProcess) {
-        this.testProcess = testProcess;
-    }
-
-    public URI getTestAssertion() {
-        return testAssertion;
-    }
-
-    public void setTestAssertion(URI testAssertion) {
-        this.testAssertion = testAssertion;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/resources/test.ttl
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/resources/test.ttl 
b/platform/marmotta-ldp/src/test/resources/test.ttl
index bf70c35..1f4b4ac 100644
--- a/platform/marmotta-ldp/src/test/resources/test.ttl
+++ b/platform/marmotta-ldp/src/test/resources/test.ttl
@@ -1,4 +1,3 @@
-#
 # 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
@@ -14,7 +13,7 @@
 # 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.
-#
+
 @prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
 @prefix dct:  <http://purl.org/dc/terms/>.

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-Custom-20140318.ttl
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-Custom-20140318.ttl
 
b/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-Custom-20140318.ttl
deleted file mode 100644
index 1f621bc..0000000
--- 
a/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-Custom-20140318.ttl
+++ /dev/null
@@ -1,63 +0,0 @@
-@prefix dc: <http://purl.org/dc/terms/> .
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-@prefix ht: <http://www.w3.org/2011/http#> .
-@prefix owl: <http://www.w3.org/2002/07/owl#> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix td: <http://www.w3.org/2006/03/test-description#> .
-@prefix tn: <http://ldp.example.org/NewTestDefinitions#> .
-@prefix : <http://www.w3.org/TR/ldp-test-cases/> .
-
-:TCR1 a td:TestCase;
-         rdfs:label "TC-R1";
-         dc:title "GET on an LDPR";
-         dc:description "Tests making a GET request on an existing LDPR";
-         dc:contributor :RaulGarciaCastro;
-         td:reviewStatus td:unreviewed;
-         rdfs:seeAlso <http://www.w3.org/TR/ldp/>;
-         td:specificationReference [
-             a tn:Excerpt;
-             rdfs:seeAlso <http://www.w3.org/TR/ldp/>;
-             tn:includesText "4.2.8 LDPR server responses MUST use entity tags 
(either weak or strong ones) as response ETag header values."
-           ],
-                                [
-            a tn:Excerpt;
-             rdfs:seeAlso <http://www.w3.org/TR/ldp/>;
-             tn:includesText "4.2.10 LDPR servers MUST advertise their LDP 
support by exposing a HTTP Link header with a target URI of 
http://www.w3.org/ns/ldp/Resource, and a link relation type of type (that is, 
rel=\"type\") in all responses to requests made to the resource's HTTP 
Request-URI. [...]"
-           ],
-                               [
-            a tn:Excerpt;
-             rdfs:seeAlso <http://www.w3.org/TR/ldp/>;
-             tn:includesText "4.3.1 LDPR servers MUST support the HTTP GET 
Method for LDPRs."
-           ];
-         td:input :TCR1-I1-LDPR-URI;
-         td:precondition "The LDP server contains an LDPR at <LDPR URI>";
-         tn:output :TCR1-O1-Response-1-GET;
-         tn:testProcess (:TCR1-RQ1-GET-LDPR-URI);
-         tn:testAssertion :TCR1-A1-Response-1-GET.
-
-:RaulGarciaCastro a foaf:Person;
-                    rdfs:label "Raúl García-Castro";
-                    owl:sameAs <http://delicias.dia.fi.upm.es/~rgarcia/#me>.
-
-:TCR1-I1-LDPR-URI a tn:TestInput;
-           dc:title "<LDPR URI>";
-           dc:description "The URI of an LDPR".
-
-:TCR1-O1-Response-1-GET a tn:TestOutput;
-            a ht:Response;
-            tn:fromStep :TCR1-RQ1-GET-LDPR-URI;
-            dc:title "<Response 1 GET>";
-            dc:description "The response of the GET request in step 1".
-
-:TCR1-RQ1-GET-LDPR-URI a tn:Step;
-            a ht:Request;
-            dc:description "GET <LDPR URI>";
-            tn:usesInput :TCR1-I1-LDPR-URI.
-
-:TCR1-A1-Response-1-GET a tn:TestAssertion;
-            tn:outputAsserted :TCR1-O1-Response-1-GET;
-            dc:title "GET correct";
-            dc:description """[Status-Line].Status-Code = 2xx
-        [response-header].ETag exists
-        [response-header].Link = ldp:Resource; rel="type" """.

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7e89065e/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-WD-20140317.ttl
----------------------------------------------------------------------
diff --git 
a/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-WD-20140317.ttl
 
b/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-WD-20140317.ttl
index f051eec..0d61f33 100644
--- 
a/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-WD-20140317.ttl
+++ 
b/platform/marmotta-ldp/src/test/resources/testsuite/LDP-Test-Cases-WD-20140317.ttl
@@ -1,3 +1,25 @@
+# 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.
+
+# This file contains the Turtle serialization of the Test Cases in RDFa
+# from 
https://dvcs.w3.org/hg/ldpwg/raw-file/default/Test%20Cases/LDP%20Test%20Cases.html
+# (cached on March 17, 2014).
+#
+# Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
+
 @prefix dc: <http://purl.org/dc/terms/> .
 @prefix foaf: <http://xmlns.com/foaf/0.1/> .
 @prefix ht: <http://www.w3.org/2011/http#> .

Reply via email to