TestServlet nach juplo-test verschoben
authorKai Moritz <kai@coolibri.de>
Fri, 23 Dec 2011 16:41:40 +0000 (17:41 +0100)
committerKai Moritz <kai@coolibri.de>
Thu, 2 Aug 2012 07:03:25 +0000 (09:03 +0200)
cachecontrol/pom.xml
cachecontrol/src/test/java/de/halbekunst/juplo/cachecontrol/TestServlet.java [deleted file]
cachecontrol/src/test/resources/web.xml
pom.xml
test/pom.xml
test/src/main/java/de/halbekunst/juplo/test/TestServlet.java [new file with mode: 0644]

index 884bf25..24f2174 100644 (file)
@@ -56,9 +56,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-test</artifactId>
-      <version>${springframework.version}</version>
+      <groupId>${pom.parent.groupId}</groupId>
+      <artifactId>${pom.parent.artifactId}-test</artifactId>
+      <version>${pom.parent.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/cachecontrol/src/test/java/de/halbekunst/juplo/cachecontrol/TestServlet.java b/cachecontrol/src/test/java/de/halbekunst/juplo/cachecontrol/TestServlet.java
deleted file mode 100644 (file)
index cb114fd..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-package de.halbekunst.juplo.cachecontrol;
-
-import java.io.IOException;
-import java.util.Map;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.junit.Ignore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author kai
- */
-@Ignore
-public class TestServlet extends HttpServlet {
-  private final static Logger log = LoggerFactory.getLogger(TestServlet.class);
-
-  private static final String FORWARDED = TestServlet.class.getName() + ".FORWARDED";
-  private static final String INCLUDED = TestServlet.class.getName() + ".INCLUDED";
-
-  @Override
-  protected long getLastModified(HttpServletRequest req) {
-    try {
-      /** Der Reqeust-Parameter "lm" wird als Wert für Last-Modified zurückgegeben */
-      return Long.parseLong(req.getParameter("l"));
-    }
-    catch (Exception e) {
-      return -1l;
-    }
-  }
-
-  @Override
-  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-    /** Angeforderte Header setzen */
-    Map<String, String[]> map = request.getParameterMap();
-    for (String param : map.keySet()) {
-      if (param.equals("n") || param.equals("l") || param.equals("f") || param.equals("i"))
-        continue;
-      /**
-       * Alle Request-Parameter außer die Sonder-Parameter "n" und "lm"
-       * werden als Schlüssel/Wert-Paare für die Antwort-Header interpretiert!
-       */
-      for (String value : map.get(param))
-        response.setHeader(param, value);
-    }
-
-    int n = 0;
-    try {
-      /**
-       * Wenn der Parameter n gesetzt ist, wird ein Antwort-Body erzeugt, der
-       * exakt die Anzahl der geforderten Bytes enthält.
-       */
-      n = Integer.parseInt(request.getParameter("n"));
-    }
-    catch(Exception e) {}
-    log.debug("GET {} bytes: {}", n, request.getRequestURI());
-    ServletOutputStream out = response.getOutputStream();
-    for (int i=0; i<n; i++)
-      out.write(i%2 + 48); /** ASCII-Codes für "0" und "1" */
-
-    if (request.getParameter("i") != null && request.getAttribute(INCLUDED) == null) {
-      for (String include : request.getParameterValues("i")) {
-        RequestDispatcher dispatcher = request.getRequestDispatcher(include);
-        request.setAttribute(INCLUDED, include);
-        dispatcher.include(request, response);
-      }
-    }
-
-    if (request.getParameter("f") != null && request.getAttribute(FORWARDED) == null) {
-      String forward = request.getParameter("f");
-      request.setAttribute(FORWARDED, forward);
-      RequestDispatcher dispatcher = request.getRequestDispatcher(forward);
-      dispatcher.forward(request, response);
-    }
-  }
-}
index 5eee561..4838a1a 100644 (file)
@@ -15,7 +15,7 @@
 
   <servlet>
     <servlet-name>test-servlet</servlet-name>
