Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/data.txt.gz
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/data.txt.gz?rev=677925&view=auto
==============================================================================
Binary file - no diff available.
Propchange: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/data.txt.gz
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/favicon.ico
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/favicon.ico?rev=677925&view=auto
==============================================================================
Binary file - no diff available.
Propchange: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/favicon.ico
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/index.html
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/index.html?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/index.html (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/index.html Fri Jul
18 08:01:51 2008
@@ -0,0 +1,47 @@
+<HTML>
+ <HEAD>
+ <TITLE>Powered By Jetty</TITLE>
+ <META http-equiv="Pragma" content="no-cache">
+ <META http-equiv="Cache-Control" content="no-cache,no-store">
+ </HEAD>
+<BODY>
+<A HREF="http://jetty.mortbay.org"><IMG SRC="jetty_banner.gif"></A>
+<h1>Welcome to Jetty 6</h1>
+<p>
+This is the Test webapp for the Jetty 6 HTTP Server and Servlet Container.
+For more information about Jetty, please visit our
+<a href="http://jetty.mortbay.org">website</a>
+or <a href="http://docs.codehaus.org/display/JETTY/Jetty+Wiki">wiki</a>.
+Commercial support for Jetty is available via <a
href="http://www.webtide.com">webtide</a>.
+</p>
+<p>
+This is a test context that serves:
+<ul>
+<li>static content (
+<a href="d.txt">tiny</a>,
+<a href="da.txt">small</a>,
+<a href="dat.txt">medium</a>,
+<a href="data.txt">large</a>,
+<a href="data.txt.gz">large gziped</a>)</li>
+<li>a <a href="hello/">Hello World Servlet</a></li>
+<li>a <a href="dump/info">Request Dump Servlet</a></li>
+<li>a <a href="session/">Session Dump Servlet</a></li>
+<li>a <a href="cookie/">Cookie Dump Servlet</a></li>
+<li>a <a href="snoop.jsp">Request Dump JSP</a></li>
+<li>a <a href="jsp/">Other JSP Tests</a></li>
+<li>a <a href="dispatch">Dispatcher Servlet</a></li>
+<li>a <a href="cgi-bin/hello.sh">CGI script</a>(unix only)</li>
+</ul>
+</p>
+
+<p>
+Other contexts:
+<ul>
+<li> a demo of the <a href="/test-jaas">JAAS features</a></li>
+</ul>
+</p>
+
+This webapp is deployed in $JETTY_HOME/webapp/test and configured by
$JETTY_HOME/contexts/test.xml
+
+</BODY>
+</HTML>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jetty_banner.gif
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jetty_banner.gif?rev=677925&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jetty_banner.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean1.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean1.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean1.jsp
(added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean1.jsp Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,15 @@
+<html>
+<%@ page session="true"%>
+<body>
+<jsp:useBean id='counter' scope='session' class='com.acme.Counter'
type="com.acme.Counter" />
+
+<h1>JSP1.2 Beans: 1</h1>
+
+Counter accessed <jsp:getProperty name="counter" property="count"/> times.<br/>
+Counter last accessed by <jsp:getProperty name="counter" property="last"/><br/>
+<jsp:setProperty name="counter" property="last" value="<%=
request.getRequestURI()%>"/>
+
+<a href="bean2.jsp">Goto bean2.jsp</a>
+
+</body>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean2.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean2.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean2.jsp
(added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/bean2.jsp Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,15 @@
+<html>
+<%@ page session="true"%>
+<body>
+<jsp:useBean id='counter' scope='session' class='com.acme.Counter'
type="com.acme.Counter" />
+
+<h1>JSP1.2 Beans: 2</h1>
+
+Counter accessed <jsp:getProperty name="counter" property="count"/> times.<br/>
+Counter last accessed by <jsp:getProperty name="counter" property="last"/><br/>
+<jsp:setProperty name="counter" property="last" value="<%=
request.getRequestURI()%>"/>
+
+<a href="bean1.jsp">Goto bean1.jsp</a>
+
+</body>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/dump.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/dump.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/dump.jsp (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/dump.jsp Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,23 @@
+<html><head>
+<%@ page import="java.util.Enumeration" %>
+</head><body>
+<h1>JSP Dump</h1>
+
+<table border="1">
+<tr><th>Request URI:</th><td><%= request.getRequestURI() %></td></tr>
+<tr><th>ServletPath:</th><td><%= request.getServletPath() %></td></tr>
+<tr><th>PathInfo:</th><td><%= request.getPathInfo() %></td></tr>
+
+<%
+ Enumeration e =request.getParameterNames();
+ while(e.hasMoreElements())
+ {
+ String name = (String)e.nextElement();
+%>
+<tr>
+ <th>getParameter("<%= name %>")</th>
+ <td><%= request.getParameter(name) %></td></tr>
+<% } %>
+
+</table>
+</body></html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/expr.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/expr.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/expr.jsp (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/expr.jsp Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,23 @@
+<html>
+<h1>JSP2.0 Expressions</h1>
+
+<table border="1">
+ <tr><th>Expression</th><th>Result</th></tr>
+ <tr>
+ <td>\${param["A"]}</td>
+ <td>${param["A"]} </td>
+ </tr><tr>
+ <td>\${header["host"]}</td>
+ <td>${header["host"]}</td>
+ </tr><tr>
+ <td>\${header["user-agent"]}</td>
+ <td>${header["user-agent"]}</td>
+ </tr><tr>
+ <td>\${1+1}</td>
+ <td>${1+1}</td>
+ </tr><tr>
+ <td>\${param["A"] * 2}</td>
+ <td>${param["A"] * 2} </td>
+ </tr>
+</table>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/index.html
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/index.html?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/index.html
(added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/index.html Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,15 @@
+<html>
+<body>
+
+<h1>Day2</h1>
+
+<a href="dump.jsp">JSP 1.2 embedded java</a><br/>
+<a href="bean1.jsp">JSP 1.2 Bean demo</a><br/>
+<a href="tag.jsp">JSP 1.2 BodyTag demo</a><br/>
+<a href="tag2.jsp">JSP 2.0 SimpleTag demo</a><br/>
+<a href="tagfile.jsp">JSP 2.0 Tag File demo</a><br/>
+<a href="expr.jsp?A=1">JSP 2.0 Tag Expression</a><br/>
+
+
+</body>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag.jsp (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag.jsp Fri Jul
18 08:01:51 2008
@@ -0,0 +1,16 @@
+<html>
+<body>
+
+<%@ taglib uri="http://www.acme.com/taglib" prefix="acme" %>
+
+<small><acme:date tz="GMT">EEE, dd/MMM/yyyy HH:mm:ss
ZZZ</acme:date>
+==></small>
+<acme:date tz="GMT">EEE, dd/MMM/yyyy HH:mm:ss ZZZ</acme:date>
+<br/>
+<small><acme:date tz="EST">EEE, dd-MMM-yyyy HH:mm:ss
ZZZ</acme:date>
+==></small>
+<acme:date tz="EST">EEE, dd-MMM-yyyy HH:mm:ss ZZZ</acme:date>
+<br/>
+
+</body>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag2.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag2.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag2.jsp (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tag2.jsp Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,19 @@
+<html>
+<body>
+
+<%@ taglib uri="http://www.acme.com/taglib2" prefix="acme" %>
+
+<acme:date2 format="long">
+ On ${day} of ${month} in the year ${year}
+</acme:date2>
+
+<br/>
+
+<acme:date2 format="short">
+ ${day} - ${month} - ${year}
+</acme:date2>
+
+<br/>
+
+</body>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tagfile.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tagfile.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tagfile.jsp
(added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/jsp/tagfile.jsp Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,37 @@
+<%@ taglib prefix="acme" tagdir="/WEB-INF/tags" %>
+<html>
+ <head>
+ </head>
+ <body>
+ <h1>JSP 2.0 Tag File Example</h1>
+ <hr>
+ <p>Panel tag created from JSP fragment file in WEB-INF/tags
+ <hr>
+ <table border="0">
+ <tr valign="top">
+ <td>
+ <acme:panel color="#ff8080" bgcolor="#ffc0c0" title="Panel 1">
+ First panel.<br/>
+ </acme:panel>
+ </td>
+ <td>
+ <acme:panel color="#80ff80" bgcolor="#c0ffc0" title="Panel 2">
+ Second panel.<br/>
+ Second panel.<br/>
+ Second panel.<br/>
+ Second panel.<br/>
+ </acme:panel>
+ </td>
+ <td>
+ <acme:panel color="#8080ff" bgcolor="#c0c0ff" title="Panel 3">
+ Third panel.<br/>
+ <acme:panel color="#ff80ff" bgcolor="#ffc0ff" title="Inner">
+ A panel in a panel.
+ </acme:panel>
+ Third panel.<br/>
+ </acme:panel>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logon.html
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logon.html?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logon.html (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logon.html Fri Jul
18 08:01:51 2008
@@ -0,0 +1,20 @@
+<HTML>
+<H1>FORM Authentication demo</H1>
+<form method="POST" action="j_security_check">
+<table border="0" cellspacing="2" cellpadding="1">
+<tr>
+ <td>Username:</td>
+ <td><input size="12" value="" name="j_username" maxlength="25"
type="text"></td>
+</tr>
+<tr>
+ <td>Password:</td>
+ <td><input size="12" value="" name="j_password" maxlength="25"
type="password"></td>
+</tr>
+<tr>
+ <td colspan="2" align="center">
+ <input name="submit" type="submit" value="Login">
+ </td>
+</tr>
+</table>
+</form>
+</HTML>
\ No newline at end of file
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logonError.html
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logonError.html?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logonError.html
(added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/logonError.html Fri
Jul 18 08:01:51 2008
@@ -0,0 +1,5 @@
+<HTML>
+<H1>Authentication ERROR</H1>
+Username, password or role incorrect.
+
+</HTML>
\ No newline at end of file
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/snoop.jsp
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/snoop.jsp?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/snoop.jsp (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/webapps/test/snoop.jsp Fri Jul
18 08:01:51 2008
@@ -0,0 +1,201 @@
+<HTML>
+<HEAD>
+ <TITLE>JSP snoop page</TITLE>
+ <%@ page import="javax.servlet.http.HttpUtils,java.util.Enumeration" %>
+</HEAD>
+<BODY>
+
+<H1>WebApp JSP Snoop page</H1>
+
+<H2>Request information</H2>
+
+<TABLE>
+<TR>
+ <TH align=right>Requested URL:</TH>
+ <TD><%= HttpUtils.getRequestURL(request) %></TD>
+</TR>
+<TR>
+ <TH align=right>Request method:</TH>
+ <TD><%= request.getMethod() %></TD>
+</TR>
+<TR>
+ <TH align=right>Request URI:</TH>
+ <TD><%= request.getRequestURI() %></TD>
+</TR>
+<TR>
+ <TH align=right>Request protocol:</TH>
+ <TD><%= request.getProtocol() %></TD>
+</TR>
+<TR>
+ <TH align=right>Servlet path:</TH>
+ <TD><%= request.getServletPath() %></TD>
+</TR>
+<TR>
+ <TH align=right>Path info:</TH>
+ <TD><%= request.getPathInfo() %></TD>
+</TR>
+<TR>
+ <TH align=right>Path translated:</TH>
+ <TD><%= request.getPathTranslated() %></TD>
+</TR>
+<TR>
+ <TH align=right>Query string:</TH>
+ <TD><% if(request.getQueryString()!=null)
out.write(request.getQueryString().replaceAll("<",
"<").replaceAll(">",">")); %></TD>
+</TR>
+<TR>
+ <TH align=right>Content length:</TH>
+ <TD><%= request.getContentLength() %></TD>
+</TR>
+<TR>
+ <TH align=right>Content type:</TH>
+ <TD><%= request.getContentType() %></TD>
+<TR>
+<TR>
+ <TH align=right>Server name:</TH>
+ <TD><%= request.getServerName() %></TD>
+<TR>
+<TR>
+ <TH align=right>Server port:</TH>
+ <TD><%= request.getServerPort() %></TD>
+<TR>
+<TR>
+ <TH align=right>Remote user:</TH>
+ <TD><%= request.getRemoteUser() %></TD>
+<TR>
+<TR>
+ <TH align=right>Remote address:</TH>
+ <TD><%= request.getRemoteAddr() %></TD>
+<TR>
+<TR>
+ <TH align=right>Remote host:</TH>
+ <TD><%= request.getRemoteHost() %></TD>
+<TR>
+<TR>
+ <TH align=right>Authorization scheme:</TH>
+ <TD><%= request.getAuthType() %></TD>
+<TR>
+</TABLE>
+
+<%
+ Enumeration e = request.getHeaderNames();
+ if(e != null && e.hasMoreElements()) {
+%>
+<H2>Request headers</H2>
+
+<TABLE>
+<TR>
+ <TH align=left>Header:</TH>
+ <TH align=left>Value:</TH>
+</TR>
+<%
+ while(e.hasMoreElements()) {
+ String k = (String) e.nextElement();
+%>
+<TR>
+ <TD><%= k %></TD>
+ <TD><%= request.getHeader(k) %></TD>
+</TR>
+<%
+ }
+%>
+</TABLE>
+<%
+ }
+%>
+
+
+<%
+ e = request.getParameterNames();
+ if(e != null && e.hasMoreElements()) {
+%>
+<H2>Request parameters</H2>
+<TABLE>
+<TR valign=top>
+ <TH align=left>Parameter:</TH>
+ <TH align=left>Value:</TH>
+ <TH align=left>Multiple values:</TH>
+</TR>
+<%
+ while(e.hasMoreElements()) {
+ String k = (String) e.nextElement();
+ String val = request.getParameter(k);
+ String vals[] = request.getParameterValues(k);
+%>
+<TR valign=top>
+ <TD><%= k.replaceAll("<", "<").replaceAll(">",">") %></TD>
+ <TD><%= val.replaceAll("<", "<").replaceAll(">",">") %></TD>
+ <TD><%
+ for(int i = 0; i < vals.length; i++) {
+ if(i > 0)
+ out.print("<BR>");
+ out.print(vals[i].replaceAll("<",
"<").replaceAll(">",">"));
+ }
+ %></TD>
+</TR>
+<%
+ }
+%>
+</TABLE>
+<%
+ }
+%>
+
+
+<%
+ e = request.getAttributeNames();
+ if(e != null && e.hasMoreElements()) {
+%>
+<H2>Request Attributes</H2>
+<TABLE>
+<TR valign=top>
+ <TH align=left>Attribute:</TH>
+ <TH align=left>Value:</TH>
+</TR>
+<%
+ while(e.hasMoreElements()) {
+ String k = (String) e.nextElement();
+ Object val = request.getAttribute(k);
+%>
+<TR valign=top>
+ <TD><%= k.replaceAll("<", "<").replaceAll(">",">") %></TD>
+ <TD><%= val.toString().replaceAll("<", "<").replaceAll(">",">")
%></TD>
+</TR>
+<%
+ }
+%>
+</TABLE>
+<%
+ }
+%>
+
+
+<%
+ e = getServletConfig().getInitParameterNames();
+ if(e != null && e.hasMoreElements()) {
+%>
+<H2>Init parameters</H2>
+<TABLE>
+<TR valign=top>
+ <TH align=left>Parameter:</TH>
+ <TH align=left>Value:</TH>
+</TR>
+<%
+ while(e.hasMoreElements()) {
+ String k = (String) e.nextElement();
+ String val = getServletConfig().getInitParameter(k);
+%>
+<TR valign=top>
+ <TD><%= k %></TD>
+ <TD><%= val %></TD>
+</TR>
+<%
+ }
+%>
+</TABLE>
+<%
+ }
+%>
+
+</BODY>
+</HTML>
+
Added:
turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyServiceTest.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyServiceTest.java?rev=677925&view=auto
==============================================================================
---
turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyServiceTest.java
(added)
+++
turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyServiceTest.java
Fri Jul 18 08:01:51 2008
@@ -0,0 +1,201 @@
+package org.apache.fulcrum.jetty;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.avalon.framework.activity.Startable;
+import org.apache.avalon.framework.configuration.Reconfigurable;
+
+import java.net.URL;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Testing the embedded Jetty container.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Siegfried Goeschl</a>
+ */
+public class JettyServiceTest extends BaseUnitTest
+{
+ /** the service to test */
+ private JettyService service;
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public JettyServiceTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test setup
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ try
+ {
+ service = (JettyService) this.lookup(JettyService.class.getName());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Add all of our test suites
+ */
+ public static Test suite()
+ {
+ TestSuite suite= new TestSuite();
+ suite.addTest( new JettyServiceTest("testGetJettyService") );
+ suite.addTest( new JettyServiceTest("testInvokeTestServlets") );
+ suite.addTest( new JettyServiceTest("testInvokeTestJsps") );
+ suite.addTest( new JettyServiceTest("testStartStop") );
+ return suite;
+ }
+
+ /**
+ * @return the JettyService service to be used
+ */
+ protected JettyService getService()
+ {
+ return this.service;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Start of unit tests
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Ensure that we start Jetty properly
+ */
+ public void testGetJettyService() throws Exception
+ {
+ assertTrue(this.service.getServer() != null);
+ }
+
+ /**
+ * Fetch the start page
+ */
+ public void testGetIndexPage() throws Exception
+ {
+ String result = this.getURLContent("http://localhost:8080/test/");
+ assertTrue(result.length() > 100);
+ }
+
+ /**
+ * Invoke all servlet examples
+ */
+ public void testInvokeTestServlets() throws Exception
+ {
+ String result = null;
+
+ // 'Hello World' servlet
+ result = this.getURLContent("http://localhost:9080/test/hello/");
+ assertTrue(result.indexOf("Hello") > 0);
+
+ // 'Request Dump' servlet
+ result = this.getURLContent("http://localhost:9080/test/dump/info");
+ assertTrue(result.length() > 100);
+
+ // 'Session Dump' servlet
+ result = this.getURLContent("http://localhost:9080/test/session/");
+ assertTrue(result.length() > 100);
+
+ // 'Cookie Dump' servlet
+ result = this.getURLContent("http://localhost:9080/test/cookie/");
+ assertTrue(result.length() > 100);
+ }
+
+ /**
+ * Invoke a JSP examples
+ */
+ public void testInvokeTestJsps() throws Exception
+ {
+ String result = null;
+
+ // invoke Snoop JSP
+ result = this.getURLContent("http://localhost:9080/test/snoop.jsp");
+ assertTrue(result.indexOf("WebApp JSP Snoop page") > 0);
+
+ // invoke Snoop JSP
+ result =
this.getURLContent("http://localhost:9080/test/jsp/bean1.jsp");
+ assertTrue(result.indexOf("Counter accessed 1 times.") > 0);
+
+ }
+
+ /**
+ * Reconfigure a running Jetty using the Avalon Lifycyle 'stop',
'reconfigure', 'start'
+ */
+ public void testStartStop() throws Exception
+ {
+ String result = null;
+
+ ((Startable) this.getService()).stop();
+
+ try
+ {
+ result = this.getURLContent("http://localhost:9080/test/hello/");
+ fail("The Jetty instance should be stopped");
+ }
+ catch(Exception e)
+ {
+ // expected
+ }
+
+ ((Reconfigurable) this.getService()).reconfigure(null);
+ ((Startable) this.getService()).start();
+
+ result = this.getURLContent("http://localhost:9080/test/hello/");
+ assertTrue(result.indexOf("Hello") > 0);
+ }
+
+ /**
+ * Quick-and-dirty implementation to downlaod te content from an URL.
+ *
+ * @param urlString the URL to be invoked
+ * @return the content loaded from the URL
+ * @throws Exception invoking the URL failed
+ */
+ private String getURLContent(String urlString) throws Exception
+ {
+ StringBuffer result = new StringBuffer(8192);
+ URL url = new URL(urlString);
+ InputStream is = url.openStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ char[] buffer = new char[8192];
+ while(reader.read(buffer) > 0) {
+ result.append(buffer);
+ }
+ is.close();
+ return result.toString();
+ }
+}
Added:
turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyTestRunner.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyTestRunner.java?rev=677925&view=auto
==============================================================================
---
turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyTestRunner.java
(added)
+++
turbine/fulcrum/trunk/jetty/src/test/org/apache/fulcrum/jetty/JettyTestRunner.java
Fri Jul 18 08:01:51 2008
@@ -0,0 +1,78 @@
+package org.apache.fulcrum.jetty;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+
+import java.net.URL;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Testing the embedded Jetty container.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Siegfried Goeschl</a>
+ */
+public class JettyTestRunner extends BaseUnitTest
+{
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public JettyTestRunner(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test setup
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ try
+ {
+ this.lookup(JettyService.class.getName());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Start of unit tests
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Run the Jetty instance for 600 seconds to do some manual testing
+ */
+ public void testRunJetty() throws Exception
+ {
+ Thread.sleep(600000);
+ }
+}
\ No newline at end of file
Added: turbine/fulcrum/trunk/jetty/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/xdocs/changes.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/xdocs/changes.xml (added)
+++ turbine/fulcrum/trunk/jetty/xdocs/changes.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<document>
+ <properties>
+ <title>Fulcrum Jetty Service</title>
+ <author email="[EMAIL PROTECTED]">Siegfried Goeschl</author>
+ </properties>
+
+ <body>
+ <release version="1.0.0-SNAPSHOT" date="as in SVN">
+ <action dev="sgoeschl" type="add">
+ First cut for an embeddable Jetty server
+ </action>
+ </release>
+ </body>
+</document>
+
Added: turbine/fulcrum/trunk/jetty/xdocs/configuration.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/xdocs/configuration.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/xdocs/configuration.xml (added)
+++ turbine/fulcrum/trunk/jetty/xdocs/configuration.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<document>
+ <properties>
+ <title>Fulcrum Jetty Service</title>
+ <author email="[EMAIL PROTECTED]">Siegfried Goeschl</author>
+ </properties>
+ <body>
+ <section name="Configuration">
+
+ <subsection name="Role Configuration">
+ <source><![CDATA[
+<role
+ name="org.apache.fulcrum.jetty.JettyService"
+ shorthand="JettyService"
+ default-class="org.apache.fulcrum.jetty.impl.JettyServiceImpl"
+ description="Starts a Jetty container as Avalon service"
+/>
+ ]]></source>
+ </subsection>
+
+ <subsection name="Component Configuration">
+ <table>
+ <tr>
+ <th>Item</th>
+ <th>Datatype</th>
+ <th>Cardinality</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>configurations</td>
+ <td>Complex</td>
+ <td>[1]</td>
+ <td>
+ Contains a list of Jetty configuration files
+ </td>
+ </tr>
+ <tr>
+ <td>configurations\configuration</td>
+ <td>String</td>
+ <td>[1..n]</td>
+ <td>
+ Contains the location of a Jetty configuration file. The
configuration
+ is loaded from the file system or from the classpath.
+ </td>
+ </tr>
+ <tr>
+ <td>properties</td>
+ <td>Complex</td>
+ <td>[0|1]</td>
+ <td>
+ Contains a list of system properties used for configuring Jetty
+ </td>
+ </tr>
+ <tr>
+ <td>properties\property</td>
+ <td>String</td>
+ <td>[0..n]</td>
+ <td>
+ Contains a single system property
+ </td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Component Configuration Example 1">
+ <p>A simple configuration to start Jetty</p>
+ <source><![CDATA[
+<JettyService>
+ <configurations>
+ <configuration>./src/test/jetty/etc/jetty.xml</configLocation>
+ </configurations>
+</JettyService>
+ ]]></source>
+ </subsection>
+
+ <subsection name="Component Configuration Example 2">
+ <p>
+ A configuration loading three Jetty configuration files and setting
+ a few system properties to configure Jetty.
+ </p>
+ <source><![CDATA[
+<JettyService>
+ <configurations>
+ <configuration>./src/test/jetty/etc/jetty.xml</configLocation>
+ <configuration>./src/test/jetty/etc/jetty-logging.xml</configuration>
+ <configuration>./src/test/jetty/etc/jetty-jaas.xml</configuration>
+ </configurations>
+ <properties>
+ <property name="jetty.home">./src/test/jetty</property>
+ <property name="jetty.logs">./target</property>
+ <property name="jetty.port">9080</property>
+ </properties>
+</JettyService>
+ ]]></source>
+ </subsection>
+
+ </section>
+ </body>
+</document>
Added: turbine/fulcrum/trunk/jetty/xdocs/index.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/xdocs/index.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/xdocs/index.xml (added)
+++ turbine/fulcrum/trunk/jetty/xdocs/index.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,144 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<document>
+ <properties>
+ <title>Fulcrum Jetty Service</title>
+ <author email="[EMAIL PROTECTED]">Siegfried Goeschl</author>
+ </properties>
+ <body>
+ <section name="Overview">
+ <p>
+ The Fulcrum Jetty Service allows embedding a Jetty HTTP server to serve
+ HTTP request. The main focus is to add HTTP support to an existing
+ non-web application. The tests also exercise JSPs and JAAS integration
to make
+ sure that everything is properly wired.
+ </p>
+ </section>
+ <section name="How to Test Manually">
+ <p>
+ To make sure that Jetty is properly integrated run the following
command line
+ </p>
+ <source><![CDATA[
+mvn -Pstandalone test
+ ]]></source>
+ <p>
+ This will start the embedded Jetty and allows manual testing using
+ <a href="http://localhost:9080/test/">http://localhost:9080/test/</a>.
+ </p>
+ </section>
+ <section name="JSP Support">
+ <p>
+ The fulcrum-jetty library ships without JSP support because
+ <ul>
+ <li>most people plainly don't need it and it adds a lot of
baggage</li>
+ <li>for supporting JDK 1.4 and 1.5 different libraries are
required</li>
+ </ul>
+ To help you with evaluating this options a 'jetty-with-jsp.xml' pom is
+ provided which uses Maven profiles to build the library using JSP 2.0
+ and JSP 2.1.
+ </p>
+ <subsection name="JSP 2.0 Support for JDK 1.4">
+ <p>
+ These dependencies are required for running JSP 2.0 on JDK 1.4
+ </p>
+ <source><![CDATA[
+<!-- JSP 2.0 dependencies for JDK 1.4 -->
+<dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+</dependency>
+<dependency>
+ <groupId>commons-el</groupId>
+ <artifactId>commons-el</artifactId>
+ <version>1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+</dependency>
+<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.3.1</version>
+</dependency>
+<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.3.1</version>
+</dependency>
+<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.3.1</version>
+</dependency>
+<dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler</artifactId>
+ <version>${jetty.jasper.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+</dependency>
+<dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler-jdt</artifactId>
+ <version>${jetty.jasper.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.jdt</groupId>
+ <artifactId>core</artifactId>
+ </exclusion>
+ </exclusions>
+</dependency>
+<dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-runtime</artifactId>
+ <version>${jetty.jasper.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+</dependency>
+ ]]></source>
+ </subsection>
+ <subsection name="JSP 2.1 Support for JDK 1.5">
+ <p>
+ These dependencies are required for running JSP 2.1 on JDK 1.5
+ </p>
+ <source><![CDATA[
+<!-- JSP 2.1 dependencies for JDK 1.5 -->
+<dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-${jetty.jsp.version}</artifactId>
+ <version>${jetty.version}</version>
+</dependency>
+ ]]></source>
+ </subsection>
+ </section>
+ </body>
+</document>