From b18b822c21ed44c84e5f4ea6de68a1a04f7e9a0b Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 19 Jun 2012 02:14:26 +0200 Subject: [PATCH] WIP: Versuch den StaticTest zu reparieren... --- .../examples/{jsp => }/JspTest.java | 2 +- .../examples/{jsp => }/ServletTest.java | 2 +- .../{jsp/JspTest.java => SpringMVCTest.java} | 8 ++++---- examples/static/pom.xml | 1 - .../examples/SimpleDefaultServlet.java} | 12 +++++++++--- examples/static/src/main/webapp/WEB-INF/web.xml | 3 ++- .../examples/{jsp => }/StaticTest.java | 2 +- .../cachecontrol/examples/jsp/.JspTest.java.swp | Bin 12288 -> 0 bytes 8 files changed, 18 insertions(+), 12 deletions(-) rename examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/{jsp => }/JspTest.java (95%) rename examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/{jsp => }/ServletTest.java (92%) rename examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/{jsp/JspTest.java => SpringMVCTest.java} (86%) rename examples/static/src/{test/java/org/apache/catalina/servlets/DefaultServlet.java => main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java} (55%) rename examples/static/src/test/java/de/halbekunst/cachecontrol/examples/{jsp => }/StaticTest.java (93%) delete mode 100644 examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp diff --git a/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java b/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java similarity index 95% rename from examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java rename to examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java index cce6ae8e..da29369c 100644 --- a/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java +++ b/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java @@ -1,4 +1,4 @@ -package de.halbekunst.cachecontrol.examples.jsp; +package de.halbekunst.cachecontrol.examples; import de.halbekunst.juplo.test.HttpTestCase; import com.meterware.httpunit.WebResponse; diff --git a/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/jsp/ServletTest.java b/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java similarity index 92% rename from examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/jsp/ServletTest.java rename to examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java index f942c5bb..32b13e11 100644 --- a/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/jsp/ServletTest.java +++ b/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java @@ -1,4 +1,4 @@ -package de.halbekunst.cachecontrol.examples.jsp; +package de.halbekunst.cachecontrol.examples; import de.halbekunst.juplo.test.HttpTestCase; import org.junit.Test; diff --git a/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java b/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java similarity index 86% rename from examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java rename to examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java index 9861068b..7250b5fb 100644 --- a/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java +++ b/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java @@ -1,4 +1,4 @@ -package de.halbekunst.cachecontrol.examples.jsp; +package de.halbekunst.cachecontrol.examples; import de.halbekunst.juplo.test.HttpTestCase; import com.meterware.httpunit.WebResponse; @@ -10,12 +10,12 @@ import org.slf4j.LoggerFactory; * * @author kai */ -public class JspTest extends HttpTestCase { +public class SpringMVCTest extends HttpTestCase { - private static final Logger log = LoggerFactory.getLogger(JspTest.class); + private static final Logger log = LoggerFactory.getLogger(SpringMVCTest.class); - public JspTest() { + public SpringMVCTest() { super("src/main/webapp/WEB-INF/web.xml"); } diff --git a/examples/static/pom.xml b/examples/static/pom.xml index 5cf0634f..9fe6d115 100644 --- a/examples/static/pom.xml +++ b/examples/static/pom.xml @@ -19,7 +19,6 @@ org.apache.commons commons-io ${commons-io.version} - test diff --git a/examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java b/examples/static/src/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java similarity index 55% rename from examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java rename to examples/static/src/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java index e96c37ef..6dff5ff8 100644 --- a/examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java +++ b/examples/static/src/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java @@ -1,5 +1,6 @@ -package org.apache.catalina.servlets; +package de.halbekunst.cachecontrol.examples; +import java.io.FileInputStream; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -12,10 +13,15 @@ import org.apache.commons.io.IOUtils; * * @author kai */ -public class DefaultServlet extends HttpServlet { +public class SimpleDefaultServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - IOUtils.copy(DefaultServlet.class.getResourceAsStream(request.getRequestURI()), response.getOutputStream()); + String path = getServletContext().getRealPath(request.getRequestURI()); + if (path == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + IOUtils.copy(new FileInputStream(path), response.getOutputStream()); } } diff --git a/examples/static/src/main/webapp/WEB-INF/web.xml b/examples/static/src/main/webapp/WEB-INF/web.xml index 8c1c69db..89bf5915 100644 --- a/examples/static/src/main/webapp/WEB-INF/web.xml +++ b/examples/static/src/main/webapp/WEB-INF/web.xml @@ -48,7 +48,7 @@ default - org.apache.catalina.servlets.DefaultServlet + de.halbekunst.cachecontrol.examples.SimpleDefaultServlet @@ -59,4 +59,5 @@ / + diff --git a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java similarity index 93% rename from examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java rename to examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java index 67ebfa17..e66a5087 100644 --- a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java +++ b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java @@ -1,4 +1,4 @@ -package de.halbekunst.cachecontrol.examples.jsp; +package de.halbekunst.cachecontrol.examples; import de.halbekunst.juplo.test.HttpTestCase; import com.meterware.httpunit.WebResponse; diff --git a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp deleted file mode 100644 index 765075a60349a8bd8c56d3cf60652c489e8af456..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2+iDX*7{{mTjXjE93u9DBi`lJJu(Vi;rLonX=<%iqlg%XAbh5MV%(l@|3kAVD z^$oo80R%zt4ZP4N&va5msg?|!djqL0<%WA!?hV}?bS`dY zZt!bYSI)f_5N9 z43GgbKnBPF86X2>fDDiUGC&4Sp#f23OkHMdp%a70|NjTy|9|u`_8oixDR>4Z!EJC0 zaBv;;f==+Om$9GVJ$MJ+f|ptOTuZZCdSOtr~#WWA-AOmE843GgbKnBPF8Tfw&b{OXl&Xq2E zMOjG8+03%6+mUsJdgIjSitz@`xU;s?}vp78aYA zYh9N=3b5HseydYa)#NEm;t8?5|Be%1zJZUD2!8RNHK8CUWBr+t`;lkCSjySjkOe_3=^| z3B_l08TsXIQ^E4yFXTmFb@IY(Bl{<^2Pxr!62@Rfv*v={+MU-jAsFnUydTSYaELhHHvwN3}R z=GCN?ZV^h)?NN<3hxW8qQ_Rr6N%3AIhu(8Lly^7?7qAF6@U(b)`@>1}-a+cUd+MX? E4;!>M4FCWD -- 2.20.1