marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject [17/50] [abbrv] git commit: MARMOTTA-449: added some LDP-NR testing
Date Fri, 04 Apr 2014 09:30:14 GMT
MARMOTTA-449: added some LDP-NR testing


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

Branch: refs/heads/develop
Commit: 83209635c184ceec2003efed230cb5a0ecd48ccd
Parents: 2f3fbdd
Author: Sergio Fernández <wikier@apache.org>
Authored: Thu Mar 6 16:47:00 2014 +0100
Committer: Sergio Fernández <wikier@apache.org>
Committed: Thu Mar 6 16:47:00 2014 +0100

----------------------------------------------------------------------
 .../ldp/webservices/LdpWebServiceTest.java      | 77 +++++++++++++++++++-
 1 file changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/83209635/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 4883e8b..f1e6751 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
@@ -76,7 +76,7 @@ public class LdpWebServiceTest {
 
     @Test
     public void testCRUD() {
-        final String testBase = "test1";
+        final String testBase = "test";
         final String containerName = "container1";
         final String resourceName = "resource1";
 
@@ -115,7 +115,7 @@ public class LdpWebServiceTest {
                         SesameMatchers.hasStatement(new URIImpl(baseUrl + container), DCTERMS.MODIFIED,
null),
                         SesameMatchers.hasStatement(new URIImpl(baseUrl + container), RDF.TYPE,
LDP.BasicContainer)
                 ))
-                .get(container);
+            .get(container);
 
         // also the new resource exists
         RestAssured
@@ -154,7 +154,78 @@ public class LdpWebServiceTest {
 
     }
 
-    @AfterClass
+    @Test
+    public void testNR() throws IOException {
+        final String testBase = "test";
+        final String containerName = "container2";
+        final String resourceName = "resource1";
+
+        // The container
+        final String container = UriBuilder.fromPath(LdpWebService.PATH).path(testBase).path(containerName).build().toString();
+        final String newResource = UriBuilder.fromUri(container).path(resourceName).build().toString();
+        final String mimeType = "image/png";
+
+        RestAssured.expect().statusCode(404).get(container);
+
+        // Create
+        RestAssured
+            .given()
+                .header("Slug", resourceName)
+                .body(IOUtils.toByteArray(LdpWebServiceTest.class.getResourceAsStream("/test.png")))
+                .contentType(mimeType)
+            .expect()
+                .statusCode(201)
+                .header("Location", baseUrl + newResource + ".png")
+                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIST
header...
+                        HeaderMatchers.isLink(baseUrl + newResource, "describedby"),
+                        HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport",
"describedby"),
+                        HeaderMatchers.isLink(LDP.BasicContainer.stringValue(), "type"))
+                )
+            .post(container);
+
+        // now the container exists
+        RestAssured
+            .given()
+                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+            .expect()
+                .statusCode(200)
+                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIST
header...
+                        HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport",
"describedby"),
+                        HeaderMatchers.isLink(LDP.BasicContainer.stringValue(), "type"))
+                )
+                .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific
here
+                .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+                .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(),
baseUrl + container,
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), RDF.TYPE,
LDP.BasicContainer),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), DCTERMS.MODIFIED,
null),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), LDP.contains,
new URIImpl(baseUrl + newResource))
+                ))
+            .get(container);
+
+
+        // now the resource exists
+        RestAssured
+            .given()
+                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+            .expect()
+                .statusCode(200)
+                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIST
header...
+                        HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport",
"describedby"),
+                        HeaderMatchers.isLink(LDP.Resource.stringValue(), "type"),
+                        HeaderMatchers.isLink(LDP.NonRdfResource.stringValue(), "type"))
+                )
+                .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific
here
+                .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+                .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(),
baseUrl + newResource,
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), RDF.TYPE,
LDP.Resource),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), RDF.TYPE,
LDP.NonRdfResource),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), DCTERMS.MODIFIED,
null),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), DCTERMS.HAS_FORMAT,
new URIImpl(baseUrl + newResource + ".png"))
+                ))
+            .get(newResource);
+    }
+
+   @AfterClass
     public static void tearDown() {
         marmotta.shutdown();
     }


Mime
View raw message