From: Kai Moritz Date: Fri, 23 Dec 2011 16:41:40 +0000 (+0100) Subject: TestServlet nach juplo-test verschoben X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=3151dc432747314420978982769e4260aa00c866;p=percentcodec TestServlet nach juplo-test verschoben --- diff --git a/cachecontrol/pom.xml b/cachecontrol/pom.xml index 884bf255..24f21744 100644 --- a/cachecontrol/pom.xml +++ b/cachecontrol/pom.xml @@ -56,9 +56,9 @@ test - org.springframework - spring-test - ${springframework.version} + ${pom.parent.groupId} + ${pom.parent.artifactId}-test + ${pom.parent.version} test 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 index cb114fdd..00000000 --- a/cachecontrol/src/test/java/de/halbekunst/juplo/cachecontrol/TestServlet.java +++ /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 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 test-servlet - de.halbekunst.juplo.cachecontrol.TestServlet + de.halbekunst.juplo.test.TestServlet diff --git a/pom.xml b/pom.xml index d9c58c55..4c1bc811 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ + test cachecontrol diff --git a/test/pom.xml b/test/pom.xml index 53dd1398..5fc6b1c4 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -7,7 +7,7 @@ de.halbekunst juplo - 1.0.1 + 2.0-SNAPSHOT ${pom.parent.artifactId}-test @@ -24,6 +24,12 @@ spring-context ${springframework.version} + + javax.servlet + servlet-api + ${servlet-api.version} + provided + org.springframework spring-test 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 index 00000000..b2b29f44 --- /dev/null +++ b/test/src/main/java/de/halbekunst/juplo/test/TestServlet.java @@ -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 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