MARMOTTA-440: Updated LDP-WebService tests (but they do not work...)

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

Branch: refs/heads/ldp
Commit: ca0d8c0aa824960205e0000d05def76fab93cada
Parents: 05e0379
Author: Jakob Frank <[email protected]>
Authored: Tue Feb 25 18:33:41 2014 +0100
Committer: Jakob Frank <[email protected]>
Committed: Tue Feb 25 18:33:41 2014 +0100

----------------------------------------------------------------------
 .../ldp/webservices/LdpWebServiceTest.java      | 53 +++++++++++++++++++-
 .../marmotta-ldp/src/test/resources/test.ttl    | 26 ++++++++++
 2 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/ca0d8c0a/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 3e0a3d6..9016443 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
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
 
+import org.apache.commons.io.IOUtils;
 import org.junit.Assert;
 import org.apache.marmotta.platform.core.api.importer.ImportService;
 import org.apache.marmotta.platform.core.api.triplestore.ContextService;
@@ -30,6 +31,7 @@ import 
org.apache.marmotta.platform.core.test.base.JettyMarmotta;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.openrdf.rio.RDFFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,11 +49,14 @@ public class LdpWebServiceTest {
        
     private static JettyMarmotta marmotta;
 
+    private static String testResourceTTL;
+
     @BeforeClass
-    public static void setUp() throws MarmottaImportException, 
URISyntaxException {
+    public static void setUp() throws MarmottaImportException, 
URISyntaxException, IOException {
         marmotta = new JettyMarmotta("/marmotta", LdpWebService.class);
         
         //TODO: initialization
+        testResourceTTL = 
IOUtils.toString(LdpWebServiceTest.class.getResourceAsStream("/test.ttl"), 
"utf8");
         
         RestAssured.baseURI = "http://localhost";;
         RestAssured.port = marmotta.getPort();
@@ -61,7 +66,51 @@ public class LdpWebServiceTest {
 
     @Test
     public void testCRUD() {
-        
+        // The container
+        final String container = "/lpd/test/container1";
+        final String newResourceUri = container + "/resource1";
+
+        RestAssured.expect().statusCode(404).get(container);
+
+        // Create
+        RestAssured.given()
+                .header("Slug", "resource1")
+                .body(testResourceTTL.getBytes())
+                .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+                .expect()
+                .statusCode(201)
+                .header("Location", RestAssured.baseURI + newResourceUri)
+                .post(container);
+
+        // now the container exists
+        log.info("200 - container");
+        RestAssured.given()
+                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+                .expect()
+                .statusCode(200)
+                .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+                .get(container);
+
+        // also the new resource exists
+        RestAssured.given()
+                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+                .expect()
+                .statusCode(200)
+                .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+                .get(newResourceUri);
+
+        // delete
+        RestAssured.expect()
+                .statusCode(204)
+                .delete(newResourceUri);
+
+        // now the new resource does not exist.
+        RestAssured.given()
+                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+                .expect()
+                .statusCode(404)
+                .get(newResourceUri);
+
     }
 
     @AfterClass

http://git-wip-us.apache.org/repos/asf/marmotta/blob/ca0d8c0a/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
new file mode 100644
index 0000000..bf70c35
--- /dev/null
+++ b/platform/marmotta-ldp/src/test/resources/test.ttl
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+@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/>.
+@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
+@prefix ldp:  <http://www.w3.org/ns/ldp#>.
+
+<> a <http://example.com/Example> ;
+       dct:title "Example"@en , "Beispiel"@de ;
+       dct:description "Just an example"@en .

Reply via email to