Test-Beispiele überarbeitet und nach verwendeter Technik aufgeteilt
authorKai Moritz <kai@coolibri.de>
Mon, 4 Jun 2012 08:38:30 +0000 (10:38 +0200)
committerKai Moritz <kai@coolibri.de>
Thu, 2 Aug 2012 07:20:48 +0000 (09:20 +0200)
45 files changed:
examples/jsp/catalog.xml
examples/jsp/pom.xml
examples/jsp/src/main/resources/config.xml
examples/jsp/src/main/webapp/WEB-INF/c.tld
examples/jsp/src/main/webapp/WEB-INF/views/simple-page.jsp [deleted file]
examples/jsp/src/main/webapp/WEB-INF/web.xml
examples/jsp/src/main/webapp/default.css [deleted file]
examples/jsp/src/main/webapp/index.html
examples/jsp/src/main/webapp/page-with-include.jsp
examples/jsp/src/main/webapp/simple-page.jsp
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/pom.xml
examples/servlet/jetty.sh [new file with mode: 0755]
examples/servlet/pom.xml [new file with mode: 0644]
examples/servlet/src/main/resources/config.xml [new file with mode: 0644]
examples/servlet/src/main/resources/log4j.xml [new file with mode: 0644]
examples/servlet/src/main/webapp/WEB-INF/web.xml [new file with mode: 0644]
examples/servlet/src/main/webapp/index.html [new file with mode: 0644]
examples/servlet/src/test/java/de/halbekunst/cachecontrol/examples/ServletTest.java [new file with mode: 0644]
examples/servlet/tomcat.sh [new file with mode: 0755]
examples/spring/jetty.sh [new file with mode: 0755]
examples/spring/pom.xml [new file with mode: 0644]
examples/spring/src/main/resources/config.xml [new file with mode: 0644]
examples/spring/src/main/resources/log4j.xml [new file with mode: 0644]
examples/spring/src/main/webapp/WEB-INF/views/controller-view.jsp [new file with mode: 0644]
examples/spring/src/main/webapp/WEB-INF/views/index.jsp [new file with mode: 0644]
examples/spring/src/main/webapp/WEB-INF/views/spring-page.jsp [new file with mode: 0644]
examples/spring/src/main/webapp/WEB-INF/web.xml [new file with mode: 0644]
examples/spring/src/main/webapp/index.jsp [new file with mode: 0644]
examples/spring/src/test/java/de/halbekunst/cachecontrol/examples/SpringMVCTest.java [new file with mode: 0644]
examples/spring/tomcat.sh [new file with mode: 0755]
examples/static/jetty.sh [new file with mode: 0755]
examples/static/pom.xml [new file with mode: 0644]
examples/static/src/main/resources/config.xml [new file with mode: 0644]
examples/static/src/main/resources/log4j.xml [new file with mode: 0644]
examples/static/src/main/webapp/WEB-INF/web.xml [new file with mode: 0644]
examples/static/src/main/webapp/index.html [new file with mode: 0644]
examples/static/src/main/webapp/static/page.html [new file with mode: 0644]
examples/static/src/main/webapp/static/stylesheets.css [new file with mode: 0644]
examples/static/src/test/java/de/halbekunst/cachecontrol/examples/StaticTest.java [new file with mode: 0644]
examples/static/src/test/java/org/eclipse/jetty/servlet/DefaultServlet.java [new file with mode: 0644]
pom.xml
test/pom.xml
test/src/main/java/de/halbekunst/juplo/test/LoggingHttpServletResponseWrapper.java

index 218f47c..94e8090 100644 (file)
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
     <nextCatalog catalog="../.netbeans/6.9/var/cache/mavencachedirs/586500746/retriever/catalog.xml"/>
+    <nextCatalog catalog="../../.netbeans/6.9/var/cache/mavencachedirs/207239483/retriever/catalog.xml"/>
 </catalog>
\ No newline at end of file
index d9f3c6a..7eaed0b 100644 (file)
@@ -10,7 +10,7 @@
     <version>2.0-SNAPSHOT</version>
   </parent>
 
