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 2017/06/09 09:18:23 UTC

[03/11] marmotta git commit: MARMOTTA-534: applied some TDD for helping to find the root cause of the issue

MARMOTTA-534: applied some TDD for helping to find the root cause of the issue


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

Branch: refs/heads/develop
Commit: 958a79ee161430be8eb499b9f783f79c052c0f2c
Parents: 0b13c66
Author: Sergio Fernández <wi...@apache.org>
Authored: Wed May 10 09:50:19 2017 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Wed May 10 10:00:32 2017 +0200

----------------------------------------------------------------------
 platform/marmotta-user/pom.xml                  | 57 ++++++++++++++++++++
 .../user/webservices/UserWebService.java        |  4 +-
 .../user/webservices/UserWebServiceTest.java    | 52 ++++++++++++++++++
 3 files changed, 111 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/958a79ee/platform/marmotta-user/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/pom.xml b/platform/marmotta-user/pom.xml
index f519650..573cd61 100644
--- a/platform/marmotta-user/pom.xml
+++ b/platform/marmotta-user/pom.xml
@@ -157,5 +157,62 @@
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
         </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>marmotta-core</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+            <version>${jetty.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+            <version>${jetty.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>javax.el-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.restassured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/958a79ee/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
index 730b54c..63d4c22 100644
--- a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
+++ b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
@@ -263,8 +263,8 @@ public class UserWebService {
     }
 
     /**
-     * Throws a {@link AccessDeniedException} if currently no user is logged in (aka: current user
-     * is anonymous).
+     * Throws a {@link AccessDeniedException} if currently no user is logged in
+     * (aka: current user is anonymous).
      *
      * @param ref the referer to redirect to
      * @param logout set to true to log out (does currently nothing)

http://git-wip-us.apache.org/repos/asf/marmotta/blob/958a79ee/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java
new file mode 100644
index 0000000..a55055d
--- /dev/null
+++ b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java
@@ -0,0 +1,52 @@
+package org.apache.marmotta.platform.user.webservices;
+
+import com.jayway.restassured.RestAssured;
+import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import static com.jayway.restassured.RestAssured.expect;
+
+/**
+ * UserWebService Test
+ *
+ * @author Sergio Fernández
+ */
+public class UserWebServiceTest {
+
+    private static Logger log = LoggerFactory.getLogger(UserWebServiceTest.class);
+
+    private static JettyMarmotta marmotta;
+
+    @BeforeClass
+    public static void setUp() throws MarmottaImportException, URISyntaxException {
+        marmotta = new JettyMarmotta("/marmotta", UserWebService.class);
+        RestAssured.baseURI = "http://localhost";
+        RestAssured.port = marmotta.getPort();
+        RestAssured.basePath = marmotta.getContext();
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        marmotta.shutdown();
+    }
+
+    @Test
+    public void testLogin() throws IOException, InterruptedException {
+        expect().
+            log().ifError().
+            statusCode(200).
+        given().
+            auth(). preemptive().basic("admin", "pass123").
+        when().
+            get("/user/login");
+    }
+
+}