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 2014/09/10 11:39:03 UTC

[12/17] git commit: Improved ldp unit-tests

Improved ldp unit-tests

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

Branch: refs/heads/ldp
Commit: 4595f0c0d8581267e5d8742faf948ec4a9cabd4a
Parents: 30227f3
Author: Jakob Frank <ja...@apache.org>
Authored: Sun Sep 7 16:26:02 2014 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Sun Sep 7 16:26:02 2014 +0200

----------------------------------------------------------------------
 .../ldp/webservices/LdpWebServiceTest.java      | 29 ++++++++++----------
 1 file changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/4595f0c0/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 0c4891c..418346f 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
@@ -42,6 +42,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.core.EntityTag;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Link;
 import javax.ws.rs.core.UriBuilder;
 import java.io.IOException;
@@ -92,21 +93,20 @@ public class LdpWebServiceTest {
 
         // 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
+        final String newResource = RestAssured
             .given()
                 .header("Slug", resourceName)
                 .body(testResourceTTL.getBytes())
                 .contentType(mimeType)
             .expect()
                 .statusCode(201)
-                .header("Location", baseUrl + newResource)
-            .post(container);
+            .post(container)
+                .header(HttpHeaders.LOCATION);
 
         // now the container hasType
         log.info("200 - container");
@@ -140,8 +140,8 @@ public class LdpWebServiceTest {
                 .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)
+                        SesameMatchers.hasStatement(new URIImpl(newResource), DCTERMS.MODIFIED, null),
+                        SesameMatchers.hasStatement(new URIImpl(newResource), RDF.TYPE, LDP.Resource)
                 ))
             .get(newResource);
 
@@ -336,16 +336,16 @@ public class LdpWebServiceTest {
 
         // Check the data is there
         EntityTag etag = EntityTagUtils.parseEntityTag(RestAssured
-                .given()
+            .given()
                 .header("Accept", RDFFormat.RDFXML.getDefaultMIMEType())
-                .expect()
+            .expect()
                 .contentType(RDFFormat.RDFXML.getDefaultMIMEType())
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.RDFXML, resource,
                         SesameMatchers.hasStatement(uri, RDF.TYPE, new URIImpl("http://example.com/Example")),
                         CoreMatchers.not(SesameMatchers.hasStatement(uri, RDFS.LABEL, null)),
                         CoreMatchers.not(SesameMatchers.hasStatement(uri, LDP.contains, uri))
                 ))
-                .get(resource)
+            .get(resource)
                 .getHeader("ETag"));
         log.debug("ETag for <{}>: {}", resource, etag);
 
@@ -429,21 +429,20 @@ public class LdpWebServiceTest {
 
         // 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
+        final String newResource = RestAssured
             .given()
                 .header("Slug", resourceName)
                 .body(testResourceTTL.getBytes())
                 .contentType(mimeType)
             .expect()
                 .statusCode(201)
-                .header("Location", baseUrl + newResource)
-            .post(container);
+            .post(container)
+                .header(HttpHeaders.LOCATION);
 
         // now the container hasType
         log.info("200 - container");
@@ -473,8 +472,8 @@ public class LdpWebServiceTest {
                 .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)
+                        SesameMatchers.hasStatement(new URIImpl(newResource), DCTERMS.MODIFIED, null),
+                        SesameMatchers.hasStatement(new URIImpl(newResource), RDF.TYPE, LDP.Resource)
                 ))
             .get(newResource);