<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>
+++ /dev/null
-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);
- }
- }
-}
<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>
</developers>
<modules>
+ <module>test</module>
<module>cachecontrol</module>
</modules>
<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>
--- /dev/null
+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);
+ }
+ }
+}