[CVS spice] More tests and tools.
sjoberg-yCVjj/[email protected] 22 Sep 2005 12:12:07 -0000
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>spice/components/jervlet/src/test/org/codehaus/spice/jervlet</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>containers/jetty/avalon/<a href="#file1">AvalonJettyContainerTestCase.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.2 -> 1.3</td></tr>
<tr class="alt"><td><tt>containers/jetty/pico/<a href="#file2">PicoJettyContainerTestCase.java</a></tt></td><td align="right" id="added">+154</td><td align="right" id="removed">-19</td><td nowrap="nowrap" align="center">1.3 -> 1.4</td></tr>
<tr><td><tt>containers/jetty/<a href="#file3">ShieldingJettyContainerTestCase.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -> 1.2</td></tr>
<tr class="alt"><td><tt>impl/avalon/<a href="#file4"><span id="added">AvalonTestFilter.java</span></a></tt></td><td align="right" id="added">+115</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file5"><span id="added">AvalonTestServlet.java</span></a></tt></td><td align="right" id="added">+83</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>impl/dna/<a href="#file6"><span id="added">DNATestFilter.java</span></a></tt></td><td align="right" id="added">+114</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file7"><span id="added">DNATestServlet.java</span></a></tt></td><td align="right" id="added">+83</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>impl/pico/<a href="#file8"><span id="added">PicoTestFilter.java</span></a></tt></td><td align="right" id="added">+94</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file9"><span id="added">PicoTestServlet.java</span></a></tt></td><td align="right" id="added">+62</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>impl/<a href="#file10"><span id="added">Pinger.java</span></a></tt></td><td align="right" id="added">+34</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file11"><span id="added">PlainTestFilter.java</span></a></tt></td><td align="right" id="added">+74</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file12"><span id="added">PlainTestServlet.java</span></a></tt></td><td align="right" id="added">+43</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td></td><td align="right" id="added">+858</td><td align="right" id="removed">-21</td><td></td></tr>
</table>
<small id="info">9 added + 3 modified, total 12 files</small><br />
<pre class="comment">
More tests and tools.
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/containers/jetty/avalon<br /></span>
<div class="fileheader"><big><b>AvalonJettyContainerTestCase.java</b></big> <small id="info">1.2 -> 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- AvalonJettyContainerTestCase.java 10 Aug 2005 22:18:10 -0000 1.2
+++ AvalonJettyContainerTestCase.java 22 Sep 2005 12:12:06 -0000 1.3
@@ -23,7 +23,7 @@
</small></pre><pre class="diff" id="context"> public class AvalonJettyContainerTestCase extends TestCase
{
private static final String m_defaultConfiguration =
</pre><pre class="diff" id="removed">- "./testdata/jetty/jetty.xml";
</pre><pre class="diff" id="added">+ ".<span id="addedchars">./..</span>/testdata/jetty/jetty.xml";
</pre><pre class="diff" id="context">
/**
* Create an empty container and start/stop it.
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/containers/jetty/pico<br /></span>
<div class="fileheader"><big><b>PicoJettyContainerTestCase.java</b></big> <small id="info">1.3 -> 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- PicoJettyContainerTestCase.java 22 Aug 2005 00:38:55 -0000 1.3
+++ PicoJettyContainerTestCase.java 22 Sep 2005 12:12:06 -0000 1.4
@@ -12,7 +12,12 @@
</small></pre><pre class="diff" id="context"> import org.codehaus.spice.jervlet.ContextHandler;
import org.codehaus.spice.jervlet.Instantiator;
import org.codehaus.spice.jervlet.Listener;
</pre><pre class="diff" id="removed">-import org.codehaus.spice.jervlet.impl.<span id="removedchars">*</span>;
</pre><pre class="diff" id="added">+import org.codehaus.spice.jervlet.impl.<span id="addedchars">NoopContextMonitor</span>;
+import org.codehaus.spice.jervlet.impl.NoopListenerMonitor;
+import org.codehaus.spice.jervlet.impl.DefaultListener;
+import org.codehaus.spice.jervlet.impl.StandardServletInstantiator;
+import org.codehaus.spice.jervlet.impl.DefaultContext;
+import org.codehaus.spice.jervlet.impl.Pinger;
</pre><pre class="diff" id="context"> import org.codehaus.spice.jervlet.impl.pico.PicoInstantiator;
import org.picocontainer.MutablePicoContainer;
import org.picocontainer.defaults.DefaultPicoContainer;
</pre><pre class="diff"><small id="info">@@ -22,6 +27,11 @@
</small></pre><pre class="diff" id="context"> import java.net.URL;
import java.util.Properties;
</pre><pre class="diff" id="added">+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.GetMethodWebRequest;
+
</pre><pre class="diff" id="context"> /**
* TestCase for PicoJettyContainer
*
</pre><pre class="diff"><small id="info">@@ -30,11 +40,13 @@
</small></pre><pre class="diff" id="context"> public class PicoJettyContainerTestCase extends TestCase
{
private static final String m_defaultConfiguration =
</pre><pre class="diff" id="removed">- "./testdata/jetty/jetty.xml";
</pre><pre class="diff" id="added">+ ".<span id="addedchars">./..</span>/testdata/jetty/jetty.xml";
</pre><pre class="diff" id="context"> private static final String m_webapp1 =
</pre><pre class="diff" id="removed">- "../../testdata/webapps/<span id="removedchars">template</span>";
</pre><pre class="diff" id="added">+ "../../testdata/webapps/<span id="addedchars">plain</span>";
</pre><pre class="diff" id="context"> private static final String m_webapp2 =
</pre><pre class="diff" id="removed">- "../../testdata/webapps/<span id="removedchars">template2</span>.war";
</pre><pre class="diff" id="added">+ "../../testdata/webapps/<span id="addedchars">plain</span>.war";
+ private static final String m_webapp3 =
+ "../../testdata/webapps/pico";
</pre><pre class="diff" id="context">
private int m_count = 1;
</pre><pre class="diff"><small id="info">@@ -81,6 +93,24 @@
</small></pre><pre class="diff" id="context"> null,
null );
container.start();
</pre><pre class="diff" id="added">+
+ WebConversation conversation = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( "http://localhost:10080/plain/message.txt" );
+ WebResponse response = conversation.getResponse( request );
+ String responseBody = response.getText();
+ assertEquals( "plain", responseBody );
+
+ request = new GetMethodWebRequest( "http://localhost:10080/plain/plain-servlet" );
+ response = conversation.getResponse( request );
+ responseBody = response.getText();
+ assertEquals( "org.codehaus.spice.jervlet.impl.PlainTestServlet", responseBody );
+
+ request = new GetMethodWebRequest( "http://localhost:10080/plain/plain-filter-servlet" );
+ response = conversation.getResponse( request );
+ responseBody = response.getText();
+ assertEquals( "org.codehaus.spice.jervlet.impl.PlainTestFilter "
+ + "org.codehaus.spice.jervlet.impl.PlainTestServlet", responseBody );
+
</pre><pre class="diff" id="context"> container.stop();
}
</pre><pre class="diff"><small id="info">@@ -93,37 +123,56 @@
</small></pre><pre class="diff" id="context"> public void testProperties() throws Exception
{
Properties properties = new Properties();
</pre><pre class="diff" id="removed">- properties.setProperty( "jetty.port", "<span id="removedchars">8421</span>" );
</pre><pre class="diff" id="added">+ properties.setProperty( "jetty.port", "<span id="addedchars">16842</span>" );
</pre><pre class="diff" id="context">
DefaultJettyContainerConfiguration configuration =
new DefaultJettyContainerConfiguration();
</pre><pre class="diff" id="removed">- configuration.setConfiguration( m_defaultConfiguration );
</pre><pre class="diff" id="added">+ configuration.setConfiguration( (new File( m_defaultConfiguration )).toURL() );
</pre><pre class="diff" id="context"> configuration.setProperties( properties );
PicoJettyContainer container = new PicoJettyContainer( configuration,
new NoopContextMonitor(),
new NoopListenerMonitor() );
container.start();
</pre><pre class="diff" id="added">+
+ WebConversation conversation = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( "http://localhost:16842/plain/plain-servlet" );
+ WebResponse response = conversation.getResponse( request );
+ String responseBody = response.getText();
+ assertEquals( "org.codehaus.spice.jervlet.impl.PlainTestServlet", responseBody );
+
+ request = new GetMethodWebRequest( "http://localhost:16842/plain/message.txt" );
+ response = conversation.getResponse( request );
+ responseBody = response.getText();
+ assertEquals( "plain", responseBody );
+
+ request = new GetMethodWebRequest( "http://localhost:16842/plain/plain-filter-servlet" );
+ response = conversation.getResponse( request );
+ responseBody = response.getText();
+ assertEquals( "org.codehaus.spice.jervlet.impl.PlainTestFilter "
+ + "org.codehaus.spice.jervlet.impl.PlainTestServlet", responseBody );
+
</pre><pre class="diff" id="context"> container.stop();
}
/**
</pre><pre class="diff" id="removed">- * Create an empty container and start, deploy a
- * webapp and stop. Also test that the context
</pre><pre class="diff" id="added">+ * Create an empty container and start, deploy
+ * and stop some webapps. Also test that the context
</pre><pre class="diff" id="context"> * are added and removed correctly.
*
* @throws Exception
*/
public void testEmptyWithWebapps() throws Exception
{
</pre><pre class="diff" id="removed">- Context context1 = getStandardContext( m_webapp1 );
- Context context2 = getStandardContext( m_webapp2 );
</pre><pre class="diff" id="context">
PicoJettyContainer container = new PicoJettyContainer( null, null, null );
container.start();
ContextHandler contextHandler = container.createContextHandler();
</pre><pre class="diff" id="added">+ Context context1 = getStandardContext( m_webapp1 );
+ Context context2 = getStandardContext( m_webapp2 );
+
</pre><pre class="diff" id="context"> contextHandler.addContext( context1 );
contextHandler.addContext( context2 );
</pre><pre class="diff"><small id="info">@@ -133,6 +182,19 @@
</small></pre><pre class="diff" id="context"> assertTrue( contextHandler.isStarted( context1 ) );
assertTrue( contextHandler.isStarted( context2 ) );
</pre><pre class="diff" id="added">+ Listener listener = new DefaultListener( "localhost", 16842, Listener.HTTP );
+ container.addListener( listener );
+ container.startListener( listener );
+
+ WebConversation conversation = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(
+ "http://localhost:16842/context1/plain-servlet" );
+ WebResponse response = conversation.getResponse( request );
+ String responseBody = response.getText();
+ assertEquals( "org.codehaus.spice.jervlet.impl.PlainTestServlet", responseBody );
+
+ container.stopListener( listener );
+
</pre><pre class="diff" id="context"> contextHandler.stopContext( context1 );
assertFalse( contextHandler.isStarted( context1 ) );
contextHandler.stopContext( context2 );
</pre><pre class="diff"><small id="info">@@ -149,27 +211,35 @@
</small></pre><pre class="diff" id="context"> }
/**
</pre><pre class="diff" id="removed">- * Test that a pico-servlet component gets instantiated
- *
- * --------------- UNDER CONSTRUCTION! ---------------
</pre><pre class="diff" id="added">+ * Test if pico-servlet components gets instantiated
</pre><pre class="diff" id="context"> *
</pre><pre class="diff" id="removed">- * @throws Exception
</pre><pre class="diff" id="added">+ * @throws Exception on all errors
</pre><pre class="diff" id="context"> */
</pre><pre class="diff" id="removed">- public void testEmptyWithPicoInstantiator() throws Exception
</pre><pre class="diff" id="added">+ public void testPicoInstantiator_AJP() throws Exception
</pre><pre class="diff" id="context"> {
DefaultPicoContainer pico = new DefaultPicoContainer();
</pre><pre class="diff" id="removed">- Context context = getPicoContext( m_webapp1, pico );
</pre><pre class="diff" id="added">+ Pinger pinger = new Pinger();
+ String message = Long.toString( System.currentTimeMillis() );
+ pinger.ping( message );
+ pico.registerComponentInstance( pinger );
+ Context context = getPicoContext( m_webapp3, pico );
</pre><pre class="diff" id="context">
PicoJettyContainer container = new PicoJettyContainer( null, null, null );
container.start();
</pre><pre class="diff" id="removed">- Listener listener = new DefaultListener( "localhost", <span id="removedchars">8421, Listener.HTTP</span> );
</pre><pre class="diff" id="added">+ Listener listener = new DefaultListener( "localhost", <span id="addedchars">16842, Listener.AJP13</span> );
</pre><pre class="diff" id="context"> container.addListener( listener );
container.startListener( listener );
ContextHandler contextHandler = container.createContextHandler();
contextHandler.addContext( context );
contextHandler.startContext( context );
</pre><pre class="diff" id="added">+
+ assertEquals( "org.codehaus.spice.jervlet.impl.pico.PicoTestFilter "
+ + message, pinger.getMessages().get( 1 ) );
+ assertEquals( "org.codehaus.spice.jervlet.impl.pico.PicoTestServlet "
+ + message, pinger.getMessages().get( 2 ) );
+
</pre><pre class="diff" id="context"> contextHandler.stopContext( context );
contextHandler.removeContext( context );
</pre><pre class="diff"><small id="info">@@ -178,6 +248,56 @@
</small></pre><pre class="diff" id="context"> }
/**
</pre><pre class="diff" id="added">+ * Test if pico-servlet components gets instantiated
+ *
+ * @throws Exception on all errors
+ */
+ public void testPicoInstantiator_HTTP() throws Exception
+ {
+ DefaultPicoContainer pico = new DefaultPicoContainer();
+ Pinger pinger = new Pinger();
+ String message = Long.toString( System.currentTimeMillis() );
+ pinger.ping( message );
+ pico.registerComponentInstance( pinger );
+ Context context = getPicoContext( m_webapp3, pico, "test" );
+
+ PicoJettyContainer container = new PicoJettyContainer();
+ container.start();
+
+ Listener listener = new DefaultListener( "localhost", 16842, Listener.HTTP );
+ container.addListener( listener );
+ container.startListener( listener );
+
+ ContextHandler contextHandler = container.createContextHandler();
+ contextHandler.addContext( context );
+ contextHandler.startContext( context );
+
+ WebConversation conversation = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( "http://localhost:16842/test/pico-servlet" );
+ WebResponse response = conversation.getResponse( request );
+ String responseBody = response.getText();
+
+ assertEquals( "org.codehaus.spice.jervlet.impl.pico.PicoTestServlet "
+ + message, responseBody );
+
+ conversation = new WebConversation();
+ request = new GetMethodWebRequest( "http://localhost:16842/test/pico-filter-servlet" );
+ response = conversation.getResponse( request );
+ responseBody = response.getText();
+
+ assertEquals( "org.codehaus.spice.jervlet.impl.pico.PicoTestFilter "
+ + message + " org.codehaus.spice.jervlet.impl.pico.PicoTestServlet "
+ + message, responseBody );
+
+ container.stop();
+
+ assertEquals( "org.codehaus.spice.jervlet.impl.pico.PicoTestFilter "
+ + message, pinger.getMessages().get( 1 ) );
+ assertEquals( "org.codehaus.spice.jervlet.impl.pico.PicoTestServlet "
+ + message, pinger.getMessages().get( 2 ) );
+ }
+
+ /**
</pre><pre class="diff" id="context"> * Create a basic context, using the standard servlet
* instantiator.
*/
</pre><pre class="diff"><small id="info">@@ -200,7 +320,7 @@
</small></pre><pre class="diff" id="context"> /**
* Create a Pico context, using <code>PicoInstantiator</code>.
*
</pre><pre class="diff" id="removed">- * @param filePath path to the web resource
</pre><pre class="diff" id="added">+ * @param filePath path to the web resource<span id="addedchars"> )</span>
</pre><pre class="diff" id="context"> * @param pico container for this context
* (used when instantiation servlets)
*/
</pre><pre class="diff"><small id="info">@@ -208,7 +328,22 @@
</small></pre><pre class="diff" id="context"> MutablePicoContainer pico )
throws MalformedURLException
{
</pre><pre class="diff" id="removed">- String path = "context" + m_count++;
</pre><pre class="diff" id="added">+ return getPicoContext( filePath, pico, "context" + m_count++ );
+ }
+
+ /**
+ * Create a Pico context, using <code>PicoInstantiator</code>.
+ *
+ * @param filePath path to the web resource
+ * @param pico container for this context
+ * (used when instantiation servlets)
+ * @param path the context's path
+ */
+ private Context getPicoContext( String filePath,
+ MutablePicoContainer pico,
+ String path )
+ throws MalformedURLException
+ {
</pre><pre class="diff" id="context"> String[] virtualHosts = null;
URL resource = (new File( filePath )).toURL();
boolean extractWAR = false;
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/containers/jetty<br /></span>
<div class="fileheader"><big><b>ShieldingJettyContainerTestCase.java</b></big> <small id="info">1.1 -> 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- ShieldingJettyContainerTestCase.java 5 Jul 2005 13:32:12 -0000 1.1
+++ ShieldingJettyContainerTestCase.java 22 Sep 2005 12:12:06 -0000 1.2
@@ -18,7 +18,7 @@
</small></pre><pre class="diff" id="context"> */
public class ShieldingJettyContainerTestCase extends TestCase
{
</pre><pre class="diff" id="removed">- private static final String DEFAULT_CONFIGURATION = "./testdata/jetty/jetty.xml";
</pre><pre class="diff" id="added">+ private static final String DEFAULT_CONFIGURATION = ".<span id="addedchars">./..</span>/testdata/jetty/jetty.xml";
</pre><pre class="diff" id="context">
/**
* Test a dafault plain Jetty, no conf but with the
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonTestFilter.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonTestFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonTestFilter.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,115 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import org.codehaus.spice.jervlet.impl.Pinger;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.ConsoleLogger;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.Serviceable;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * Avalon style servlet filter, for testing.
+ *
+ * @author Johan Sjoberg
+ */
+public class AvalonTestFilter implements Filter, LogEnabled, Serviceable
+{
+ /** Pinger */
+ Pinger m_pinger;
+
+ /** Logger */
+ Logger m_logger = new ConsoleLogger();
+
+ /**
+ * Get the logger
+ *
+ * @param logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Get references, the pinger, and ping it.
+ *
+ * @param serviceManager a service manager with the needed references
+ * @throws org.apache.avalon.framework.service.ServiceException if something goes wrong
+ */
+ public void service( ServiceManager serviceManager ) throws ServiceException
+ {
+ m_logger.info( "AvalonTestFilter service called." );
+ m_pinger = (Pinger)serviceManager.lookup( "pinger" );
+ m_pinger.ping( this.getClass().getName() + " "
+ + m_pinger.getMessages().get( 0 ).toString() );
+ }
+
+ /**
+ * Initialize the filter
+ */
+ public void init( FilterConfig filterConfig ) throws ServletException
+ {
+ m_logger.info( "AvalonTestFilter init called." );
+ }
+
+ /**
+ * Filter a transaction, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ * @param chain the next step
+ */
+ public void doFilter( ServletRequest request,
+ ServletResponse response,
+ FilterChain chain ) throws IOException, ServletException
+ {
+ m_logger.info( "AvalonTestFilter doFilter called." );
+ long before = System.currentTimeMillis();
+ try
+ {
+ response.getWriter().print( this.getClass().getName()
+ + " " + m_pinger.getMessages().get( 0 ).toString() + " " );
+ response.getWriter().flush();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ chain.doFilter( request, response );
+ long after = System.currentTimeMillis();
+ String name = "";
+ if( request instanceof HttpServletRequest )
+ {
+ name = ((HttpServletRequest)request).getRequestURI();
+ }
+ m_logger.info( "AvalonTestFilter processing for " + name + " took "
+ + ( after - before ) + "ms." );
+ }
+
+ /**
+ * Destroy the filter
+ */
+ public void destroy()
+ {
+ m_logger.info( "AvalonTestFilter destroy called." );
+ }
+}
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/avalon<br /></span>
<div class="fileheader" id="added"><big><b>AvalonTestServlet.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N AvalonTestServlet.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AvalonTestServlet.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,83 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.avalon;
+
+import org.codehaus.spice.jervlet.impl.Pinger;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.ConsoleLogger;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * Avalon style servlet filter, for testing.
+ *
+ * @author Johan Sjoberg
+ */
+public class AvalonTestServlet extends HttpServlet
+ implements LogEnabled, Serviceable
+{
+ /** Pinger */
+ Pinger m_pinger;
+
+ /** Logger */
+ Logger m_logger = new ConsoleLogger();
+
+ /**
+ * Get the logger
+ *
+ * @param logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Get references, the pinger, and ping it.
+ *
+ * @param serviceManager a service manager with the needed references
+ * @throws ServiceException if something goes wrong
+ */
+ public void service( ServiceManager serviceManager ) throws ServiceException
+ {
+ m_logger.info( "AvalonTestServlet service called." );
+ m_pinger = (Pinger)serviceManager.lookup( "pinger" );
+ m_pinger.ping( this.getClass().getName() + " "
+ + m_pinger.getMessages().get( 0 ).toString() );
+ }
+
+ /**
+ * Perform an HTTP GET, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ */
+ public void doGet( HttpServletRequest request, HttpServletResponse response )
+ {
+ m_logger.info( "AvalonTestServlet doGet called." );
+ try
+ {
+ response.getWriter().print( this.getClass().getName()
+ + " " + m_pinger.getMessages().get( 0 ).toString() );
+ response.getWriter().flush();
+ response.getWriter().close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/dna<br /></span>
<div class="fileheader" id="added"><big><b>DNATestFilter.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DNATestFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DNATestFilter.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,114 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.dna;
+
+import org.codehaus.spice.jervlet.impl.Pinger;
+import org.codehaus.dna.Composable;
+import org.codehaus.dna.Logger;
+import org.codehaus.dna.ResourceLocator;
+import org.codehaus.dna.MissingResourceException;
+import org.codehaus.dna.LogEnabled;
+import org.codehaus.dna.impl.ConsoleLogger;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * DNA style servlet filter, for testing.
+ *
+ * @author Johan Sjoberg
+ */
+public class DNATestFilter implements Filter, LogEnabled, Composable
+{
+ /** Pinger */
+ Pinger m_pinger;
+
+ /** Logger */
+ Logger m_logger = new ConsoleLogger();
+
+ /**
+ * Get the logger
+ *
+ * @param logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Get references, the pinger, and ping it.
+ *
+ * @param locator a service manager with the needed references
+ * @throws org.codehaus.dna.MissingResourceException if something goes wrong
+ */
+ public void compose( ResourceLocator locator ) throws MissingResourceException
+ {
+ m_logger.info( "DNATestFilter service called." );
+ m_pinger = (Pinger)locator.lookup( "pinger" );
+ m_pinger.ping( this.getClass().getName() + " "
+ + m_pinger.getMessages().get( 0 ).toString() );
+ }
+
+ /**
+ * Initialize the filter
+ */
+ public void init( FilterConfig filterConfig ) throws ServletException
+ {
+ m_logger.info( "DNATestFilter init called." );
+ }
+
+ /**
+ * Filter a transaction, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ * @param chain the next step
+ */
+ public void doFilter( ServletRequest request,
+ ServletResponse response,
+ FilterChain chain ) throws IOException, ServletException
+ {
+ m_logger.info( "DNATestFilter doFilter called." );
+ long before = System.currentTimeMillis();
+ try
+ {
+ response.getWriter().print( this.getClass().getName()
+ + " " + m_pinger.getMessages().get( 0 ).toString() + " " );
+ response.getWriter().flush();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ chain.doFilter( request, response );
+ long after = System.currentTimeMillis();
+ String name = "";
+ if( request instanceof HttpServletRequest )
+ {
+ name = ((HttpServletRequest)request).getRequestURI();
+ }
+ m_logger.info( "DNATestFilter processing for " + name + " took "
+ + ( after - before ) + "ms." );
+ }
+
+ /**
+ * Destroy the filter
+ */
+ public void destroy()
+ {
+ m_logger.info( "DNATestFilter destroy called." );
+ }
+}
</pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/dna<br /></span>
<div class="fileheader" id="added"><big><b>DNATestServlet.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DNATestServlet.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DNATestServlet.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,83 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.dna;
+
+import org.codehaus.spice.jervlet.impl.Pinger;
+import org.codehaus.dna.LogEnabled;
+import org.codehaus.dna.Composable;
+import org.codehaus.dna.Logger;
+import org.codehaus.dna.MissingResourceException;
+import org.codehaus.dna.ResourceLocator;
+import org.codehaus.dna.impl.ConsoleLogger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * DNA style servlet filter, for testing.
+ *
+ * @author Johan Sjoberg
+ */
+public class DNATestServlet extends HttpServlet
+ implements LogEnabled, Composable
+{
+ /** Pinger */
+ Pinger m_pinger;
+
+ /** Logger */
+ Logger m_logger = new ConsoleLogger();
+
+ /**
+ * Get the logger
+ *
+ * @param logger
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Get resources, the pinger, and ping it.
+ *
+ * @param locator a resource locator with the needed resources
+ * @throws MissingResourceException if something goes wrong
+ */
+ public void compose( ResourceLocator locator ) throws MissingResourceException
+ {
+ m_logger.info( "DNATestServlet service called." );
+ m_pinger = (Pinger)locator.lookup( "pinger" );
+ m_pinger.ping( this.getClass().getName() + " "
+ + m_pinger.getMessages().get( 0 ).toString() );
+ }
+
+ /**
+ * Perform an HTTP GET, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ */
+ public void doGet( HttpServletRequest request, HttpServletResponse response )
+ {
+ m_logger.info( "DNATestServlet doGet called." );
+ try
+ {
+ response.getWriter().print( this.getClass().getName()
+ + " " + m_pinger.getMessages().get( 0 ).toString() );
+ response.getWriter().flush();
+ response.getWriter().close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader" id="added"><big><b>PicoTestFilter.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoTestFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoTestFilter.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,94 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.pico;
+
+import org.codehaus.spice.jervlet.impl.Pinger;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * Picocontainer style servlet filter, for testing.
+ *
+ * @author Johan Sjoberg
+ */
+public class PicoTestFilter implements Filter
+{
+ /** Pinger */
+ Pinger m_pinger;
+
+ /**
+ * Get a pinger and ping back.
+ *
+ * @param pinger the Pinger to ping
+ */
+ public PicoTestFilter( Pinger pinger )
+ {
+ System.out.println( "PicoTestFilter created." );
+ m_pinger = pinger;
+ m_pinger.ping( this.getClass().getName() + " "
+ + m_pinger.getMessages().get( 0 ).toString() );
+ }
+
+ /**
+ * Initialize the filter
+ */
+ public void init( FilterConfig filterConfig ) throws ServletException
+ {
+ System.out.println( "PicoTestFilter init called." );
+ }
+
+ /**
+ * Filter a transaction, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ * @param chain the next step
+ */
+ public void doFilter( ServletRequest request,
+ ServletResponse response,
+ FilterChain chain ) throws IOException, ServletException
+ {
+ System.out.println( "PicoTestFilter doFilter called." );
+ long before = System.currentTimeMillis();
+ try
+ {
+ response.getWriter().print( this.getClass().getName()
+ + " " + m_pinger.getMessages().get( 0 ).toString() + " " );
+ response.getWriter().flush();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ chain.doFilter( request, response );
+ long after = System.currentTimeMillis();
+ String name = "";
+ if( request instanceof HttpServletRequest )
+ {
+ name = ((HttpServletRequest)request).getRequestURI();
+ }
+ System.out.println( "PicoTestFilter processing for " + name + " took "
+ + ( after - before ) + "ms." );
+ }
+
+ /**
+ * Destroy the filter
+ */
+ public void destroy()
+ {
+ System.out.println( "PicoTestFilter destroy called." );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl/pico<br /></span>
<div class="fileheader" id="added"><big><b>PicoTestServlet.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PicoTestServlet.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PicoTestServlet.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,62 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl.pico;
+
+import org.codehaus.spice.jervlet.impl.Pinger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Picocontainer style servlet, for testing.
+ *
+ * @author Johan Sjoberg
+ */
+public class PicoTestServlet extends HttpServlet
+{
+ /** Pinger */
+ Pinger m_pinger;
+
+ /**
+ * Get a pinger and ping back.
+ *
+ * @param pinger the Pinger to ping
+ */
+ public PicoTestServlet( Pinger pinger )
+ {
+ System.out.println( "PicoTestServlet created." );
+ m_pinger = pinger;
+ m_pinger.ping( this.getClass().getName() + " "
+ + m_pinger.getMessages().get( 0 ).toString() );
+ }
+
+ /**
+ * Perform an HTTP GET, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ */
+ public void doGet( HttpServletRequest request, HttpServletResponse response )
+ {
+ System.out.println( "PicoTestServlet doGet called." );
+ try
+ {
+ response.getWriter().print( this.getClass().getName()
+ + " " + m_pinger.getMessages().get( 0 ).toString() );
+ response.getWriter().flush();
+ response.getWriter().close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ }
+}
</pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>Pinger.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N Pinger.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Pinger.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,34 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sjoberg
+ * Date: 04-Sep-2005
+ * Time: 23:50:51
+ * To change this template use File | Settings | File Templates.
+ */
+public class Pinger
+{
+ ArrayList m_messages = new ArrayList();
+
+ public void ping( String message )
+ {
+ m_messages.add( message );
+ }
+
+ public List getMessages()
+ {
+ return m_messages;
+ }
+}
+
</pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>PlainTestFilter.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PlainTestFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PlainTestFilter.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,74 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * Test servlet-filter
+ *
+ * @author Johan Sjoberg
+ */
+public class PlainTestFilter implements Filter
+{
+ /**
+ * Initialize the filter
+ */
+ public void init( FilterConfig filterConfig ) throws ServletException
+ {
+ System.out.println( "PlainTestFilter init called." );
+ }
+
+ /**
+ * Filter a transaction
+ *
+ * @param request the request
+ * @param response the response
+ * @param chain the next step
+ */
+ public void doFilter( ServletRequest request,
+ ServletResponse response,
+ FilterChain chain ) throws IOException, ServletException
+ {
+ System.out.println( "PlainTestFilter doFilter called." );
+ long before = System.currentTimeMillis();
+ try
+ {
+ response.getWriter().print( this.getClass().getName() + " " );
+ response.getWriter().flush();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ chain.doFilter( request, response );
+ long after = System.currentTimeMillis();
+ String name = "";
+ if( request instanceof HttpServletRequest )
+ {
+ name = ((HttpServletRequest)request).getRequestURI();
+ }
+ System.out.println( "PlainTestFilter processing for " + name + " took "
+ + ( after - before ) + "ms." );
+ }
+
+ /**
+ * Destroy the filter
+ */
+ public void destroy()
+ {
+ System.out.println( "PlainTestFilter destroy called." );
+ }
+}
</pre></div>
<hr /><a name="file12" /><div class="file">
<span class="pathname" id="added">spice/components/jervlet/src/test/org/codehaus/spice/jervlet/impl<br /></span>
<div class="fileheader" id="added"><big><b>PlainTestServlet.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PlainTestServlet.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PlainTestServlet.java 22 Sep 2005 12:12:06 -0000 1.1
@@ -0,0 +1,43 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.jervlet.impl;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Test servlet
+ *
+ * @author Johan Sjoberg
+ */
+public class PlainTestServlet extends HttpServlet
+{
+ /**
+ * Perform an HTTP GET, meaning write back whatever the pinger
+ * was pinged with.
+ *
+ * @param request the request
+ * @param response the response
+ */
+ public void doGet( HttpServletRequest request, HttpServletResponse response )
+ {
+ System.out.println( "PlainTestServlet doGet called." );
+ try
+ {
+ response.getWriter().print( this.getClass().getName() );
+ response.getWriter().flush();
+ response.getWriter().close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ }
+}
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.8</small></center>
</body></html>