marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject git commit: Some refactoring in the unit-tests
Date Thu, 11 Sep 2014 16:21:18 GMT
Repository: marmotta
Updated Branches:
  refs/heads/ldp 97778349b -> aecd4ae21


Some refactoring in the unit-tests

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

Branch: refs/heads/ldp
Commit: aecd4ae215aa8587e3364a9026dac5fedf59a3b6
Parents: 9777834
Author: Jakob Frank <jakob@apache.org>
Authored: Thu Sep 11 18:20:49 2014 +0200
Committer: Jakob Frank <jakob@apache.org>
Committed: Thu Sep 11 18:20:49 2014 +0200

----------------------------------------------------------------------
 .../platform/ldp/webservices/LdpWebService.java |  16 ++-
 .../marmotta/platform/ldp/LdpSuiteTest.java     |  89 --------------
 .../platform/ldp/webservices/LdpSuiteTest.java  | 122 +++++++++++++++++++
 .../ldp/webservices/LdpWebServiceTest.java      |  80 ++++++------
 4 files changed, 175 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/aecd4ae2/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
index a6448f6..bec9b89 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
@@ -70,7 +70,7 @@ import java.util.UUID;
 public class LdpWebService {
 
     public static final String PATH = "/ldp"; //TODO: at some point this will be root ('/')
in marmotta
-    public static final String LDP_SERVER_CONSTRAINTS = "https://wiki.apache.org/marmotta/LDPImplementationReport/2014-03-11";
+    public static final String LDP_SERVER_CONSTRAINTS = "http://wiki.apache.org/marmotta/LDPImplementationReport/2014-03-11";
 
     private Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());
 
@@ -475,7 +475,7 @@ public class LdpWebService {
                 }
 
                 newResource = ldpService.updateResource(conn, resource, postBody, mimeType);
-                log.info("PUT update for <{}> successful", newResource);
+                log.debug("PUT update for <{}> successful", newResource);
                 resp = createResponse(conn, Response.Status.OK, resource);
                 conn.commit();
                 return resp.build();
