You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2014/06/13 10:58:43 UTC
[083/100] [abbrv] git commit: MARMOTTA-438: more work on test suite
execution
MARMOTTA-438: more work on test suite execution
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/49b6b3c0
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/49b6b3c0
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/49b6b3c0
Branch: refs/heads/ldp
Commit: 49b6b3c0dcc89731c423cb01ac7e14b4f19e5a20
Parents: c3b393e
Author: Sergio Fernández <wi...@apache.org>
Authored: Tue Apr 15 16:31:38 2014 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Tue Apr 15 16:31:38 2014 +0200
----------------------------------------------------------------------
.../platform/ldp/services/LdpServiceImpl.java | 1 +
.../ldp/testsuite/LdpTestCaseRunner.java | 20 ++++-
.../platform/ldp/testsuite/LdpTestCases.java | 2 +-
.../ldp/testsuite/LdpTestCasesRunner.java | 82 +++++++++++---------
4 files changed, 66 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/49b6b3c0/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
index 75d7923..8d28aae 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
@@ -44,6 +44,7 @@ import org.openrdf.rio.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.core.EntityTag;
http://git-wip-us.apache.org/repos/asf/marmotta/blob/49b6b3c0/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCaseRunner.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCaseRunner.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCaseRunner.java
index 79a6079..3c2f36b 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCaseRunner.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCaseRunner.java
@@ -70,14 +70,30 @@ public class LdpTestCaseRunner extends Runner {
notifier.fireTestFinished(getDescription());
}
+ /**
+ * Actual test case run method, which build the test case execution
+ * on the fly based on
+ */
private void run() {
Assume.assumeNotNull(baseUrl);
assertNotNull(testCase);
assertNotNull(testCase.getUri());
String context = buildContext(testCase);
- log.info("Executing LDP Test Case {} over context {}...", testCase.getUri().getLocalName(), context);
+ log.warn("Executing LDP Test Case {} over context {}...", testCase.getUri().getLocalName(), context);
- //TODO: actual test case execution
+ //basic pre-checking
+ //RestAssured.expect().statusCode(200).get(baseUrl); //TODO: clarify this (root container?)
+ RestAssured.expect().statusCode(404).get(context);
+
+ //load all information of the test cases
+ readTestCase(testCase);
+
+ //actual test case execution
+
+ }
+
+ private void readTestCase(LdpTestCase testCase) {
+ //TODO: read all details
}
private String buildContext(LdpTestCase testCase) {
http://git-wip-us.apache.org/repos/asf/marmotta/blob/49b6b3c0/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
index c60aba4..ace1b23 100644
--- 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
@@ -53,7 +53,7 @@ public class LdpTestCases {
@Override
protected void before() throws Throwable {
- marmotta = new JettyMarmotta("/marmotta-ldp", LdpWebService.class);
+ marmotta = new JettyMarmotta("/marmotta", LdpWebService.class);
RestAssured.baseURI = "http://localhost";
RestAssured.port = marmotta.getPort();
RestAssured.basePath = marmotta.getContext();
http://git-wip-us.apache.org/repos/asf/marmotta/blob/49b6b3c0/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesRunner.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesRunner.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesRunner.java
index f9fc57a..4cb18a7 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesRunner.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesRunner.java
@@ -18,6 +18,7 @@
package org.apache.marmotta.platform.ldp.testsuite;
import org.apache.commons.lang3.StringUtils;
+import org.apache.marmotta.platform.ldp.webservices.LdpWebService;
import org.junit.rules.TestRule;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
@@ -37,6 +38,7 @@ import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -50,9 +52,28 @@ public class LdpTestCasesRunner extends Suite {
private LdpTestCases.MarmottaResource marmotta;
+ private Repository repo;
+
+ private List<Runner> runners;
+
public LdpTestCasesRunner(Class<?> klass) throws Throwable {
- super(klass, buildTestCasesFromManifest());
+ super(klass, Collections.EMPTY_LIST);
+
+ //load test cases manifest
+ repo = loadManifest();
+ //get children runners for each test cases from manifest
+ RepositoryConnection conn = repo.getConnection();
+ try {
+ conn.begin();
+ runners = buildTestCasesFromManifest(conn);
+ log.info("Initialized LDP test suite with {} test cases", runners.size());
+ conn.commit();
+ } finally {
+ conn.close();
+ }
+
+ //get embedded marmotta from rules
//TODO: it should be an easier way to do it...
for (TestRule rule : this.classRules()) {
if (LdpTestCases.MarmottaResource.class.equals(rule.getClass())) {
@@ -63,55 +84,44 @@ public class LdpTestCasesRunner extends Suite {
}
@Override
+ protected List<Runner> getChildren() {
+ return Collections.unmodifiableList(runners);
+ }
+
+ @Override
protected void runChild(Runner runner, RunNotifier notifier) {
if (runner instanceof LdpTestCaseRunner) {
- ((LdpTestCaseRunner)runner).setBaseUrl(marmotta.baseUrl);
+ ((LdpTestCaseRunner)runner).setBaseUrl(marmotta.baseUrl + LdpWebService.PATH);
}
super.runChild(runner, notifier);
}
- private static List<Runner> buildTestCasesFromManifest() throws Throwable {
- List<Runner> runners = new ArrayList<>();
-
+ private Repository loadManifest() throws RepositoryException, RDFParseException, IOException {
String path = LdpTestCases.ROOT_PATH + LdpTestCases.MANIFEST_CACHE + ".ttl";
+ return LdpTestCasesUtils.loadData(path, RDFFormat.TURTLE);
+ }
+
+ private static List<Runner> buildTestCasesFromManifest(RepositoryConnection conn) throws Throwable {
+ List<Runner> runners = new ArrayList<>();
try {
- Repository repo = LdpTestCasesUtils.loadData(path, RDFFormat.TURTLE);
- RepositoryConnection conn = repo.getConnection();
+ String testCasesQuery = LdpTestCasesUtils.getNormativeNamespacesSparql()+ "\n"
+ + "SELECT ?tc WHERE { ?tc a td:TestCase }";
+ TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, testCasesQuery);
+ TupleQueryResult results = tupleQuery.evaluate();
try {
- conn.begin();
-
- String testCasesQuery = LdpTestCasesUtils.getNormativeNamespacesSparql()+ "\n"
- + "SELECT ?tc WHERE { ?tc a td:TestCase }";
- 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"));
- runners.add(new LdpTestCaseRunner(testCase));
- }
- } finally {
- results.close();
+ while (results.hasNext()) {
+ BindingSet bindings = results.next();
+ LdpTestCase testCase = new LdpTestCase((URI)bindings.getValue("tc"));
+ runners.add(new LdpTestCaseRunner(testCase));
}
- conn.commit();
- } catch (RepositoryException e) {
- log.error("Error loading test cases: {}", e.getMessage(), e);
- return runners;
- } catch (QueryEvaluationException | MalformedQueryException e) {
- log.error("Error performing test cases' query: {}", e.getMessage(), e);
- return runners;
} finally {
- conn.close();
+ results.close();
}
- } catch (RDFParseException | IOException e) {
- log.error("Error loading test cases: {}", e.getMessage(), e);
- return runners;
} catch (RepositoryException e) {
- log.error("Error connecting with the repository: {}", e.getMessage(), e);
- return runners;
+ log.error("Error loading test cases: {}", e.getMessage(), e);
+ } catch (QueryEvaluationException | MalformedQueryException e) {
+ log.error("Error performing test cases' query: {}", e.getMessage(), e);
}
-
- log.info("Initialized LDP test suite with {} test cases", runners.size());
return runners;
}