MARMOTTA-438: removed test suite until the official one is ready to be integrated
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/b5cfb0a5 Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/b5cfb0a5 Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/b5cfb0a5 Branch: refs/heads/ldp Commit: b5cfb0a5d23eea132925ca166b563a8d493ab3f4 Parents: ecebad1 Author: Sergio Fernández <[email protected]> Authored: Mon May 5 20:42:07 2014 +0200 Committer: Sergio Fernández <[email protected]> Committed: Mon May 5 20:42:07 2014 +0200 ---------------------------------------------------------------------- .../platform/ldp/testsuite/LdpManifestTest.java | 73 -------- .../platform/ldp/testsuite/LdpTestCase.java | 183 ------------------- .../ldp/testsuite/LdpTestCaseRunner.java | 111 ----------- .../platform/ldp/testsuite/LdpTestCases.java | 71 ------- .../ldp/testsuite/LdpTestCasesRunner.java | 128 ------------- .../ldp/testsuite/LdpTestCasesUtils.java | 130 ------------- 6 files changed, 696 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/b5cfb0a5/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 deleted file mode 100644 index b9102a4..0000000 --- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpManifestTest.java +++ /dev/null @@ -1,73 +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.testsuite; - -import org.junit.*; -import org.openrdf.model.Statement; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.repository.Repository; -import org.openrdf.repository.RepositoryConnection; -import org.openrdf.repository.RepositoryException; -import org.openrdf.repository.RepositoryResult; -import org.openrdf.rio.RDFFormat; -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 { - String path = LdpTestCases.ROOT_PATH + LdpTestCases.MANIFEST_CACHE + ".ttl"; - repo = LdpTestCasesUtils.loadData(path, RDFFormat.TURTLE); - 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, RDF.TYPE, conn.getValueFactory().createURI("http://www.w3.org/2006/03/test-description#", "TestCase"), 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/b5cfb0a5/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 deleted file mode 100644 index e293d71..0000000 --- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCase.java +++ /dev/null @@ -1,183 +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.testsuite; - -import org.openrdf.model.URI; - -import java.util.List; - -import static org.junit.Assert.assertEquals; - -/** - * 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) { - 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/b5cfb0a5/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 deleted file mode 100644 index 3c2f36b..0000000 --- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCaseRunner.java +++ /dev/null @@ -1,111 +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.testsuite; - -import com.jayway.restassured.RestAssured; -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.LdpWebService; -import org.junit.*; -import org.junit.rules.TestName; -import org.junit.runner.Description; -import org.junit.runner.Runner; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.Suite; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.core.UriBuilder; -import java.io.IOException; -import java.net.URISyntaxException; - -import static org.junit.Assert.assertNotNull; - -/** - * LDP Test Case JUnit Runner - * - * @author Sergio Fernández - */ -public class LdpTestCaseRunner extends Runner { - - private static Logger log = LoggerFactory.getLogger(LdpTestCaseRunner.class); - - private final LdpTestCase testCase; - - private String baseUrl; - - public LdpTestCaseRunner(LdpTestCase testCase) { - this.testCase = testCase; - } - - @Override - public Description getDescription() { - return Description.createSuiteDescription(testCase.getUri().getLocalName()); - } - - @Override - public void run(RunNotifier notifier) { - notifier.fireTestRunStarted(getDescription()); - try { - run(); - } catch (Exception e) { - //TODO - //notifier.fireTestFailure(e); - } - 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.warn("Executing LDP Test Case {} over context {}...", testCase.getUri().getLocalName(), context); - - //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) { - return baseUrl + "/" + testCase.getUri().getLocalName().toLowerCase(); - } - - public String getBaseUrl() { - return baseUrl; - } - - public void setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - } - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/b5cfb0a5/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 deleted file mode 100644 index ace1b23..0000000 --- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCases.java +++ /dev/null @@ -1,71 +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.testsuite; - -import com.jayway.restassured.RestAssured; -import org.apache.marmotta.platform.core.test.base.JettyMarmotta; -import org.apache.marmotta.platform.ldp.webservices.LdpWebService; -import org.junit.ClassRule; -import org.junit.rules.ExternalResource; -import org.junit.runner.RunWith; - -import javax.ws.rs.core.UriBuilder; - -/** - * LDP Test Cases - * - * @author Sergio Fernández - * - * @see <a href="https://dvcs.w3.org/hg/ldpwg/raw-file/default/Test%20Cases/LDP%20Test%20Cases.html">LDP Test Cases</a> - */ -@RunWith(LdpTestCasesRunner.class) -public class LdpTestCases { - - public final static String ROOT_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-live"; - - @ClassRule - public static ExternalResource marmotta = new MarmottaResource(); - - public static class MarmottaResource extends ExternalResource { - - JettyMarmotta marmotta; - - String baseUrl; - - @Override - protected void before() throws Throwable { - marmotta = new JettyMarmotta("/marmotta", LdpWebService.class); - RestAssured.baseURI = "http://localhost"; - RestAssured.port = marmotta.getPort(); - RestAssured.basePath = marmotta.getContext(); - baseUrl = UriBuilder.fromUri("http://localhost").port(marmotta.getPort()).path(marmotta.getContext()).build().toString(); - } - - @Override - protected void after() { - //marmotta.shutdown(); - marmotta = null; - } - - } - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/b5cfb0a5/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 deleted file mode 100644 index 4cb18a7..0000000 --- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesRunner.java +++ /dev/null @@ -1,128 +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.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; -import org.junit.runners.Suite; -import org.junit.runners.model.FrameworkField; -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.RDFFormat; -import org.openrdf.rio.RDFParseException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -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; - -/** - * LDP Test Cases JUnit Runner - * - * @author Sergio Fernández - */ -public class LdpTestCasesRunner extends Suite { - - private static Logger log = LoggerFactory.getLogger(LdpTestCasesRunner.class); - - private LdpTestCases.MarmottaResource marmotta; - - private Repository repo; - - private List<Runner> runners; - - public LdpTestCasesRunner(Class<?> klass) throws Throwable { - 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())) { - marmotta = (LdpTestCases.MarmottaResource)rule; - break; - } - } - } - - @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 + LdpWebService.PATH); - } - super.runChild(runner, notifier); - } - - 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 { - 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(); - } - } catch (RepositoryException e) { - log.error("Error loading test cases: {}", e.getMessage(), e); - } catch (QueryEvaluationException | MalformedQueryException e) { - log.error("Error performing test cases' query: {}", e.getMessage(), e); - } - return runners; - } - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/b5cfb0a5/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 deleted file mode 100644 index 9270da7..0000000 --- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/testsuite/LdpTestCasesUtils.java +++ /dev/null @@ -1,130 +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.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.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -/** - * Utils functions for the test cases - * - * @author Sergio Fernández - */ -public class LdpTestCasesUtils { - - /** - * Load test cases' data - * - * @param path path to the manifest file - * @param format serialization format used in the manifest file - * @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(String path, RDFFormat format) throws RDFParseException, RepositoryException, IOException { - 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; - } - - /** - * Get normative namespaces - * - * @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 Map<String,String> getNormativeNamespaces() throws IOException { - String path = LdpTestCases.ROOT_PATH + "namespaces.properties"; - Map<String,String> prefixes = new HashMap<>(); - Properties properties = new Properties(); - properties.load(LdpTestCasesUtils.class.getResourceAsStream(path)); - for(String key : properties.stringPropertyNames()) { - String value = properties.getProperty(key); - prefixes.put(key, value); - } - return Collections.unmodifiableMap(prefixes); - } - - /** - * Get normative namespaces with SPARQL syntax - * - * @throws IOException - */ - public static String getNormativeNamespacesSparql() throws IOException { - StringBuffer sb = new StringBuffer(); - Map<String, String> normativeNamespaces = getNormativeNamespaces(); - for (Map.Entry<String, String> entry : normativeNamespaces.entrySet()) { - //PREFIX dc: <http://purl.org/dc/terms/> - sb.append("PREFIX "); - sb.append(entry.getKey()); - sb.append(": <"); - sb.append(entry.getValue()); - sb.append("> \n"); - } - return sb.toString(); - } - - /** - * Add normative namespaces - * - * @param conn target connection - * @throws IOException - * @throws RepositoryException - */ - public static void addNormativeNamespaces(RepositoryConnection conn) throws IOException, RepositoryException { - Map<String, String> normativeNamespaces = getNormativeNamespaces(); - for (Map.Entry<String, String> entry : normativeNamespaces.entrySet()) { - conn.setNamespace(entry.getValue(), entry.getKey()); - } - } - -}