@@ -639,7 +639,17 @@ public class LdpWebService {
         try {
             con.begin();
 
-            log.warn("NOT CHECKING EXISTENCE OF <{}>", resource);
+            if (!ldpService.exists(con, resource)) {
+                final Response.ResponseBuilder resp;
+                if (ldpService.isReusedURI(con, resource)) {
+                    resp = createResponse(con, Response.Status.GONE, resource);
+                } else {
+                    resp = createResponse(con, Response.Status.NOT_FOUND, resource);
+                }
+                con.rollback();
+                return resp.build();
+            }
+
 
             Response.ResponseBuilder builder = createResponse(con, Response.Status.OK, resource);
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aecd4ae2/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/LdpSuiteTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/LdpSuiteTest.java
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/LdpSuiteTest.java
deleted file mode 100644
index 8ef68b6..0000000
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/LdpSuiteTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.marmotta.platform.ldp;
-
-import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
-import org.apache.marmotta.platform.ldp.webservices.LdpWebService;
-import org.junit.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3.ldp.testsuite.LdpTestSuite;
-
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * LDP Test Suite runner, see <a href="https://github.com/w3c/ldp-testsuite">https://github.com/w3c/ldp-testsuite</a>.
- *
- * @author Sergio Fernández
- * @author Jakob Frank
- */
-public class LdpSuiteTest {
-
-    /** @see org.testng.TestNG#HAS_FAILURE */
-    private static final int TESTNG_STATUS_HAS_FAILURE = 1;
-    /** @see org.testng.TestNG#HAS_NO_TEST */
-    private static final int TESTNG_STATUS_HAS_NO_TEST = 8;
-
-    private static Logger log = LoggerFactory.getLogger(LdpSuiteTest.class);
-
-    private static JettyMarmotta marmotta;
-
-    private static String baseUrl;
-
-    private LdpTestSuite testSuite;
-
-    @BeforeClass
-    public static void setup() throws URISyntaxException, IOException {
-        marmotta = new JettyMarmotta("/marmotta", LdpWebService.class);
-        baseUrl = UriBuilder.fromUri("http://localhost").port(marmotta.getPort()).path(marmotta.getContext()).build().toString();
-    }
-
-    @AfterClass
-    public static void shutdown() {
-        marmotta.shutdown();
-        marmotta = null;
-    }
-
-    @Before
-    public void before() {
-        log.info("Running W3C official LDP Test Suite against '{}' server", baseUrl);
-        System.out.println("Running ldp-testsuite against " + baseUrl);
-        Map<String, String> options = new HashMap<>();
-        options.put("server", baseUrl + "/ldp");
-        options.put("basic", null);
-        options.put("non-rdf", null);
-        testSuite = new LdpTestSuite(options);
-    }
-
-    @After
-    public void after() {
-        testSuite = null;
-    }
-
-    @Test
-    public void testRunSuite() {
-        testSuite.run();
-        Assert.assertTrue("ldp-testsuite finished with errors", (testSuite.getStatus() &
TESTNG_STATUS_HAS_FAILURE) == 0);
-        Assert.assertTrue("ldp-testsuite is empty - no test run", (testSuite.getStatus()
& TESTNG_STATUS_HAS_NO_TEST) == 0);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aecd4ae2/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpSuiteTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpSuiteTest.java
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpSuiteTest.java
new file mode 100644
index 0000000..e501d29
--- /dev/null
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpSuiteTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+package org.apache.marmotta.platform.ldp.webservices;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.platform.core.api.triplestore.SesameService;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.apache.marmotta.platform.ldp.api.LdpService;
+import org.junit.*;
+import org.junit.experimental.categories.Categories;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3.ldp.testsuite.LdpTestSuite;
+
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * LDP Test Suite runner, see <a href="https://github.com/w3c/ldp-testsuite">https://github.com/w3c/ldp-testsuite</a>.
+ *
+ * @author Sergio Fernández
+ * @author Jakob Frank
+ */
+public class LdpSuiteTest {
+
+    /** @see org.testng.TestNG#HAS_FAILURE */
+    private static final int TESTNG_STATUS_HAS_FAILURE = 1;
+    /** @see org.testng.TestNG#HAS_NO_TEST */
+    private static final int TESTNG_STATUS_HAS_NO_TEST = 8;
+
+    private static Logger log = LoggerFactory.getLogger(LdpSuiteTest.class);
+
+    private static JettyMarmotta marmotta;
+
+    private static String baseUrl;
+
+    private LdpTestSuite testSuite;
+
+    @BeforeClass
+    public static void setup() throws URISyntaxException, IOException {
+        marmotta = new JettyMarmotta("/marmotta", LdpWebService.class);
+        baseUrl = UriBuilder.fromUri("http://localhost").port(marmotta.getPort()).path(marmotta.getContext()).path(LdpWebService.PATH).build().toString();
+    }
+
+    @AfterClass
+    public static void shutdown() {
+        marmotta.shutdown();
+        marmotta = null;
+    }
+
+    @Before
+    public void before() throws RepositoryException, IOException, RDFParseException {
+
+        log.debug("Performing required LDP re-initialization...");
+        final SesameService sesameService = marmotta.getService(SesameService.class);
+        final  LdpService ldpService = marmotta.getService(LdpService.class);
+        final RepositoryConnection conn = sesameService.getConnection();
+        try {
+            conn.begin();
+
+            final String container = ldpService.addResource(conn, baseUrl,
+                    UriBuilder.fromUri(baseUrl).path(UUID.randomUUID().toString()).build().toString(),
+                    LdpService.InteractionModel.LDPC, RDFFormat.TURTLE.getDefaultMIMEType(),
+                    IOUtils.toInputStream("<> a <http://example.com/ldp/ContainerInteraction>
. "));
+            final String resource = ldpService.addResource(conn, baseUrl,
+                    UriBuilder.fromUri(baseUrl).path(UUID.randomUUID().toString()).build().toString(),
+                    LdpService.InteractionModel.LDPR, RDFFormat.TURTLE.getDefaultMIMEType(),
+                    IOUtils.toInputStream("<> a <http://example.com/ldp/ResourceInteraction>
. "));
+            conn.commit();
+
+            log.info("Running W3C official LDP Test Suite against '{}' server", container);
+            Map<String, String> options = new HashMap<>();
+            options.put("server", container);
+            options.put("basic", null);
+            options.put("non-rdf", null);
+            options.put("cont-res", resource);
+            if (!LdpService.SERVER_MANAGED_PROPERTIES.isEmpty()) {
+                options.put("read-only-prop", LdpService.SERVER_MANAGED_PROPERTIES.iterator().next().stringValue());
+            }
+            options.put("excludedGroups", "MANUAL");
+            testSuite = new LdpTestSuite(options);
+        } finally {
+            conn.close();
+        }
+    }
+
+    @After
+    public void after() {
+        testSuite = null;
+    }
+
+    @Test
+    public void testRunSuite() {
+        testSuite.run();
+        Assert.assertTrue("ldp-testsuite finished with errors", (testSuite.getStatus() &
TESTNG_STATUS_HAS_FAILURE) == 0);
+        Assert.assertTrue("ldp-testsuite is empty - no test run", (testSuite.getStatus()
& TESTNG_STATUS_HAS_NO_TEST) == 0);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aecd4ae2/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 287a173..e8e4e6e 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
@@ -112,14 +112,14 @@ public class LdpWebServiceTest {
         log.info("200 - container");
         RestAssured
             .given()
-                .header("Accept", mimeType)
+                .header(HttpHeaders.ACCEPT, mimeType)
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.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
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(true)) // FIXME: be
more specific here
                 .contentType(mimeType)
                 .body(SesameMatchers.rdfStringMatches(mimeType, container,
                         SesameMatchers.hasStatement(new URIImpl(container), DCTERMS.MODIFIED,
null),
@@ -130,14 +130,14 @@ public class LdpWebServiceTest {
         // also the new resource hasType
         RestAssured
             .given()
-                .header("Accept", mimeType)
+                .header(HttpHeaders.ACCEPT, mimeType)
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.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
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(true)) // FIXME: be
more specific here
                 .contentType(mimeType)
                 .body(SesameMatchers.rdfStringMatches(mimeType, container,
                         SesameMatchers.hasStatement(new URIImpl(newResource), DCTERMS.MODIFIED,
null),
@@ -149,15 +149,15 @@ public class LdpWebServiceTest {
         RestAssured
             .expect()
                 .statusCode(204)
-                .header("Link", HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"))
-                .header("ETag", HeaderMatchers.headerNotPresent())
-                .header("Last-Modified", HeaderMatchers.headerNotPresent())
+                .header(HttpHeaders.LINK, HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"))
+                .header(HttpHeaders.ETAG, HeaderMatchers.headerNotPresent())
+                .header(HttpHeaders.LAST_MODIFIED, HeaderMatchers.headerNotPresent())
             .delete(newResource);
 
         // now the new resource does not exist any more.
         RestAssured
             .given()
-                .header("Accept", mimeType)
+                .header(HttpHeaders.ACCEPT, mimeType)
             .expect()
                 .statusCode(410)
             .get(newResource);
@@ -180,7 +180,7 @@ public class LdpWebServiceTest {
                 .contentType(mimeType)
             .expect()
                 .statusCode(201)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.LINK, CoreMatchers.anyOf( //TODO: RestAssured only checks
the FIRST header...
                         //  HeaderMatchers.isLink(metaResource, "describedby"),
                         HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS, "describedby"),
                         HeaderMatchers.isLink(LDP.BasicContainer.stringValue(), "type"))
@@ -195,14 +195,14 @@ public class LdpWebServiceTest {
         // now the container hasType
         RestAssured
             .given()
-                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+                .header(HttpHeaders.ACCEPT, RDFFormat.TURTLE.getDefaultMIMEType())
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.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
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(true)) // FIXME: be
more specific here
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(),
container,
                         SesameMatchers.hasStatement(new URIImpl(container), RDF.TYPE, LDP.Resource),
@@ -218,15 +218,15 @@ public class LdpWebServiceTest {
         // now the resource hasType
         RestAssured
             .given()
-                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+                .header(HttpHeaders.ACCEPT, RDFFormat.TURTLE.getDefaultMIMEType())
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.LINK, CoreMatchers.anyOf( //TODO: RestAssured only checks
the FIRST header...
                         HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS, "describedby"),
                         HeaderMatchers.isLink(LDP.Resource.stringValue(), "type"),
                         HeaderMatchers.isLink(LDP.RDFSource.stringValue(), "type"))
                 )
-                .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific
here
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(true)) // FIXME: be
more specific here
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(),
metaResource,
                         SesameMatchers.hasStatement(new URIImpl(metaResource), RDF.TYPE,
LDP.Resource),
@@ -239,15 +239,15 @@ public class LdpWebServiceTest {
         // now the resource hasType
         RestAssured
             .given()
-                .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+                .header(HttpHeaders.ACCEPT, RDFFormat.TURTLE.getDefaultMIMEType())
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.LINK, CoreMatchers.anyOf( //TODO: RestAssured only checks
the FIRST header...
                         HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS, "describedby"),
                         HeaderMatchers.isLink(LDP.Resource.stringValue(), "type"),
                         HeaderMatchers.isLink(LDP.NonRDFSource.stringValue(), "type"))
                 )
-                .header("ETag", HeaderMatchers.hasEntityTag(false)) // FIXME: be more specific
here
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(false)) // FIXME: be
more specific here
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(),
binaryResource,
                         SesameMatchers.hasStatement(new URIImpl(binaryResource), RDF.TYPE,
LDP.Resource),
@@ -262,15 +262,15 @@ public class LdpWebServiceTest {
         final String expectedMD5 = HashUtils.md5sum(LdpWebServiceTest.class.getResourceAsStream("/test.png"));
         final byte[] data = RestAssured
             .given()
-                .header("Accept", mimeType)
+                .header(HttpHeaders.ACCEPT, mimeType)
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.LINK, CoreMatchers.anyOf( //TODO: RestAssured only checks
the FIRST header...
                         HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS, "describedby"),
                         HeaderMatchers.isLink(LDP.Resource.stringValue(), "type"),
                         HeaderMatchers.isLink(LDP.RDFSource.stringValue(), "type"))
                 )
-                .header("ETag", HeaderMatchers.hasEntityTag(false)) // FIXME: be more specific
here
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(false)) // FIXME: be
more specific here
                 .contentType(mimeType)
             .get(binaryResource)
                 .body().asByteArray();
@@ -285,7 +285,7 @@ public class LdpWebServiceTest {
         // Try LDPR
         final String ldpr = RestAssured
             .given()
-                .header("Link", Link.fromUri(LDP.Resource.stringValue()).rel("type").build().toString())
+                .header(HttpHeaders.LINK, Link.fromUri(LDP.Resource.stringValue()).rel("type").build().toString())
                 .body(testResourceTTL.getBytes())
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
             .expect()
@@ -305,7 +305,7 @@ public class LdpWebServiceTest {
         // Try an invalid interaction model
         RestAssured
             .given()
-                .header("Link", Link.fromUri(baseUrl).rel("type").build().toString())
+                .header(HttpHeaders.LINK, Link.fromUri(container).rel("type").build().toString())
                 .body(testResourceTTL.getBytes())
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
             .expect()
@@ -336,7 +336,7 @@ public class LdpWebServiceTest {
         // Check the data is there
         EntityTag etag = EntityTagUtils.parseEntityTag(RestAssured
             .given()
-                .header("Accept", RDFFormat.RDFXML.getDefaultMIMEType())
+                .header(HttpHeaders.ACCEPT, RDFFormat.RDFXML.getDefaultMIMEType())
             .expect()
                 .contentType(RDFFormat.RDFXML.getDefaultMIMEType())
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.RDFXML, resource,
@@ -360,7 +360,7 @@ public class LdpWebServiceTest {
         // Try a Put with wrong if-match header
         RestAssured
             .given()
-                .header("If-Match", new EntityTag("invalid").toString())
+                .header(HttpHeaders.IF_MATCH, new EntityTag("invalid").toString())
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
                 .body(put_valid.getBytes())
             .expect()
@@ -370,7 +370,7 @@ public class LdpWebServiceTest {
         // Try a Put
         RestAssured
             .given()
-                .header("If-Match", etag.toString())
+                .header(HttpHeaders.IF_MATCH, etag.toString())
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
                 .body(put_valid.getBytes())
             .expect()
@@ -380,7 +380,7 @@ public class LdpWebServiceTest {
         // Check the new data is there
         etag = EntityTagUtils.parseEntityTag(RestAssured
             .given()
-                .header("Accept", RDFFormat.RDFXML.getDefaultMIMEType())
+                .header(HttpHeaders.ACCEPT, RDFFormat.RDFXML.getDefaultMIMEType())
             .expect()
                 .contentType(RDFFormat.RDFXML.getDefaultMIMEType())
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.RDFXML, resource,
@@ -389,13 +389,13 @@ public class LdpWebServiceTest {
                         CoreMatchers.not(SesameMatchers.hasStatement(uri, LDP.contains, uri))
                 ))
             .get(resource)
-                .header("ETag"));
+                .header(HttpHeaders.ETAG));
 
         // Try an invalid PUT (server-controlled property)
         // Try a Put
         RestAssured
             .given()
-                .header("If-Match", etag.toString())
+                .header(HttpHeaders.IF_MATCH, etag.toString())
                 .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
                 .body(put_invalid.getBytes())
             .expect()
@@ -405,10 +405,10 @@ public class LdpWebServiceTest {
         // Check the data is still there
         RestAssured
             .given()
-                .header("Accept", RDFFormat.RDFXML.getDefaultMIMEType())
+                .header(HttpHeaders.ACCEPT, RDFFormat.RDFXML.getDefaultMIMEType())
             .expect()
                 .contentType(RDFFormat.RDFXML.getDefaultMIMEType())
-                .header("ETag", HeaderMatchers.hasEntityTag(etag))
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(etag))
                 .body(SesameMatchers.rdfStringMatches(RDFFormat.RDFXML, resource,
                         SesameMatchers.hasStatement(uri, RDF.TYPE, new URIImpl("http://example.com/Example")),
                         SesameMatchers.hasStatement(uri, RDFS.LABEL, null),
@@ -461,11 +461,11 @@ public class LdpWebServiceTest {
         RestAssured
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.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
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(true)) // FIXME: be
more specific here
                 .contentType(mimeType)
                 .body(SesameMatchers.rdfStringMatches(mimeType, container,
                         SesameMatchers.hasStatement(new URIImpl(container), DCTERMS.MODIFIED,
null),
@@ -477,11 +477,11 @@ public class LdpWebServiceTest {
         RestAssured
             .expect()
                 .statusCode(200)
-                .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIRST
header...
+                .header(HttpHeaders.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
+                .header(HttpHeaders.ETAG, HeaderMatchers.hasEntityTag(true)) // FIXME: be
more specific here
                 .contentType(mimeType)
                 .body(SesameMatchers.rdfStringMatches(mimeType, container,
                         SesameMatchers.hasStatement(new URIImpl(newResource), DCTERMS.MODIFIED,
null),
@@ -493,9 +493,9 @@ public class LdpWebServiceTest {
         RestAssured
             .expect()
                 .statusCode(204)
-                .header("Link", HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"))
-                .header("ETag", HeaderMatchers.headerNotPresent())
-                .header("Last-Modified", HeaderMatchers.headerNotPresent())
+                .header(HttpHeaders.LINK, HeaderMatchers.isLink(LdpWebService.LDP_SERVER_CONSTRAINTS,
"describedby"))
+                .header(HttpHeaders.ETAG, HeaderMatchers.headerNotPresent())
+                .header(HttpHeaders.LAST_MODIFIED, HeaderMatchers.headerNotPresent())
             .delete(newResource);
 
         // now the new resource does not exist.


Mime
View raw message