From: Kai Moritz Date: Tue, 19 Jun 2012 00:14:26 +0000 (+0200) Subject: WIP: Versuch den StaticTest zu reparieren... X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=b18b822c21ed44c84e5f4ea6de68a1a04f7e9a0b;p=percentcodec WIP: Versuch den StaticTest zu reparieren... --- diff --git a/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java b/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java new file mode 100644 index 00000000..da29369c --- /dev/null +++ b/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java @@ -0,0 +1,43 @@ +package de.halbekunst.cachecontrol.examples; + +import de.halbekunst.juplo.test.HttpTestCase; +import com.meterware.httpunit.WebResponse; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author kai + */ +public class JspTest extends HttpTestCase { + + private static final Logger log = LoggerFactory.getLogger(JspTest.class); + + + public JspTest() { + super("src/main/webapp/WEB-INF/web.xml"); + } + + + @Test + public void testSimplePage() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/index.jsp"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } + + @Test + public void testPageWithInclude() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/page-with-include.jsp"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } + + @Test + public void testPageWithForward() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/page-with-forward.jsp"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } +} 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/jsp/JspTest.java deleted file mode 100644 index cce6ae8e..00000000 --- a/examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.halbekunst.cachecontrol.examples.jsp; - -import de.halbekunst.juplo.test.HttpTestCase; -import com.meterware.httpunit.WebResponse; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author kai - */ -public class JspTest extends HttpTestCase { - - private static final Logger log = LoggerFactory.getLogger(JspTest.class); - - - public JspTest() { - super("src/main/webapp/WEB-INF/web.xml"); - } - - - @Test - public void testSimplePage() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/index.jsp"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } - - @Test - public void testPageWithInclude() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/page-with-include.jsp"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } - - @Test - public void testPageWithForward() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/page-with-forward.jsp"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } -} diff --git a/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java b/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java new file mode 100644 index 00000000..32b13e11 --- /dev/null +++ b/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java @@ -0,0 +1,28 @@ +package de.halbekunst.cachecontrol.examples; + +import de.halbekunst.juplo.test.HttpTestCase; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author kai + */ +public class ServletTest extends HttpTestCase { + + private static final Logger log = LoggerFactory.getLogger(ServletTest.class); + + + public ServletTest() { + super("src/main/webapp/WEB-INF/web.xml"); + } + + + @Test + public void test() throws Exception { +// WebResponse response = executeRequest("http://localhost:8080/simple-page.jsp"); +// log.info("Title:\t\t{}", response.getTitle()); +// log.debug("Text:\t\t{}", response.getText()); + } +} 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/jsp/ServletTest.java deleted file mode 100644 index f942c5bb..00000000 --- a/examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/jsp/ServletTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.halbekunst.cachecontrol.examples.jsp; - -import de.halbekunst.juplo.test.HttpTestCase; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author kai - */ -public class ServletTest extends HttpTestCase { - - private static final Logger log = LoggerFactory.getLogger(ServletTest.class); - - - public ServletTest() { - super("src/main/webapp/WEB-INF/web.xml"); - } - - - @Test - public void test() throws Exception { -// WebResponse response = executeRequest("http://localhost:8080/simple-page.jsp"); -// log.info("Title:\t\t{}", response.getTitle()); -// log.debug("Text:\t\t{}", response.getText()); - } -} diff --git a/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java b/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java new file mode 100644 index 00000000..7250b5fb --- /dev/null +++ b/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java @@ -0,0 +1,50 @@ +package de.halbekunst.cachecontrol.examples; + +import de.halbekunst.juplo.test.HttpTestCase; +import com.meterware.httpunit.WebResponse; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author kai + */ +public class SpringMVCTest extends HttpTestCase { + + private static final Logger log = LoggerFactory.getLogger(SpringMVCTest.class); + + + public SpringMVCTest() { + super("src/main/webapp/WEB-INF/web.xml"); + } + + + @Test + public void testSimplePage() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/simple-page.jsp"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } + + @Test + public void testPageWithInclude() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/page-with-include.jsp"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } + + @Test + public void testPageWithForward() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/page-with-forward.jsp"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } + + @Test + public void testStaticContent() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/default.css"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } +} 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/jsp/JspTest.java deleted file mode 100644 index 9861068b..00000000 --- a/examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.halbekunst.cachecontrol.examples.jsp; - -import de.halbekunst.juplo.test.HttpTestCase; -import com.meterware.httpunit.WebResponse; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author kai - */ -public class JspTest extends HttpTestCase { - - private static final Logger log = LoggerFactory.getLogger(JspTest.class); - - - public JspTest() { - super("src/main/webapp/WEB-INF/web.xml"); - } - - - @Test - public void testSimplePage() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/simple-page.jsp"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } - - @Test - public void testPageWithInclude() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/page-with-include.jsp"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } - - @Test - public void testPageWithForward() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/page-with-forward.jsp"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } - - @Test - public void testStaticContent() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/default.css"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } -} 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/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java b/examples/static/src/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java new file mode 100644 index 00000000..6dff5ff8 --- /dev/null +++ b/examples/static/src/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java @@ -0,0 +1,27 @@ +package de.halbekunst.cachecontrol.examples; + +import java.io.FileInputStream; +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; + +/** + * Möglichst simple Fake-Implementierung für die Ausführung des Testfalls + * + * @author kai + */ +public class SimpleDefaultServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + 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/StaticTest.java b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java new file mode 100644 index 00000000..e66a5087 --- /dev/null +++ b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java @@ -0,0 +1,28 @@ +package de.halbekunst.cachecontrol.examples; + +import de.halbekunst.juplo.test.HttpTestCase; +import com.meterware.httpunit.WebResponse; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author kai + */ +public class StaticTest extends HttpTestCase { + + private static final Logger log = LoggerFactory.getLogger(StaticTest.class); + + + public StaticTest() { + super("src/main/webapp/WEB-INF/web.xml"); + } + + @Test + public void testStaticContent() throws Exception { + WebResponse response = executeRequest("http://localhost:8080/static/page.html"); + log.info("Title:\t\t{}", response.getTitle()); + log.debug("Text:\t\t{}", response.getText()); + } +} 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 765075a6..00000000 Binary files a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp and /dev/null differ 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/jsp/StaticTest.java deleted file mode 100644 index 67ebfa17..00000000 --- a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.halbekunst.cachecontrol.examples.jsp; - -import de.halbekunst.juplo.test.HttpTestCase; -import com.meterware.httpunit.WebResponse; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author kai - */ -public class StaticTest extends HttpTestCase { - - private static final Logger log = LoggerFactory.getLogger(StaticTest.class); - - - public StaticTest() { - super("src/main/webapp/WEB-INF/web.xml"); - } - - @Test - public void testStaticContent() throws Exception { - WebResponse response = executeRequest("http://localhost:8080/static/page.html"); - log.info("Title:\t\t{}", response.getTitle()); - log.debug("Text:\t\t{}", response.getText()); - } -} diff --git a/examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java b/examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java deleted file mode 100644 index e96c37ef..00000000 --- a/examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.apache.catalina.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.io.IOUtils; - -/** - * Möglichst simple Fake-Implementierung für die Ausführung des Testfalls - * - * @author kai - */ -public class DefaultServlet extends HttpServlet { - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - IOUtils.copy(DefaultServlet.class.getResourceAsStream(request.getRequestURI()), response.getOutputStream()); - } -}