marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject [09/17] git commit: Added Unit-Test for MARMOTTA-525
Date Wed, 10 Sep 2014 09:39:00 GMT
Added Unit-Test for MARMOTTA-525


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

Branch: refs/heads/ldp
Commit: dd701b9b82ab01940202cda9a5a17822028889e1
Parents: 652ab44
Author: Jakob Frank <jakob@apache.org>
Authored: Fri Sep 5 10:21:18 2014 +0200
Committer: Jakob Frank <jakob@apache.org>
Committed: Fri Sep 5 10:22:47 2014 +0200

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


http://git-wip-us.apache.org/repos/asf/marmotta/blob/dd701b9b/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 8053e46..c5f5d92 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
@@ -418,4 +418,81 @@ public class LdpWebServiceTest {
             .get(resource);
     }
 
+    /**
+     * Test for <a href="https://issues.apache.org/jira/browse/MARMOTTA-525">MARMOTTA-525</a>
+     */
+    @Test
+    public void testMARMOTTA_525() {
+        final String testBase = "MARMOTTA_525";
+        final String containerName = "c1";
+        final String resourceName = "r1";
+
+        // 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 = RDFFormat.TURTLE.getDefaultMIMEType();
+
+        RestAssured.expect().statusCode(404).get(container);
+
+        // Create
+        RestAssured
+            .given()
+                .header("Slug", resourceName)
+                .body(testResourceTTL.getBytes())
+                .contentType(mimeType)
+            .expect()
+                .statusCode(201)
+                .header("Location", baseUrl + newResource)
+            .post(container);
+
+        // now the container hasType
+        log.info("200 - container");
+        RestAssured
+            .expect()
+                .statusCode(200)
+                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                                HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"),
+                                HeaderMatchers.isLink(LDP.BasicContainer.stringValue(), "type"))
+                )
+                .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific
here
+                .contentType(mimeType)
+                .body(SesameMatchers.rdfStringMatches(mimeType, baseUrl+container,
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), DCTERMS.MODIFIED,
null),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + container), RDF.TYPE,
LDP.BasicContainer)
+                ))
+            .get(container);
+
+        // also the new resource hasType
+        RestAssured
+            .expect()
+                .statusCode(200)
+                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                                HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"),
+                                HeaderMatchers.isLink(LDP.Resource.stringValue(), "type"))
+                )
+                .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific
here
+                .contentType(mimeType)
+                .body(SesameMatchers.rdfStringMatches(mimeType, baseUrl + container,
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), DCTERMS.MODIFIED,
null),
+                        SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), RDF.TYPE,
LDP.Resource)
+                ))
+            .get(newResource);
+
+        // delete
+        RestAssured
+            .expect()
+                .statusCode(204)
+                .header("Link", HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"))
+                .header("ETag", HeaderMatchers.headerNotPresent())
+                .header("Last-Modified", HeaderMatchers.headerNotPresent())
+            .delete(newResource);
+
+        // now the new resource does not exist.
+        RestAssured
+            .expect()
+                .statusCode(404)
+            .get(newResource);
+
+    }
+
 }


Mime
View raw message