You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2014/02/27 13:37:53 UTC
[2/3] git commit: MARMOTTA-440: refacotrized test
MARMOTTA-440: refacotrized test
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/66a7f5b8
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/66a7f5b8
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/66a7f5b8
Branch: refs/heads/ldp
Commit: 66a7f5b83d0e56bf80782163b8067105265b3c7c
Parents: 283444f
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Feb 27 13:23:55 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Feb 27 13:23:55 2014 +0100
----------------------------------------------------------------------
.../platform/ldp/webservices/LdpWebService.java | 2 +-
.../ldp/webservices/LdpWebServiceTest.java | 68 ++++++++++++--------
2 files changed, 43 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/66a7f5b8/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 b6e33e8..e176e21 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
@@ -62,7 +62,7 @@ import java.util.*;
@Path(LdpWebService.PATH + "{local:.*}")
public class LdpWebService {
- public static final String PATH = "ldp"; //FIXME: imho this should be root '/' (jakob)
+ public static final String PATH = "/ldp"; //FIXME: imho this should be root '/' (jakob)
private Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());
http://git-wip-us.apache.org/repos/asf/marmotta/blob/66a7f5b8/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 27a693a..b329f2b 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
@@ -28,83 +28,99 @@ import org.openrdf.rio.RDFFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.net.URISyntaxException;
/**
- * Tests for testing the LDP web services
- *
- * @author Sergio Fernández
+ * Testing LDP web services
*
+ * @author Sergio Fernández
+ * @author Jakob Frank
*/
public class LdpWebServiceTest {
- private static Logger log = LoggerFactory.getLogger(LdpWebServiceTest.class);
-
+ private static Logger log = LoggerFactory.getLogger(LdpWebServiceTest.class);
+
private static JettyMarmotta marmotta;
+ private static String baseUrl;
+
private static String testResourceTTL;
@BeforeClass
- public static void setUp() throws MarmottaImportException, URISyntaxException, IOException {
+ 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();
RestAssured.basePath = marmotta.getContext();
+ baseUrl = UriBuilder.fromUri("http://localhost").port(marmotta.getPort()).path(marmotta.getContext()).build().toString();
+ //initialization
+ testResourceTTL = IOUtils.toString(LdpWebServiceTest.class.getResourceAsStream("/test.ttl"), "utf8");
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ marmotta.shutdown();
+ testResourceTTL = null;
}
@Test
public void testCRUD() {
+ final String testBase = "test1";
+ final String containerName = "container1";
+ final String resourceName = "resource1";
+
// The container
- final String container = "/ldp/test/container1";
- final String newResourceUri = container + "/resource1";
+ final String container = UriBuilder.fromPath(LdpWebService.PATH).path(testBase).path(containerName).build().toString();
+ final String newResource = UriBuilder.fromUri(container).path(resourceName).build().toString();
RestAssured.expect().statusCode(404).get(container);
// Create
RestAssured
.given()
- .header("Slug", "resource1")
+ .header("Slug", resourceName)
.body(testResourceTTL.getBytes())
.contentType(RDFFormat.TURTLE.getDefaultMIMEType())
.expect()
.statusCode(201)
- .header("Location", RestAssured.baseURI + newResourceUri)
- .post(container);
+ .header("Location", baseUrl + newResource)
+ .post(container);
// now the container exists
log.info("200 - container");
- RestAssured.given()
+ RestAssured
+ .given()
.header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
- .expect()
+ .expect()
.statusCode(200)
.contentType(RDFFormat.TURTLE.getDefaultMIMEType())
- .get(container);
+ .get(container);
// also the new resource exists
- RestAssured.given()
+ RestAssured
+ .given()
.header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
- .expect()
+ .expect()
.statusCode(200)
.contentType(RDFFormat.TURTLE.getDefaultMIMEType())
- .get(newResourceUri);
+ .get(newResource);
// delete
- RestAssured.expect()
+ RestAssured
+ .expect()
.statusCode(204)
- .delete(newResourceUri);
+ .delete(newResource);
// now the new resource does not exist.
- RestAssured.given()
+ RestAssured
+ .given()
.header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
- .expect()
+ .expect()
.statusCode(404)
- .get(newResourceUri);
+ .get(newResource);
}