-    <servlet-class>de.halbekunst.juplo.cachecontrol.TestServlet</servlet-class>
+    <servlet-class>de.halbekunst.juplo.test.TestServlet</servlet-class>
   </servlet>
 
   <servlet-mapping>
diff --git a/pom.xml b/pom.xml
index d9c58c5..4c1bc81 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,7 @@
   </developers>
 
   <modules>
+    <module>test</module>
     <module>cachecontrol</module>
   </modules>
 
index 53dd139..5fc6b1c 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>de.halbekunst</groupId>
     <artifactId>juplo</artifactId>
-    <version>1.0.1</version>
+    <version>2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>${pom.parent.artifactId}-test</artifactId>
       <artifactId>spring-context</artifactId>
       <version>${springframework.version}</version>
     </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>${servlet-api.version}</version>
+      <scope>provided</scope>
+    </dependency>
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
diff --git a/test/src/main/java/de/halbekunst/juplo/test/TestServlet.java b/test/src/main/java/de/halbekunst/juplo/test/TestServlet.java
new file mode 100644 (file)
index 0000000..b2b29f4
--- /dev/null
@@ -0,0 +1,79 @@
+package de.halbekunst.juplo.test;
+
+import java.io.IOException;
+import java.util.Map;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author kai
+ */
+public class TestServlet extends HttpServlet {
+  private final static Logger log = LoggerFactory.getLogger(TestServlet.class);
+
+  private static final String FORWARDED = TestServlet.class.getName() + ".FORWARDED";
+  private static final String INCLUDED = TestServlet.class.getName() + ".INCLUDED";
+
+  @Override
+  protected long getLastModified(HttpServletRequest req) {
+    try {
+      /** Der Reqeust-Parameter "lm" wird als Wert für Last-Modified zurückgegeben */
+      return Long.parseLong(req.getParameter("l"));
+    }
+    catch (Exception e) {
+      return -1l;
+    }
+  }
+
+  @Override
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    /** Angeforderte Header setzen */
+    Map<String, String[]> map = request.getParameterMap();
+    for (String param : map.keySet()) {
+      if (param.equals("n") || param.equals("l") || param.equals("f") || param.equals("i"))
+        continue;
+      /**
+       * Alle Request-Parameter außer die Sonder-Parameter "n" und "lm"
+       * werden als Schlüssel/Wert-Paare für die Antwort-Header interpretiert!
+       */
+      for (String value : map.get(param))
+        response.setHeader(param, value);
+    }
+
+    int n = 0;
+    try {
+      /**
+       * Wenn der Parameter n gesetzt ist, wird ein Antwort-Body erzeugt, der
+       * exakt die Anzahl der geforderten Bytes enthält.
+       */
+      n = Integer.parseInt(request.getParameter("n"));
+    }
+    catch(Exception e) {}
+    log.debug("GET {} bytes: {}", n, request.getRequestURI());
+    ServletOutputStream out = response.getOutputStream();
+    for (int i=0; i<n; i++)
+      out.write(i%2 + 48); /** ASCII-Codes für "0" und "1" */
+
+    if (request.getParameter("i") != null && request.getAttribute(INCLUDED) == null) {
+      for (String include : request.getParameterValues("i")) {
+        RequestDispatcher dispatcher = request.getRequestDispatcher(include);
+        request.setAttribute(INCLUDED, include);
+        dispatcher.include(request, response);
+      }
+    }
+
+    if (request.getParameter("f") != null && request.getAttribute(FORWARDED) == null) {
+      String forward = request.getParameter("f");
+      request.setAttribute(FORWARDED, forward);
+      RequestDispatcher dispatcher = request.getRequestDispatcher(forward);
+      dispatcher.forward(request, response);
+    }
+  }
+}