WIP: Versuch den StaticTest zu reparieren...
authorKai Moritz <kai@coolibri.de>
Tue, 19 Jun 2012 00:14:26 +0000 (02:14 +0200)
committerKai Moritz <kai@coolibri.de>
Thu, 2 Aug 2012 07:03:26 +0000 (09:03 +0200)
13 files changed:
examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/JspTest.java [new file with mode: 0644]
examples/jsp/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java [deleted file]
examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java [new file with mode: 0644]
examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/jsp/ServletTest.java [deleted file]
examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java [new file with mode: 0644]
examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/jsp/JspTest.java [deleted file]
examples/static/pom.xml
examples/static/src/main/java/de/halbekunst/cachecontrol/examples/SimpleDefaultServlet.java [new file with mode: 0644]
examples/static/src/main/webapp/WEB-INF/web.xml
examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java [new file with mode: 0644]
examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp [deleted file]
examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java [deleted file]
examples/static/src/test/java/org/apache/catalina/servlets/DefaultServlet.java [deleted file]

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 (file)
index 0000000..da29369
--- /dev/null
@@ -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 (file)
index cce6ae8..0000000
+++ /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 (file)
index 0000000..32b13e1
--- /dev/null
@@ -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 (file)
index f942c5b..0000000
+++ /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 (file)
index 0000000..7250b5f
--- /dev/null
@@ -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 (file)
index 9861068..0000000
+++ /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());
-  }
-}
index 5cf0634..9fe6d11 100644 (file)
@@ -19,7 +19,6 @@
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-io</artifactId>
       <version>${commons-io.version}</version>
-      <scope>test</scope>
     </dependency>
   </dependencies>
 
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 (file)
index 0000000..6dff5ff
--- /dev/null
@@ -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());
+  }
+}
index 8c1c69d..89bf591 100644 (file)
@@ -48,7 +48,7 @@
 
   <servlet>
     <servlet-name>default</servlet-name>
-    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
+    <servlet-class>de.halbekunst.cachecontrol.examples.SimpleDefaultServlet</servlet-class>
   </servlet>
 
 
@@ -59,4 +59,5 @@
     <url-pattern>/</url-pattern>
   </servlet-mapping>
 
+
 </web-app>
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 (file)
index 0000000..e66a508
--- /dev/null
@@ -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 (file)
index 765075a..0000000
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 (file)
index 67ebfa1..0000000
+++ /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 (file)
index e96c37e..0000000
+++ /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());
-  }
-}