You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/27 14:01:11 UTC
[4/12] MARMOTTA-108: renamed packages in marmotta-client-java also
did some cleanup (removed clients for services that are not part of marmotta)
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/test/java/org/apache/marmotta/client/test/sparql/SPARQLIT.java
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/test/java/org/apache/marmotta/client/test/sparql/SPARQLIT.java b/client/marmotta-client-java/src/test/java/org/apache/marmotta/client/test/sparql/SPARQLIT.java
new file mode 100644
index 0000000..1cc0dfb
--- /dev/null
+++ b/client/marmotta-client-java/src/test/java/org/apache/marmotta/client/test/sparql/SPARQLIT.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed 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.client.test.sparql;
+
+
+import org.apache.marmotta.client.ClientConfiguration;
+import org.apache.marmotta.client.clients.SPARQLClient;
+import org.apache.marmotta.client.model.sparql.SPARQLResult;
+import org.apache.marmotta.client.test.AbstractClientIT;
+import org.apache.marmotta.client.test.ldpath.LDPathIT;
+import org.apache.marmotta.platform.core.api.importer.ImportService;
+import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.hamcrest.Matcher;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+
+import static org.hamcrest.Matchers.*;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class SPARQLIT extends AbstractClientIT {
+ private final static Logger log = LoggerFactory.getLogger(SPARQLIT.class);
+
+ private static JettyMarmotta marmotta;
+
+ private static ClientConfiguration config;
+
+ // the tests require the demo-data.foaf to be loaded; we do so by first calling the import service before we start with tests
+ private static ImportService importService;
+
+
+ @BeforeClass
+ public static void init() throws MarmottaImportException {
+ marmotta = new JettyMarmotta("/Marmotta",8080);
+ config = new ClientConfiguration("http://localhost:8080/Marmotta");
+
+ importService = marmotta.getService(ImportService.class);
+
+ // load initial data
+ InputStream data = getTestData("demo-data.foaf");
+
+ importService.importData(data,"application/rdf+xml",null,null);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ marmotta.shutdown();
+ }
+
+
+ @Test
+ public void testSparqlSelect() throws Exception {
+ SPARQLClient client = new SPARQLClient(config);
+
+ SPARQLResult result = client.select("SELECT ?r ?n WHERE { ?r <http://xmlns.com/foaf/0.1/name> ?n }");
+ Assert.assertEquals(3, result.size());
+ Assert.assertThat(result, (Matcher) hasItems(hasKey("r"), hasKey("n")));
+ Assert.assertThat(result,(Matcher)hasItem(hasValue(hasProperty("content", equalTo("Sepp Huber")))));
+ }
+
+
+ @Test
+ public void testSparqlAsk() throws Exception {
+ SPARQLClient client = new SPARQLClient(config);
+
+ boolean result = client.ask("ASK { ?r <http://xmlns.com/foaf/0.1/name> ?n }");
+ Assert.assertTrue(result);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/test/resources/demo-data.foaf
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/test/resources/demo-data.foaf b/client/marmotta-client-java/src/test/resources/demo-data.foaf
deleted file mode 100644
index bdd8de0..0000000
--- a/client/marmotta-client-java/src/test/resources/demo-data.foaf
+++ /dev/null
@@ -1,80 +0,0 @@
-<!--
- ~ Copyright (c) 2012 Salzburg Research.
- ~
- ~ Licensed 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.
- -->
-
-<rdf:RDF
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:foaf="http://xmlns.com/foaf/0.1/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:skos="http://www.w3.org/2004/02/skos/core#"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- >
-
- <foaf:Person rdf:about="http://localhost:8080/LMF/resource/hans_meier" xmlns:foaf="http://xmlns.com/foaf/0.1/">
- <foaf:name>Hans Meier</foaf:name>
- <dc:description>Hans Meier is a software engineer living in Salzburg</dc:description>
- <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.software_engineering"/>
- <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.linux"/>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Java" />
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
- <foaf:based_near rdf:resource="http://sws.geonames.org/2766824/"/>
- <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/hans_meier.jpg"/>
-
- <foaf:knows rdf:resource="http://bblfish.net/people/henry/card#me" />
- <foaf:knows rdf:resource="http://dbpedia.org/resource/James_Gosling"/>
- </foaf:Person>
-
- <foaf:Person rdf:about="http://localhost:8080/LMF/resource/sepp_huber" xmlns:foaf="http://xmlns.com/foaf/0.1/">
- <foaf:name>Sepp Huber</foaf:name>
- <dc:description>Sepp Huber is an alpinist living in Traunstein. He is a good climber, but not as famous as his cousin Alexander Huber.</dc:description>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
- <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
- <foaf:based_near rdf:resource="http://dbpedia.org/resource/Traunstein"/>
-
- <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
- <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/hans_meier" />
- </foaf:Person>
-
- <foaf:Person rdf:about="http://localhost:8080/LMF/resource/anna_schmidt" xmlns:foaf="http://xmlns.com/foaf/0.1/">
- <foaf:name>Anna Schmidt</foaf:name>
- <dc:description>Anna Schmidt is working as PR manager for mountaineers coming from Garmisch-Partenkirchen. She likes mountaineering and is also a Linux enthusiast.</dc:description>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
- <foaf:interest rdf:resource="http://dbpedia.org/resource/Linux"/>
- <foaf:interest rdf:resource="http://localhost:8080/LMF/resource/Chess" />
- <foaf:based_near rdf:resource="http://dbpedia.org/resource/Garmisch-Partenkirchen"/>
- <foaf:depiction rdf:resource="http://localhost:8080/LMF/resource/anna_schmidt.jpg"/>
-
- <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
- <foaf:knows rdf:resource="http://localhost:8080/LMF/resource/sepp_huber" />
- </foaf:Person>
-
- <skos:Concept rdf:about="http://rdf.freebase.com/ns/en.linux">
- <rdfs:label>GNU/Linux</rdfs:label>
- </skos:Concept>
-
- <skos:Concept rdf:about="http://rdf.freebase.com/ns/en.software_engineering">
- <rdfs:label>Software Engineering</rdfs:label>
- </skos:Concept>
-
- <skos:Concept rdf:about="http://dbpedia.org/resource/Java">
- <rdfs:label>Java</rdfs:label>
- </skos:Concept>
-
- <skos:Concept rdf:about="http://dbpedia.org/resource/Climbing">
- <rdfs:label>Climbing</rdfs:label>
- </skos:Concept>
-
-</rdf:RDF>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ed88a640/client/marmotta-client-java/src/test/resources/org/apache/marmotta/client/test/demo-data.foaf
----------------------------------------------------------------------
diff --git a/client/marmotta-client-java/src/test/resources/org/apache/marmotta/client/test/demo-data.foaf b/client/marmotta-client-java/src/test/resources/org/apache/marmotta/client/test/demo-data.foaf
new file mode 100644
index 0000000..3528b48
--- /dev/null
+++ b/client/marmotta-client-java/src/test/resources/org/apache/marmotta/client/test/demo-data.foaf
@@ -0,0 +1,80 @@
+<!--
+ ~ Copyright (c) 2012 Salzburg Research.
+ ~
+ ~ Licensed 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.
+ -->
+
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:skos="http://www.w3.org/2004/02/skos/core#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ >
+
+ <foaf:Person rdf:about="http://localhost:8080/Marmotta/resource/hans_meier" xmlns:foaf="http://xmlns.com/foaf/0.1/">
+ <foaf:name>Hans Meier</foaf:name>
+ <dc:description>Hans Meier is a software engineer living in Salzburg</dc:description>
+ <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.software_engineering"/>
+ <foaf:interest rdf:resource="http://rdf.freebase.com/ns/en.linux"/>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Java" />
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
+ <foaf:based_near rdf:resource="http://sws.geonames.org/2766824/"/>
+ <foaf:depiction rdf:resource="http://localhost:8080/Marmotta/resource/hans_meier.jpg"/>
+
+ <foaf:knows rdf:resource="http://bblfish.net/people/henry/card#me" />
+ <foaf:knows rdf:resource="http://dbpedia.org/resource/James_Gosling"/>
+ </foaf:Person>
+
+ <foaf:Person rdf:about="http://localhost:8080/Marmotta/resource/sepp_huber" xmlns:foaf="http://xmlns.com/foaf/0.1/">
+ <foaf:name>Sepp Huber</foaf:name>
+ <dc:description>Sepp Huber is an alpinist living in Traunstein. He is a good climber, but not as famous as his cousin Alexander Huber.</dc:description>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Climbing"/>
+ <foaf:interest rdf:resource="http://localhost:8080/Marmotta/resource/Chess" />
+ <foaf:based_near rdf:resource="http://dbpedia.org/resource/Traunstein"/>
+
+ <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
+ <foaf:knows rdf:resource="http://localhost:8080/Marmotta/resource/hans_meier" />
+ </foaf:Person>
+
+ <foaf:Person rdf:about="http://localhost:8080/Marmotta/resource/anna_schmidt" xmlns:foaf="http://xmlns.com/foaf/0.1/">
+ <foaf:name>Anna Schmidt</foaf:name>
+ <dc:description>Anna Schmidt is working as PR manager for mountaineers coming from Garmisch-Partenkirchen. She likes mountaineering and is also a Linux enthusiast.</dc:description>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Mountaineering"/>
+ <foaf:interest rdf:resource="http://dbpedia.org/resource/Linux"/>
+ <foaf:interest rdf:resource="http://localhost:8080/Marmotta/resource/Chess" />
+ <foaf:based_near rdf:resource="http://dbpedia.org/resource/Garmisch-Partenkirchen"/>
+ <foaf:depiction rdf:resource="http://localhost:8080/Marmotta/resource/anna_schmidt.jpg"/>
+
+ <foaf:knows rdf:resource="http://dbpedia.org/resource/Alexander_Huber" />
+ <foaf:knows rdf:resource="http://localhost:8080/Marmotta/resource/sepp_huber" />
+ </foaf:Person>
+
+ <skos:Concept rdf:about="http://rdf.freebase.com/ns/en.linux">
+ <rdfs:label>GNU/Linux</rdfs:label>
+ </skos:Concept>
+
+ <skos:Concept rdf:about="http://rdf.freebase.com/ns/en.software_engineering">
+ <rdfs:label>Software Engineering</rdfs:label>
+ </skos:Concept>
+
+ <skos:Concept rdf:about="http://dbpedia.org/resource/Java">
+ <rdfs:label>Java</rdfs:label>
+ </skos:Concept>
+
+ <skos:Concept rdf:about="http://dbpedia.org/resource/Climbing">
+ <rdfs:label>Climbing</rdfs:label>
+ </skos:Concept>
+
+</rdf:RDF>