-  <artifactId>${pom.parent.artifactId}-jsp</artifactId>
+  <artifactId>juplo-examples-jsp</artifactId>
   <packaging>war</packaging>
   <name>Juplo - Examples: JSP-Pages</name>
 
index b7a4892..e414ce9 100644 (file)
     <constructor-arg value="3600"/>
   </bean>
 
-  <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
-    <property name="defaultHandler" value="urlFilenameViewController"/>
-  </bean>
-
-  <bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
-
-  <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
-  <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
-    <property name="prefix" value="/WEB-INF/views/"/>
-    <property name="suffix" value=".jsp"/>
-  </bean>
-
 </beans>
index 8c447f5..4b85b44 100644 (file)
@@ -1,5 +1,11 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
+<!--
+Workaround for a bug in ServletUnit:
+The TLD in jstl.jar is not found when the webapp is running in this
+environment. Because of that, the TLD must be copied here and this
+copy must be referenced explicitly in all JSP's
+-->
 <taglib xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
diff --git a/examples/jsp/src/main/webapp/WEB-INF/views/simple-page.jsp b/examples/jsp/src/main/webapp/WEB-INF/views/simple-page.jsp
deleted file mode 100644 (file)
index 194cac5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<%@page contentType="text/html" pageEncoding="UTF-8" session="false" buffer="1kb" %>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
-<html>
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <title>Simple Page</title>
-    <link rel="stylesheet" type="text/css" media="all" href="/default.css">
-  </head>
-  <body>
-    <h1>Hello World!</h1>
-    <p>This is a really simple page...</p>
-    <p>This version of a really simple page was delivered via SPRING!</p>
-  </body>
-</html>
index 64cdaf7..c5661f8 100644 (file)
     <url-pattern>*.jsp</url-pattern>
   </filter-mapping>
 
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>*.html</url-pattern>
-  </filter-mapping>
   <filter-mapping>
     <filter-name>accelerator</filter-name>
     <url-pattern>*.jsp</url-pattern>
   </filter-mapping>
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>*.css</url-pattern>
-  </filter-mapping>
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>/test-servlet</url-pattern>
-  </filter-mapping>
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>/spring/*</url-pattern>
-  </filter-mapping>
-
-
-  <!-- Servlet-Definitions -->
-
-  <servlet>
-    <servlet-name>test-servlet</servlet-name>
-    <servlet-class>de.halbekunst.juplo.test.TestServlet</servlet-class>
-  </servlet>
-
-  <servlet>
-    <servlet-name>dispatcher-servlet</servlet-name>
-    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
-    <init-param>
-      <param-name>contextConfigLocation</param-name>
-      <param-value>
-      </param-value>
-    </init-param>
-    <load-on-startup>1</load-on-startup>
-  </servlet>
-
-
-  <!-- Servlet-Mappings -->
-
-  <servlet-mapping>
-    <servlet-name>test-servlet</servlet-name>
-    <url-pattern>/test-servlet</url-pattern>
-  </servlet-mapping>
-
-  <servlet-mapping>
-    <servlet-name>dispatcher-servlet</servlet-name>
-    <url-pattern>/spring/*</url-pattern>
-  </servlet-mapping>
 
 </web-app>
diff --git a/examples/jsp/src/main/webapp/default.css b/examples/jsp/src/main/webapp/default.css
deleted file mode 100644 (file)
index e04bba2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-body {
-  background-color: #ccc;
-  color: #444;
-}
-h1,h2,h3,h4 {
-  color: #000;
-}
\ No newline at end of file
index cd95f2c..c8c218d 100644 (file)
@@ -3,38 +3,14 @@
 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <title>Static Page</title>
-    <link rel="stylesheet" type="text/css" media="all" href="/default.css">
+    <title>JSP Examples</title>
   </head>
   <body>
-    <h1>Static Page</h1>
-    <p>This page is a static HTML-page</p>
-    <p>At the same time, it gives an overview over all tests...</p>
-    <h2>JSP-Pages</h2>
+    <h1>JSP Examples</h1>
     <ul>
       <li><a href="/simple-page.jsp">A really simple JSP-page</a></li>
       <li><a href="/page-with-include.jsp">A JSP-page with several includes</a></li>
       <li><a href="/page-with-forward.jsp">A JSP-page with a forward to /simple-page.jsp</a></li>
     </ul>
-    <h2>Static Content</h2>
-    <ul>
-      <li><a href="/index.html">A plain static HTML-file (this page!)</a></li>
-      <li><a href="/default.css">A plain static CSS-file</a></li>
-    </ul>
-    <h2>Dynamic Servlet-Answers</h2>
-    <ul>
-      <li><a href="/test-servlet">Empty Answer</a></li>
-      <li><a href="/test-servlet?n=16">16-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=32">32-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=64">64-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=128">128-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=256">256-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=512">512-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=1024">1024-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=2048">2048-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=4096">4096-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=8192">8192-Bytes-Answer</a></li>
-      <li><a href="/test-servlet?n=16384">16384-Bytes-Answer</a></li>
-    </ul>
   </body>
 </html>
index ba581a4..3347af7 100644 (file)
@@ -6,7 +6,6 @@
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <title>Page with include</title>
-    <link rel="stylesheet" type="text/css" media="all" href="/default.css">
   </head>
   <body>
     <h1>Hello World!</h1>
index 880d761..99d92d7 100644 (file)
@@ -5,10 +5,9 @@
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <title>Simple Page</title>
-    <link rel="stylesheet" type="text/css" media="all" href="/default.css">
   </head>
   <body>
-    <h1>Hello World!</h1>
-    <p>This is a really simple page...</p>
+    <h1>Simple Page</h1>
+    <p>This page is a simple jsp-page</p>
   </body>
 </html>
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..a7331b6
--- /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/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());
+  }
+}
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 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 28a64a6..cf45de5 100644 (file)
@@ -16,6 +16,9 @@
 
   <modules>
     <module>jsp</module>
+    <module>static</module>
+    <module>servlet</module>
+    <module>spring</module>
   </modules>
 
   <dependencies>
@@ -77,7 +80,6 @@
       <scope>runtime</scope>
     </dependency>
 
-
     <!-- Test -->
     <dependency>
       <groupId>${pom.parent.groupId}</groupId>
       <plugin>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>jetty-maven-plugin</artifactId>
-        <version>8.0.1.v20110908</version>
+        <version>${jetty.version}</version>
         <configuration>
           <connectors>
             <connector implementation="org.eclipse.jetty.server.nio.BlockingChannelConnector">
diff --git a/examples/servlet/jetty.sh b/examples/servlet/jetty.sh
new file mode 100755 (executable)
index 0000000..4950796
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn jetty:run
diff --git a/examples/servlet/pom.xml b/examples/servlet/pom.xml
new file mode 100644 (file)
index 0000000..313fe7c
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>de.halbekunst</groupId>
+    <artifactId>juplo-examples</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>juplo-examples-servlet</artifactId>
+  <packaging>war</packaging>
+  <name>Juplo - Examples: Servlet</name>
+
+</project>
diff --git a/examples/servlet/src/main/resources/config.xml b/examples/servlet/src/main/resources/config.xml
new file mode 100644 (file)
index 0000000..b7a4892
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+  <!-- Activates the AspectJ-Weaver -->
+  <context:component-scan base-package="de.halbekunst"/>
+  <context:spring-configured/>
+
+  <bean id="eTag" class="java.lang.String">
+    <constructor-arg value="Hallo Welt!"/>
+  </bean>
+
+  <bean id="weak" class="java.lang.Boolean">
+    <constructor-arg value="true"/>
+  </bean>
+
+  <bean id="lastModified" class="java.lang.Long">
+    <constructor-arg value="1338593731"/>
+  </bean>
+
+  <bean id="cacheSeconds" class="java.lang.Integer">
+    <constructor-arg value="3600"/>
+  </bean>
+
+  <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
+    <property name="defaultHandler" value="urlFilenameViewController"/>
+  </bean>
+
+  <bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
+
+  <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
+  <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+    <property name="prefix" value="/WEB-INF/views/"/>
+    <property name="suffix" value=".jsp"/>
+  </bean>
+
+</beans>
diff --git a/examples/servlet/src/main/resources/log4j.xml b/examples/servlet/src/main/resources/log4j.xml
new file mode 100644 (file)
index 0000000..d3414bd
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%p - %C{1}.%M(%L) | %m%n"/>
+    </layout>
+  </appender>
+
+  <logger name="de.halbekunst">
+   <level value="trace"/>
+  </logger>
+
+  <root>
+    <level value="info"/>
+    <appender-ref ref="CONSOLE"/>
+  </root>
+
+</log4j:configuration>
diff --git a/examples/servlet/src/main/webapp/WEB-INF/web.xml b/examples/servlet/src/main/webapp/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..53de033
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+  <!-- Context Configuration locations for Spring XML files -->
+
+  <context-param>
+    <param-name>contextConfigLocation</param-name>
+    <param-value>classpath:/config.xml</param-value>
+  </context-param>
+
+
+  <!-- Listener-Definitions -->
+
+  <listener>
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+  </listener>
+
+
+  <!-- Filter-Definitions -->
+
+  <filter>
+    <filter-name>accelerator</filter-name>
+    <filter-class>de.halbekunst.juplo.cachecontrol.AcceleratorFilter</filter-class>
+  </filter>
+
+  <filter>
+    <filter-name>logger</filter-name>
+    <filter-class>de.halbekunst.juplo.test.LoggingHttpServletResponseFilter</filter-class>
+  </filter>
+
+
+  <!-- Filter-Mappings -->
+
+  <filter-mapping>
+    <filter-name>logger</filter-name>
+    <url-pattern>/test-servlet</url-pattern>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>accelerator</filter-name>
+    <url-pattern>/test-servlet</url-pattern>
+  </filter-mapping>
+
+
+  <!-- Servlet-Definitions -->
+
+  <servlet>
+    <servlet-name>test-servlet</servlet-name>
+    <servlet-class>de.halbekunst.juplo.test.TestServlet</servlet-class>
+  </servlet>
+
+
+  <!-- Servlet-Mappings -->
+
+  <servlet-mapping>
+    <servlet-name>test-servlet</servlet-name>
+    <url-pattern>/test-servlet</url-pattern>
+  </servlet-mapping>
+
+</web-app>
diff --git a/examples/servlet/src/main/webapp/index.html b/examples/servlet/src/main/webapp/index.html
new file mode 100644 (file)
index 0000000..766627b
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Servlet Examples</title>
+  </head>
+  <body>
+    <h1>Servlet Examples</h1>
+    <p>This page is a static HTML-page</p>
+    <ul>
+      <li><a href="/test-servlet">Empty Answer</a></li>
+      <li><a href="/test-servlet?n=16">16-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=32">32-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=64">64-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=128">128-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=256">256-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=512">512-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=1024">1024-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=2048">2048-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=4096">4096-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=8192">8192-Bytes-Answer</a></li>
+      <li><a href="/test-servlet?n=16384">16384-Bytes-Answer</a></li>
+    </ul>
+  </body>
+</html>
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/tomcat.sh b/examples/servlet/tomcat.sh
new file mode 100755 (executable)
index 0000000..4378a12
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn tomcat:run-war
diff --git a/examples/spring/jetty.sh b/examples/spring/jetty.sh
new file mode 100755 (executable)
index 0000000..4950796
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn jetty:run
diff --git a/examples/spring/pom.xml b/examples/spring/pom.xml
new file mode 100644 (file)
index 0000000..90010cc
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>de.halbekunst</groupId>
+    <artifactId>juplo-examples</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>juplo-examples-spring</artifactId>
+  <packaging>war</packaging>
+  <name>Juplo - Examples: Spring-MVC</name>
+
+</project>
diff --git a/examples/spring/src/main/resources/config.xml b/examples/spring/src/main/resources/config.xml
new file mode 100644 (file)
index 0000000..b7a4892
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+  <!-- Activates the AspectJ-Weaver -->
+  <context:component-scan base-package="de.halbekunst"/>
+  <context:spring-configured/>
+
+  <bean id="eTag" class="java.lang.String">
+    <constructor-arg value="Hallo Welt!"/>
+  </bean>
+
+  <bean id="weak" class="java.lang.Boolean">
+    <constructor-arg value="true"/>
+  </bean>
+
+  <bean id="lastModified" class="java.lang.Long">
+    <constructor-arg value="1338593731"/>
+  </bean>
+
+  <bean id="cacheSeconds" class="java.lang.Integer">
+    <constructor-arg value="3600"/>
+  </bean>
+
+  <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
+    <property name="defaultHandler" value="urlFilenameViewController"/>
+  </bean>
+
+  <bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
+
+  <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
+  <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+    <property name="prefix" value="/WEB-INF/views/"/>
+    <property name="suffix" value=".jsp"/>
+  </bean>
+
+</beans>
diff --git a/examples/spring/src/main/resources/log4j.xml b/examples/spring/src/main/resources/log4j.xml
new file mode 100644 (file)
index 0000000..13ec197
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%p - %C{1}.%M(%L) | %m%n"/>
+    </layout>
+  </appender>
+
+  <logger name="de.halbekunst">
+   <level value="trace"/>
+  </logger>
+
+  <logger name="org.springframework">
+    <level value="debug" />
+  </logger>
+
+  <root>
+    <level value="info"/>
+    <appender-ref ref="CONSOLE"/>
+  </root>
+
+</log4j:configuration>
diff --git a/examples/spring/src/main/webapp/WEB-INF/views/controller-view.jsp b/examples/spring/src/main/webapp/WEB-INF/views/controller-view.jsp
new file mode 100644 (file)
index 0000000..26abdbd
--- /dev/null
@@ -0,0 +1,43 @@
+<%@page contentType="text/html" pageEncoding="UTF-8" session="false" buffer="1kb" %>
+<%@page import="java.util.Map" %>
+<%@page import="java.util.Date"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Page, that is handled by a controller</title>
+  </head>
+  <body>
+    <% Map<Date,String> requests = (Map<Date,String>)request.getAttribute("requests");
+       if (requests == null) { %>
+    <h1 style="color: red">This page associated with a controller and should be viewed as such!</h1>
+    <p style="color: red">Go to: <a href="/spring-controller.html">/spring-controller.html</a></p>
+    <% } else { %>
+    <h1>Controlled Page</h1>
+    <form action="/spring-controller.html">
+      <label for="max-age">Max Age:</label>
+      <input type="text" name="max-age" value="<% if (request.getParameter("max-age") != null) { %><%= request.getParameter("max-age") %><% } %>" />
+      <br />
+    </form>
+    <p>(Uncached) requests so far:</p>
+    <ol>
+      <% for(Map.Entry<Date,String> entry : requests.entrySet()) { %>
+      <li>
+        <%= entry.getKey() %>:
+        <% if (entry.getValue().equals("")) { %>
+          <a href="/spring-controller.html">No parameters...</a>
+        <% } else { %>
+          <a href="/spring-controller.html?<%= entry.getValue() %>">
+            <% for (String parameter : entry.getValue().split("&")) { %>
+            <strong><%= parameter %></strong>
+            <% } %>
+          </a>
+        <% } %>
+      </li>
+      <% } %>
+    </ol>
+    <% } %>
+    <p>This page was delivered via SPRING!</p>
+  </body>
+</html>
diff --git a/examples/spring/src/main/webapp/WEB-INF/views/index.jsp b/examples/spring/src/main/webapp/WEB-INF/views/index.jsp
new file mode 100644 (file)
index 0000000..020f6ee
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Simple Spring-MVC Examples</title>
+  </head>
+  <body>
+    <h1>Simple Spring-MVC Examples</h1>
+    <ul>
+      <li><a href="/spring-page.html">Simple Spring-View</a></li>
+    </ul>
+    <p>This page was delivered via SPRING!</p>
+    <h2>Note:</h2>
+    <p>
+      Since the <code>org.springframework.web.servlet.DispatcherServlet</code>
+      ist configured to handle all <code>*.html</code>-requests, the path
+      <code>/index.html</code> points to a view.
+    </p>
+    <p>
+      Therefore, this page must be stored under
+      <code>/WEB-INF/views/index.jsp</code> in order to be served as
+      <code>/index.html</code>
+    </p>
+    <p>
+      Additionatly, a file <code>/index.jsp</code> in the root-directory of
+      the webappliction is needed, to forward unqualified requests
+      (like <code>http://HOSTNAME/</code>) to the welcome-page served by
+      the Spring-Dispatcher-Servlet.
+    </p>
+  </body>
+</html>
diff --git a/examples/spring/src/main/webapp/WEB-INF/views/spring-page.jsp b/examples/spring/src/main/webapp/WEB-INF/views/spring-page.jsp
new file mode 100644 (file)
index 0000000..892bf1a
--- /dev/null
@@ -0,0 +1,14 @@
+<%@page contentType="text/html" pageEncoding="UTF-8" session="false" buffer="1kb" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Simple Page</title>
+  </head>
+  <body>
+    <h1>Hello World!</h1>
+    <p>This is a really simple page...</p>
+    <p>This page was delivered via SPRING!</p>
+  </body>
+</html>
diff --git a/examples/spring/src/main/webapp/WEB-INF/web.xml b/examples/spring/src/main/webapp/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..4f26f01
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+  <!-- Context Configuration locations for Spring XML files -->
+
+  <context-param>
+    <param-name>contextConfigLocation</param-name>
+    <param-value>classpath:/config.xml</param-value>
+  </context-param>
+
+
+  <!-- Listener-Definitions -->
+
+  <listener>
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+  </listener>
+
+
+  <!-- Filter-Definitions -->
+
+  <filter>
+    <filter-name>accelerator</filter-name>
+    <filter-class>de.halbekunst.juplo.cachecontrol.AcceleratorFilter</filter-class>
+  </filter>
+
+  <filter>
+    <filter-name>logger</filter-name>
+    <filter-class>de.halbekunst.juplo.test.LoggingHttpServletResponseFilter</filter-class>
+  </filter>
+
+
+  <!-- Filter-Mappings -->
+
+  <filter-mapping>
+    <filter-name>logger</filter-name>
+    <url-pattern>*.html</url-pattern>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>accelerator</filter-name>
+    <url-pattern>*.html</url-pattern>
+  </filter-mapping>
+
+
+  <!-- Servlet-Definitions -->
+
+  <servlet>
+    <servlet-name>dispatcher-servlet</servlet-name>
+    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+    <init-param>
+      <param-name>contextConfigLocation</param-name>
+      <param-value>
+      </param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+
+  <!-- Servlet-Mappings -->
+
+  <servlet-mapping>
+    <servlet-name>dispatcher-servlet</servlet-name>
+    <url-pattern>*.html</url-pattern>
+  </servlet-mapping>
+
+</web-app>
diff --git a/examples/spring/src/main/webapp/index.jsp b/examples/spring/src/main/webapp/index.jsp
new file mode 100644 (file)
index 0000000..9082000
--- /dev/null
@@ -0,0 +1,8 @@
+<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" session="false" %>
+<jsp:forward page="/index.html"/>
+<%--
+
+Unfortionatly, the welcome-mechanism in web.xml does not work with a page
+served by a servlet...
+
+--%>
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..f90d16e
--- /dev/null
@@ -0,0 +1,29 @@
+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 testSpringPage() throws Exception {
+    WebResponse response = executeRequest("http://localhost:8080/spring-page.html");
+    log.info("Title:\t\t{}", response.getTitle());
+    log.debug("Text:\t\t{}", response.getText());
+  }
+}
diff --git a/examples/spring/tomcat.sh b/examples/spring/tomcat.sh
new file mode 100755 (executable)
index 0000000..4378a12
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn tomcat:run-war
diff --git a/examples/static/jetty.sh b/examples/static/jetty.sh
new file mode 100755 (executable)
index 0000000..4950796
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn jetty:run
diff --git a/examples/static/pom.xml b/examples/static/pom.xml
new file mode 100644 (file)
index 0000000..5cf0634
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>de.halbekunst</groupId>
+    <artifactId>juplo-examples</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>juplo-examples-static</artifactId>
+  <packaging>war</packaging>
+  <name>Juplo - Examples: Static Content</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>${commons-io.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/examples/static/src/main/resources/config.xml b/examples/static/src/main/resources/config.xml
new file mode 100644 (file)
index 0000000..e414ce9
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+  <!-- Activates the AspectJ-Weaver -->
+  <context:component-scan base-package="de.halbekunst"/>
+  <context:spring-configured/>
+
+  <bean id="eTag" class="java.lang.String">
+    <constructor-arg value="Hallo Welt!"/>
+  </bean>
+
+  <bean id="weak" class="java.lang.Boolean">
+    <constructor-arg value="true"/>
+  </bean>
+
+  <bean id="lastModified" class="java.lang.Long">
+    <constructor-arg value="1338593731"/>
+  </bean>
+
+  <bean id="cacheSeconds" class="java.lang.Integer">
+    <constructor-arg value="3600"/>
+  </bean>
+
+</beans>
diff --git a/examples/static/src/main/resources/log4j.xml b/examples/static/src/main/resources/log4j.xml
new file mode 100644 (file)
index 0000000..d3414bd
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%p - %C{1}.%M(%L) | %m%n"/>
+    </layout>
+  </appender>
+
+  <logger name="de.halbekunst">
+   <level value="trace"/>
+  </logger>
+
+  <root>
+    <level value="info"/>
+    <appender-ref ref="CONSOLE"/>
+  </root>
+
+</log4j:configuration>
diff --git a/examples/static/src/main/webapp/WEB-INF/web.xml b/examples/static/src/main/webapp/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..2df85a5
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+  <!-- Context Configuration locations for Spring XML files -->
+
+  <context-param>
+    <param-name>contextConfigLocation</param-name>
+    <param-value>classpath:/config.xml</param-value>
+  </context-param>
+
+
+  <!-- Listener-Definitions -->
+
+  <listener>
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+  </listener>
+
+
+  <!-- Filter-Definitions -->
+
+  <filter>
+    <filter-name>accelerator</filter-name>
+    <filter-class>de.halbekunst.juplo.cachecontrol.AcceleratorFilter</filter-class>
+  </filter>
+
+  <filter>
+    <filter-name>logger</filter-name>
+    <filter-class>de.halbekunst.juplo.test.LoggingHttpServletResponseFilter</filter-class>
+  </filter>
+
+
+  <!-- Filter-Mappings -->
+
+  <filter-mapping>
+    <filter-name>logger</filter-name>
+    <url-pattern>/static/*</url-pattern>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>accelerator</filter-name>
+    <url-pattern>/static/*</url-pattern>
+  </filter-mapping>
+
+
+  <!-- Servlet-Definitions -->
+
+  <servlet>
+    <servlet-name>default</servlet-name>
+    <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
+  </servlet>
+
+
+  <!-- Servlet-Mappings -->
+
+  <servlet-mapping>
+    <servlet-name>default</servlet-name>
+    <url-pattern>/</url-pattern>
+  </servlet-mapping>
+
+
+</web-app>
diff --git a/examples/static/src/main/webapp/index.html b/examples/static/src/main/webapp/index.html
new file mode 100644 (file)
index 0000000..22c61d0
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Examples for Static Content</title>
+  </head>
+  <body>
+    <h1>Examples for Static Content</h1>
+    <ul>
+      <li><a href="/static/page.html">A plain static HTML-file</a></li>
+      <li><a href="/static/stylesheets.css">A plain static CSS-file</a></li>
+    </ul>
+  </body>
+</html>
diff --git a/examples/static/src/main/webapp/static/page.html b/examples/static/src/main/webapp/static/page.html
new file mode 100644 (file)
index 0000000..f851795
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>A Static Page</title>
+    <link rel="stylesheet" type="text/css" media="all" href="/static/stylesheets.css">
+  </head>
+  <body>
+    <h1>A Static Page</h1>
+    <p>This page is a static HTML-page</p>
+  </body>
+</html>
diff --git a/examples/static/src/main/webapp/static/stylesheets.css b/examples/static/src/main/webapp/static/stylesheets.css
new file mode 100644 (file)
index 0000000..e04bba2
--- /dev/null
@@ -0,0 +1,7 @@
+body {
+  background-color: #ccc;
+  color: #444;
+}
+h1,h2,h3,h4 {
+  color: #000;
+}
\ No newline at end of file
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/org/eclipse/jetty/servlet/DefaultServlet.java b/examples/static/src/test/java/org/eclipse/jetty/servlet/DefaultServlet.java
new file mode 100644 (file)
index 0000000..0173a1f
--- /dev/null
@@ -0,0 +1,28 @@
+package org.eclipse.jetty.servlet;
+
+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 DefaultServlet 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;
+    }
+    response.setContentType("text/html");
+    IOUtils.copy(new FileInputStream(path), response.getOutputStream());
+  }
+}
diff --git a/pom.xml b/pom.xml
index 97cb6a2..8c63f41 100644 (file)
--- a/pom.xml
+++ b/pom.xml
 
     <!-- Verwendete Versionen -->
     <aspectj.version>1.6.11</aspectj.version>
+    <commons-io.version>1.3.2</commons-io.version>
     <httpunit.version>1.7.1</httpunit.version>
     <jasper.version>6.0.29</jasper.version>
+    <jetty.version>8.1.4.v20120524</jetty.version>
     <jpa.version>1.0</jpa.version>
     <jstl.version>1.2</jstl.version>
     <junit.version>4.8.1</junit.version>
index d13cdbf..7c3a4b4 100644 (file)
       <version>${springframework.version}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>${jetty.version}</version>
+    </dependency>
 
     <!-- hidden dependencies -->
     <dependency>
index f654f2a..075e6a7 100644 (file)
@@ -3,6 +3,7 @@ package de.halbekunst.juplo.test;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.util.Collection;
 import java.util.Date;
 import java.util.Locale;
 import javax.servlet.ServletOutputStream;
@@ -283,6 +284,54 @@ public class LoggingHttpServletResponseWrapper implements HttpServletResponse {
     return locale;
   }
 
+  @Override
+  public int getStatus() {
+    Integer status = response.getStatus();
+    log.trace("{} -- status: {}", no, status);
+    return status;
+  }
+
+  @Override
+  public String getHeader(String name) {
+    String value = response.getHeader(name);
+    log.trace("{} -- header \"{}\": {}", new Object[] { no, name, value });
+    return value;
+  }
+
+  @Override
+  public Collection<String> getHeaders(String name) {
+    Collection<String> values = response.getHeaders(name);
+    if (log.isTraceEnabled()) {
+      StringBuilder builder = new StringBuilder();
+      builder.append(no);
+      builder.append(" -- headers \"");
+      builder.append(name);
+      builder.append("\":");
+      for (String value : values) {
+        builder.append(' ');
+        builder.append(value);
+      }
+      log.trace(builder.toString());
+    }
+    return values;
+  }
+
+  @Override
+  public Collection<String> getHeaderNames() {
+    Collection<String> values = response.getHeaderNames();
+    if (log.isTraceEnabled()) {
+      StringBuilder builder = new StringBuilder();
+      builder.append(no);
+      builder.append(" -- header-names:");
+      for (String value : values) {
+        builder.append(' ');
+        builder.append(value);
+      }
+      log.trace(builder.toString());
+    }
+    return values;
+  }
+
 
   class CountingServletOutputStream extends ServletOutputStream {