You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by sg...@apache.org on 2008/07/18 17:01:53 UTC
svn commit: r677925 [2/7] - in /turbine/fulcrum/trunk/jetty: ./ src/
src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/fulcrum/
src/java/org/apache/fulcrum/jetty/ src/java/org/apache/fulcrum/jetty/impl/
src/main/ src/main/assembly/ src/s...
Added: turbine/fulcrum/trunk/jetty/src/test/com/acme/Dump.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/com/acme/Dump.java?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/com/acme/Dump.java (added)
+++ turbine/fulcrum/trunk/jetty/src/test/com/acme/Dump.java Fri Jul 18 08:01:51 2008
@@ -0,0 +1,741 @@
+// ========================================================================
+// Copyright 1996-2005 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// Licensed 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.
+// ========================================================================
+
+package com.acme;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.util.Enumeration;
+import java.util.Locale;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+
+import org.mortbay.util.StringUtil;
+import org.mortbay.util.ajax.Continuation;
+import org.mortbay.util.ajax.ContinuationSupport;
+
+
+
+/* ------------------------------------------------------------ */
+/** Dump Servlet Request.
+ *
+ */
+public class Dump extends HttpServlet
+{
+ /* ------------------------------------------------------------ */
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ doGet(request, response);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ if(request.getPathInfo().toLowerCase().indexOf("script")!=-1)
+ {
+ response.sendRedirect(getServletContext().getContextPath() + "/dump/info");
+ return;
+ }
+
+ request.setCharacterEncoding("UTF-8");
+
+ if (request.getParameter("empty")!=null)
+ {
+ response.setStatus(200);
+ response.flushBuffer();
+ return;
+ }
+
+ if (request.getParameter("sleep")!=null)
+ {
+ try
+ {
+ long s = Long.parseLong(request.getParameter("sleep"));
+ Thread.sleep(s/2);
+ response.sendError(102);
+ Thread.sleep(s/2);
+ }
+ catch (InterruptedException e)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+ if (request.getParameter("continue")!=null)
+ {
+ Continuation continuation = ContinuationSupport.getContinuation(request, null);
+ continuation.suspend(Long.parseLong(request.getParameter("continue")));
+ }
+
+ request.setAttribute("Dump", this);
+ getServletContext().setAttribute("Dump",this);
+ // getServletContext().log("dump "+request.getRequestURI());
+
+ // Force a content length response
+ String length= request.getParameter("length");
+ if (length != null && length.length() > 0)
+ {
+ response.setContentLength(Integer.parseInt(length));
+ }
+
+ // Handle a dump of data
+ String data= request.getParameter("data");
+ String block= request.getParameter("block");
+ String dribble= request.getParameter("dribble");
+ if (data != null && data.length() > 0)
+ {
+ int d=Integer.parseInt(data);
+ int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
+ byte[] buf=new byte[b];
+ for (int i=0;i<b;i++)
+ {
+
+ buf[i]=(byte)('0'+(i%10));
+ if (i%10==9)
+ buf[i]=(byte)'\n';
+ }
+ buf[0]='o';
+ OutputStream out=response.getOutputStream();
+ response.setContentType("text/plain");
+ while (d > 0)
+ {
+ if (b==1)
+ {
+ out.write(d%80==0?'\n':'.');
+ d--;
+ }
+ else if (d>=b)
+ {
+ out.write(buf);
+ d=d-b;
+ }
+ else
+ {
+ out.write(buf,0,d);
+ d=0;
+ }
+
+ if (dribble!=null)
+ {
+ out.flush();
+ try
+ {
+ Thread.sleep(Long.parseLong(dribble));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ break;
+ }
+ }
+
+ }
+
+ return;
+ }
+
+
+ // handle an exception
+ String info= request.getPathInfo();
+ if (info != null && info.endsWith("Exception"))
+ {
+ try
+ {
+ throw (Throwable) Thread.currentThread().getContextClassLoader().loadClass(info.substring(1)).newInstance();
+ }
+ catch (Throwable th)
+ {
+ throw new ServletException(th);
+ }
+ }
+
+ // test a reset
+ String reset= request.getParameter("reset");
+ if (reset != null && reset.length() > 0)
+ {
+ response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ response.setHeader("SHOULD_NOT","BE SEEN");
+ response.reset();
+ }
+
+
+ // handle an redirect
+ String redirect= request.getParameter("redirect");
+ if (redirect != null && redirect.length() > 0)
+ {
+ response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ response.sendRedirect(redirect);
+ try
+ {
+ response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ }
+ catch(IOException e)
+ {
+ // ignored as stream is closed.
+ }
+ return;
+ }
+
+ // handle an error
+ String error= request.getParameter("error");
+ if (error != null && error.length() > 0 && request.getAttribute("javax.servlet.error.status_code")==null)
+ {
+ response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ response.sendError(Integer.parseInt(error));
+ try
+ {
+ response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ }
+ catch(IllegalStateException e)
+ {
+ try
+ {
+ response.getWriter().println("NOR THIS!!");
+ }
+ catch(IOException e2){}
+ }
+ catch(IOException e){}
+ return;
+ }
+
+
+ String buffer= request.getParameter("buffer");
+ if (buffer != null && buffer.length() > 0)
+ response.setBufferSize(Integer.parseInt(buffer));
+
+ String charset= request.getParameter("charset");
+ if (charset==null)
+ charset="UTF-8";
+ response.setCharacterEncoding(charset);
+ response.setContentType("text/html");
+
+ if (info != null && info.indexOf("Locale/") >= 0)
+ {
+ try
+ {
+ String locale_name= info.substring(info.indexOf("Locale/") + 7);
+ Field f= java.util.Locale.class.getField(locale_name);
+ response.setLocale((Locale)f.get(null));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ response.setLocale(Locale.getDefault());
+ }
+ }
+
+ String cn= request.getParameter("cookie");
+ String cv=request.getParameter("cookiev");
+ if (cn!=null && cv!=null)
+ {
+ Cookie cookie= new Cookie(cn, cv);
+ if (request.getParameter("version")!=null)
+ cookie.setVersion(Integer.parseInt(request.getParameter("version")));
+ cookie.setComment("Cookie from dump servlet");
+ response.addCookie(cookie);
+ }
+
+ String pi= request.getPathInfo();
+ if (pi != null && pi.startsWith("/ex"))
+ {
+ OutputStream out= response.getOutputStream();
+ out.write("</H1>This text should be reset</H1>".getBytes());
+ if ("/ex0".equals(pi))
+ throw new ServletException("test ex0", new Throwable());
+ else if ("/ex1".equals(pi))
+ throw new IOException("test ex1");
+ else if ("/ex2".equals(pi))
+ throw new UnavailableException("test ex2");
+ else if (pi.startsWith("/ex3/"))
+ throw new UnavailableException("test ex3",Integer.parseInt(pi.substring(5)));
+ throw new RuntimeException("test");
+ }
+
+ if ("true".equals(request.getParameter("close")))
+ response.setHeader("Connection","close");
+
+ String buffered= request.getParameter("buffered");
+
+ PrintWriter pout=null;
+
+ try
+ {
+ pout =response.getWriter();
+ }
+ catch(IllegalStateException e)
+ {
+ pout=new PrintWriter(new OutputStreamWriter(response.getOutputStream(),charset));
+ }
+ if (buffered!=null)
+ pout = new PrintWriter(new BufferedWriter(pout,Integer.parseInt(buffered)));
+
+ try
+ {
+ pout.write("<html>\n<body>\n");
+ pout.write("<h1>Dump Servlet</h1>\n");
+ pout.write("<table width=\"95%\">");
+ pout.write("<tr>\n");
+ pout.write("<th align=\"right\">getMethod: </th>");
+ pout.write("<td>" + notag(request.getMethod())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getContentLength: </th>");
+ pout.write("<td>"+Integer.toString(request.getContentLength())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getContentType: </th>");
+ pout.write("<td>"+notag(request.getContentType())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRequestURI: </th>");
+ pout.write("<td>"+notag(request.getRequestURI())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRequestURL: </th>");
+ pout.write("<td>"+notag(request.getRequestURL().toString())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getContextPath: </th>");
+ pout.write("<td>"+request.getContextPath()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServletPath: </th>");
+ pout.write("<td>"+notag(request.getServletPath())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getPathInfo: </th>");
+ pout.write("<td>"+notag(request.getPathInfo())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getPathTranslated: </th>");
+ pout.write("<td>"+notag(request.getPathTranslated())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getQueryString: </th>");
+ pout.write("<td>"+notag(request.getQueryString())+"</td>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getProtocol: </th>");
+ pout.write("<td>"+request.getProtocol()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getScheme: </th>");
+ pout.write("<td>"+request.getScheme()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServerName: </th>");
+ pout.write("<td>"+notag(request.getServerName())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServerPort: </th>");
+ pout.write("<td>"+Integer.toString(request.getServerPort())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getLocalName: </th>");
+ pout.write("<td>"+request.getLocalName()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getLocalAddr: </th>");
+ pout.write("<td>"+request.getLocalAddr()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getLocalPort: </th>");
+ pout.write("<td>"+Integer.toString(request.getLocalPort())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRemoteUser: </th>");
+ pout.write("<td>"+request.getRemoteUser()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRemoteAddr: </th>");
+ pout.write("<td>"+request.getRemoteAddr()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRemoteHost: </th>");
+ pout.write("<td>"+request.getRemoteHost()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRemotePort: </th>");
+ pout.write("<td>"+request.getRemotePort()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRequestedSessionId: </th>");
+ pout.write("<td>"+request.getRequestedSessionId()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">isSecure(): </th>");
+ pout.write("<td>"+request.isSecure()+"</td>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">isUserInRole(admin): </th>");
+ pout.write("<td>"+request.isUserInRole("admin")+"</td>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getLocale: </th>");
+ pout.write("<td>"+request.getLocale()+"</td>");
+
+ Enumeration locales= request.getLocales();
+ while (locales.hasMoreElements())
+ {
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getLocales: </th>");
+ pout.write("<td>"+locales.nextElement()+"</td>");
+ }
+ pout.write("</tr><tr>\n");
+
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Other HTTP Headers:</big></th>");
+ Enumeration h= request.getHeaderNames();
+ String name;
+ while (h.hasMoreElements())
+ {
+ name= (String)h.nextElement();
+
+ Enumeration h2= request.getHeaders(name);
+ while (h2.hasMoreElements())
+ {
+ String hv= (String)h2.nextElement();
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+notag(name)+": </th>");
+ pout.write("<td>"+notag(hv)+"</td>");
+ }
+ }
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Request Parameters:</big></th>");
+ h= request.getParameterNames();
+ while (h.hasMoreElements())
+ {
+ name= (String)h.nextElement();
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+notag(name)+": </th>");
+ pout.write("<td>"+notag(request.getParameter(name))+"</td>");
+ String[] values= request.getParameterValues(name);
+ if (values == null)
+ {
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+notag(name)+" Values: </th>");
+ pout.write("<td>"+"NULL!"+"</td>");
+ }
+ else if (values.length > 1)
+ {
+ for (int i= 0; i < values.length; i++)
+ {
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+notag(name)+"["+i+"]: </th>");
+ pout.write("<td>"+notag(values[i])+"</td>");
+ }
+ }
+ }
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Cookies:</big></th>");
+ Cookie[] cookies = request.getCookies();
+ for (int i=0; cookies!=null && i<cookies.length;i++)
+ {
+ Cookie cookie = cookies[i];
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+notag(cookie.getName())+": </th>");
+ pout.write("<td>"+notag(cookie.getValue())+"</td>");
+ }
+
+ String content_type=request.getContentType();
+ if (content_type!=null &&
+ !content_type.startsWith("application/x-www-form-urlencoded") &&
+ !content_type.startsWith("multipart/form-data"))
+ {
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" valign=\"top\" colspan=\"2\"><big><br/>Content:</big></th>");
+ pout.write("</tr><tr>\n");
+ pout.write("<td><pre>");
+ char[] content= new char[4096];
+ int len;
+ try{
+ Reader in=request.getReader();
+
+ while((len=in.read(content))>=0)
+ pout.write(notag(new String(content,0,len)));
+ }
+ catch(IOException e)
+ {
+ pout.write(e.toString());
+ }
+
+ pout.write("</pre></td>");
+ }
+
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Request Attributes:</big></th>");
+ Enumeration a= request.getAttributeNames();
+ while (a.hasMoreElements())
+ {
+ name= (String)a.nextElement();
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\" valign=\"top\">"+name+": </th>");
+ pout.write("<td>"+"<pre>" + toString(request.getAttribute(name)) + "</pre>"+"</td>");
+ }
+
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Servlet InitParameters:</big></th>");
+ a= getInitParameterNames();
+ while (a.hasMoreElements())
+ {
+ name= (String)a.nextElement();
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+name+": </th>");
+ pout.write("<td>"+ toString(getInitParameter(name)) +"</td>");
+ }
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Context InitParameters:</big></th>");
+ a= getServletContext().getInitParameterNames();
+ while (a.hasMoreElements())
+ {
+ name= (String)a.nextElement();
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">"+name+": </th>");
+ pout.write("<td>"+ toString(getServletContext().getInitParameter(name)) + "</td>");
+ }
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Context Attributes:</big></th>");
+ a= getServletContext().getAttributeNames();
+ while (a.hasMoreElements())
+ {
+ name= (String)a.nextElement();
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\" valign=\"top\">"+name+": </th>");
+ pout.write("<td>"+"<pre>" + toString(getServletContext().getAttribute(name)) + "</pre>"+"</td>");
+ }
+
+
+ String res= request.getParameter("resource");
+ if (res != null && res.length() > 0)
+ {
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Get Resource: \""+res+"\"</big></th>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">this.getClass().getResource(...): </th>");
+ pout.write("<td>"+this.getClass().getResource(res)+"</td>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">this.getClass().getClassLoader().getResource(...): </th>");
+ pout.write("<td>"+this.getClass().getClassLoader().getResource(res)+"</td>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">Thread.currentThread().getContextClassLoader().getResource(...): </th>");
+ pout.write("<td>"+Thread.currentThread().getContextClassLoader().getResource(res)+"</td>");
+
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServletContext().getResource(...): </th>");
+ try{pout.write("<td>"+getServletContext().getResource(res)+"</td>");}
+ catch(Exception e) {pout.write("<td>"+"" +e+"</td>");}
+ }
+
+ pout.write("</tr></table>\n");
+
+ /* ------------------------------------------------------------ */
+ pout.write("<h2>Request Wrappers</h2>\n");
+ ServletRequest rw=request;
+ int w=0;
+ while (rw !=null)
+ {
+ pout.write((w++)+": "+rw.getClass().getName()+"<br/>");
+ if (rw instanceof HttpServletRequestWrapper)
+ rw=((HttpServletRequestWrapper)rw).getRequest();
+ else if (rw instanceof ServletRequestWrapper)
+ rw=((ServletRequestWrapper)rw).getRequest();
+ else
+ rw=null;
+ }
+
+ pout.write("<br/>");
+ pout.write("<h2>International Characters (UTF-8)</h2>");
+ pout.write("LATIN LETTER SMALL CAPITAL AE<br/>\n");
+ pout.write("Directly uni encoded(\\u1d01): \u1d01<br/>");
+ pout.write("HTML reference (&AElig;): Æ<br/>");
+ pout.write("Decimal (&#7425;): ᴁ<br/>");
+ pout.write("Javascript unicode (\\u1d01) : <script language='javascript'>document.write(\"\u1d01\");</script><br/>");
+ pout.write("<br/>");
+ pout.write("<h2>Form to generate GET content</h2>");
+ pout.write("<form method=\"GET\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"value\"/><br/>\n");
+ pout.write("<input type=\"submit\" name=\"Action\" value=\"Submit\">");
+ pout.write("</form>");
+
+ pout.write("<br/>");
+
+ pout.write("<h2>Form to generate POST content</h2>");
+ pout.write("<form method=\"POST\" accept-charset=\"utf-8\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"value\"/><br/>\n");
+ pout.write("Select: <select multiple name=\"Select\">\n");
+ pout.write("<option>ValueA</option>");
+ pout.write("<option>ValueB1,ValueB2</option>");
+ pout.write("<option>ValueC</option>");
+ pout.write("</select><br/>");
+ pout.write("<input type=\"submit\" name=\"Action\" value=\"Submit\"><br/>");
+ pout.write("</form>");
+ pout.write("<br/>");
+
+ pout.write("<h2>Form to generate UPLOAD content</h2>");
+ pout.write("<form method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"comment\"/><br/>\n");
+ pout.write("File 1: <input type=\"file\" name=\"file1\" /><br/>\n");
+ pout.write("File 2: <input type=\"file\" name=\"file2\" /><br/>\n");
+ pout.write("<input type=\"submit\" name=\"Action\" value=\"Submit\"><br/>");
+ pout.write("</form>");
+
+ pout.write("<h2>Form to set Cookie</h2>");
+ pout.write("<form method=\"POST\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("cookie: <input type=\"text\" name=\"cookie\" /><br/>\n");
+ pout.write("value: <input type=\"text\" name=\"cookiev\" /><br/>\n");
+ pout.write("<input type=\"submit\" name=\"Action\" value=\"setCookie\">");
+ pout.write("</form>\n");
+
+ pout.write("<h2>Form to get Resource</h2>");
+ pout.write("<form method=\"POST\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("resource: <input type=\"text\" name=\"resource\" /><br/>\n");
+ pout.write("<input type=\"submit\" name=\"Action\" value=\"getResource\">");
+ pout.write("</form>\n");
+
+
+ }
+ catch (Exception e)
+ {
+ getServletContext().log("dump", e);
+ }
+
+
+ if (request.getParameter("stream")!=null)
+ {
+ pout.flush();
+ Continuation continuation = ContinuationSupport.getContinuation(request, null);
+ continuation.suspend(Long.parseLong(request.getParameter("stream")));
+ }
+
+ String lines= request.getParameter("lines");
+ if (lines!=null)
+ {
+ char[] line = "<span>A line of characters. Blah blah blah blah. blooble blooble</span></br>\n".toCharArray();
+ for (int l=Integer.parseInt(lines);l-->0;)
+ {
+ pout.write("<span>"+l+" </span>");
+ pout.write(line);
+ }
+ }
+
+ pout.write("</body>\n</html>\n");
+
+ pout.close();
+
+ if (pi != null)
+ {
+ if ("/ex4".equals(pi))
+ throw new ServletException("test ex4", new Throwable());
+ if ("/ex5".equals(pi))
+ throw new IOException("test ex5");
+ if ("/ex6".equals(pi))
+ throw new UnavailableException("test ex6");
+ }
+
+
+ }
+
+ /* ------------------------------------------------------------ */
+ public String getServletInfo()
+ {
+ return "Dump Servlet";
+ }
+
+ /* ------------------------------------------------------------ */
+ public synchronized void destroy()
+ {
+ }
+
+ /* ------------------------------------------------------------ */
+ private String getURI(HttpServletRequest request)
+ {
+ String uri= (String)request.getAttribute("javax.servlet.forward.request_uri");
+ if (uri == null)
+ uri= request.getRequestURI();
+ return uri;
+ }
+
+ /* ------------------------------------------------------------ */
+ private static String toString(Object o)
+ {
+ if (o == null)
+ return null;
+
+ try
+ {
+ if (o.getClass().isArray())
+ {
+ StringBuffer sb = new StringBuffer();
+ if (!o.getClass().getComponentType().isPrimitive())
+ {
+ Object[] array= (Object[])o;
+ for (int i= 0; i < array.length; i++)
+ {
+ if (i > 0)
+ sb.append("\n");
+ sb.append(array.getClass().getComponentType().getName());
+ sb.append("[");
+ sb.append(i);
+ sb.append("]=");
+ sb.append(toString(array[i]));
+ }
+ return sb.toString();
+ }
+ else
+ {
+ int length = Array.getLength(o);
+ for (int i=0;i<length;i++)
+ {
+ if (i > 0)
+ sb.append("\n");
+ sb.append(o.getClass().getComponentType().getName());
+ sb.append("[");
+ sb.append(i);
+ sb.append("]=");
+ sb.append(toString(Array.get(o, i)));
+ }
+ return sb.toString();
+ }
+ }
+ else
+ return o.toString();
+ }
+ catch (Exception e)
+ {
+ return e.toString();
+ }
+ }
+
+ private String notag(String s)
+ {
+ if (s==null)
+ return "null";
+ s=StringUtil.replace(s,"&","&");
+ s=StringUtil.replace(s,"<","<");
+ s=StringUtil.replace(s,">",">");
+ return s;
+ }
+}
Added: turbine/fulcrum/trunk/jetty/src/test/com/acme/HelloWorld.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/com/acme/HelloWorld.java?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/com/acme/HelloWorld.java (added)
+++ turbine/fulcrum/trunk/jetty/src/test/com/acme/HelloWorld.java Fri Jul 18 08:01:51 2008
@@ -0,0 +1,68 @@
+// ========================================================================
+// Copyright 1996-2005 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// Licensed 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.
+// ========================================================================
+
+package com.acme;
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.SingleThreadModel;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/* ------------------------------------------------------------ */
+/** Dump Servlet Request.
+ *
+ */
+public class HelloWorld extends HttpServlet implements SingleThreadModel
+{
+ /* ------------------------------------------------------------ */
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ doGet(request, response);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ response.setContentType("text/html");
+ ServletOutputStream out = response.getOutputStream();
+ out.println("<html>");
+ out.println("<h1>Hello World</h1>");
+ out.println("</html>");
+ out.flush();
+
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException e)
+ {
+ getServletContext().log("exception",e);
+ }
+ }
+
+
+
+
+}
Added: turbine/fulcrum/trunk/jetty/src/test/com/acme/SessionDump.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/com/acme/SessionDump.java?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/com/acme/SessionDump.java (added)
+++ turbine/fulcrum/trunk/jetty/src/test/com/acme/SessionDump.java Fri Jul 18 08:01:51 2008
@@ -0,0 +1,176 @@
+// ========================================================================
+// Copyright 1996-2005 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// Licensed 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.
+// ========================================================================
+
+package com.acme;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.Enumeration;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+
+/* ------------------------------------------------------------ */
+/** Test Servlet Sessions.
+ *
+ * @author Greg Wilkins (gregw)
+ */
+public class SessionDump extends HttpServlet
+{
+
+ int redirectCount=0;
+ /* ------------------------------------------------------------ */
+ String pageType;
+
+ /* ------------------------------------------------------------ */
+ public void init(ServletConfig config)
+ throws ServletException
+ {
+ super.init(config);
+ }
+
+ /* ------------------------------------------------------------ */
+ protected void handleForm(HttpServletRequest request,
+ HttpServletResponse response)
+ {
+ HttpSession session = request.getSession(false);
+ String action = request.getParameter("Action");
+ String name = request.getParameter("Name");
+ String value = request.getParameter("Value");
+
+ if (action!=null)
+ {
+ if(action.equals("New Session"))
+ {
+ session = request.getSession(true);
+ session.setAttribute("test","value");
+ }
+ else if (session!=null)
+ {
+ if (action.equals("Invalidate"))
+ session.invalidate();
+ else if (action.equals("Set") && name!=null && name.length()>0)
+ session.setAttribute(name,value);
+ else if (action.equals("Remove"))
+ session.removeAttribute(name);
+ }
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doPost(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ handleForm(request,response);
+ String nextUrl = getURI(request)+"?R="+redirectCount++;
+ String encodedUrl=response.encodeRedirectURL(nextUrl);
+ response.sendRedirect(encodedUrl);
+ }
+
+ /* ------------------------------------------------------------ */
+ public void doGet(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ handleForm(request,response);
+
+ response.setContentType("text/html");
+
+ HttpSession session = request.getSession(getURI(request).indexOf("new")>0);
+ try
+ {
+ if (session!=null)
+ session.isNew();
+ }
+ catch(IllegalStateException e)
+ {
+ session=null;
+ }
+
+ PrintWriter out = response.getWriter();
+ out.println("<h1>Session Dump Servlet:</h1>");
+ out.println("<form action=\""+response.encodeURL(getURI(request))+"\" method=\"post\">");
+
+ if (session==null)
+ {
+ out.println("<H3>No Session</H3>");
+ out.println("<input type=\"submit\" name=\"Action\" value=\"New Session\"/>");
+ }
+ else
+ {
+ try
+ {
+ out.println("<b>ID:</b> "+session.getId()+"<br/>");
+ out.println("<b>New:</b> "+session.isNew()+"<br/>");
+ out.println("<b>Created:</b> "+new Date(session.getCreationTime())+"<br/>");
+ out.println("<b>Last:</b> "+new Date(session.getLastAccessedTime())+"<br/>");
+ out.println("<b>Max Inactive:</b> "+session.getMaxInactiveInterval()+"<br/>");
+ out.println("<b>Context:</b> "+session.getServletContext()+"<br/>");
+
+
+ Enumeration keys=session.getAttributeNames();
+ while(keys.hasMoreElements())
+ {
+ String name=(String)keys.nextElement();
+ String value=""+session.getAttribute(name);
+
+ out.println("<b>"+name+":</b> "+value+"<br/>");
+ }
+
+ out.println("<b>Name:</b><input type=\"text\" name=\"Name\" /><br/>");
+ out.println("<b>Value:</b><input type=\"text\" name=\"Value\" /><br/>");
+
+ out.println("<input type=\"submit\" name=\"Action\" value=\"Set\"/>");
+ out.println("<input type=\"submit\" name=\"Action\" value=\"Remove\"/>");
+ out.println("<input type=\"submit\" name=\"Action\" value=\"Invalidate\"/><br/>");
+
+ out.println("</form><br/>");
+
+ if (request.isRequestedSessionIdFromCookie())
+ out.println("<P>Turn off cookies in your browser to try url encoding<BR>");
+
+ if (request.isRequestedSessionIdFromURL())
+ out.println("<P>Turn on cookies in your browser to try cookie encoding<BR>");
+ out.println("<a href=\""+response.encodeURL(request.getRequestURI()+"?q=0")+"\">Encoded Link</a><BR>");
+
+ }
+ catch (IllegalStateException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ /* ------------------------------------------------------------ */
+ public String getServletInfo() {
+ return "Session Dump Servlet";
+ }
+
+ /* ------------------------------------------------------------ */
+ private String getURI(HttpServletRequest request)
+ {
+ String uri=(String)request.getAttribute("javax.servlet.forward.request_uri");
+ if (uri==null)
+ uri=request.getRequestURI();
+ return uri;
+ }
+
+}
Added: turbine/fulcrum/trunk/jetty/src/test/com/acme/TagListener.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/com/acme/TagListener.java?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/com/acme/TagListener.java (added)
+++ turbine/fulcrum/trunk/jetty/src/test/com/acme/TagListener.java Fri Jul 18 08:01:51 2008
@@ -0,0 +1,119 @@
+//========================================================================
+//$Id: TagListener.java 1679 2007-03-20 08:49:30Z janb $
+//Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
+//------------------------------------------------------------------------
+//Licensed 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.
+//========================================================================
+
+package com.acme;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSessionActivationListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+public class TagListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
+{
+ public void attributeAdded(HttpSessionBindingEvent se)
+ {
+ //System.err.println("tagListener: attributedAdded "+se);
+ }
+
+ public void attributeRemoved(HttpSessionBindingEvent se)
+ {
+ //System.err.println("tagListener: attributeRemoved "+se);
+ }
+
+ public void attributeReplaced(HttpSessionBindingEvent se)
+ {
+ //System.err.println("tagListener: attributeReplaced "+se);
+ }
+
+ public void sessionWillPassivate(HttpSessionEvent se)
+ {
+ //System.err.println("tagListener: sessionWillPassivate "+se);
+ }
+
+ public void sessionDidActivate(HttpSessionEvent se)
+ {
+ //System.err.println("tagListener: sessionDidActivate "+se);
+ }
+
+ public void contextInitialized(ServletContextEvent sce)
+ {
+ //System.err.println("tagListener: contextInitialized "+sce);
+ }
+
+ public void contextDestroyed(ServletContextEvent sce)
+ {
+ //System.err.println("tagListener: contextDestroyed "+sce);
+ }
+
+ public void attributeAdded(ServletContextAttributeEvent scab)
+ {
+ //System.err.println("tagListener: attributeAdded "+scab);
+ }
+
+ public void attributeRemoved(ServletContextAttributeEvent scab)
+ {
+ //System.err.println("tagListener: attributeRemoved "+scab);
+ }
+
+ public void attributeReplaced(ServletContextAttributeEvent scab)
+ {
+ //System.err.println("tagListener: attributeReplaced "+scab);
+ }
+
+ public void requestDestroyed(ServletRequestEvent sre)
+ {
+ //System.err.println("tagListener: requestDestroyed "+sre);
+ }
+
+ public void requestInitialized(ServletRequestEvent sre)
+ {
+ //System.err.println("tagListener: requestInitialized "+sre);
+ }
+
+ public void attributeAdded(ServletRequestAttributeEvent srae)
+ {
+ //System.err.println("tagListener: attributeAdded "+srae);
+ }
+
+ public void attributeRemoved(ServletRequestAttributeEvent srae)
+ {
+ //System.err.println("tagListener: attributeRemoved "+srae);
+ }
+
+ public void attributeReplaced(ServletRequestAttributeEvent srae)
+ {
+ //System.err.println("tagListener: attributeReplaced "+srae);
+ }
+
+ public void sessionCreated(HttpSessionEvent se)
+ {
+ //System.err.println("tagListener: sessionCreated "+se);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent se)
+ {
+ //System.err.println("tagListener: sessionDestroyed "+se);
+ }
+
+}
Added: turbine/fulcrum/trunk/jetty/src/test/com/acme/TestFilter.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/com/acme/TestFilter.java?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/com/acme/TestFilter.java (added)
+++ turbine/fulcrum/trunk/jetty/src/test/com/acme/TestFilter.java Fri Jul 18 08:01:51 2008
@@ -0,0 +1,93 @@
+//========================================================================
+//$Id: TestFilter.java,v 1.5 2005/11/01 11:42:53 gregwilkins Exp $
+//Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
+//------------------------------------------------------------------------
+//Licensed 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.
+//========================================================================
+
+package com.acme;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/* ------------------------------------------------------------ */
+/** TestFilter.
+ * @author gregw
+ *
+ */
+public class TestFilter implements Filter
+{
+ private ServletContext _context;
+
+ /* ------------------------------------------------------------ */
+ /*
+ * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
+ */
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ _context= filterConfig.getServletContext();
+ }
+
+ /* ------------------------------------------------------------ */
+ /*
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+ Integer old_value=null;
+ ServletRequest r = request;
+ while (r instanceof ServletRequestWrapper)
+ r=((ServletRequestWrapper)r).getRequest();
+
+ try
+ {
+ old_value=(Integer)request.getAttribute("testFilter");
+
+ Integer value=(old_value==null)?new Integer(1):new Integer(old_value.intValue()+1);
+
+ request.setAttribute("testFilter", value);
+
+ String qString = ((HttpServletRequest)request).getQueryString();
+ if (qString != null && qString.indexOf("wrap")>0)
+ {
+ request=new HttpServletRequestWrapper((HttpServletRequest)request);
+ }
+ _context.setAttribute("request"+r.hashCode(),value);
+
+ chain.doFilter(request, response);
+ }
+ finally
+ {
+ request.setAttribute("testFilter", old_value);
+ _context.setAttribute("request"+r.hashCode(),old_value);
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+ /*
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy()
+ {
+ }
+
+}
Added: turbine/fulcrum/trunk/jetty/src/test/com/acme/TestListener.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/com/acme/TestListener.java?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/com/acme/TestListener.java (added)
+++ turbine/fulcrum/trunk/jetty/src/test/com/acme/TestListener.java Fri Jul 18 08:01:51 2008
@@ -0,0 +1,119 @@
+//========================================================================
+//$Id: TestListener.java,v 1.1 2005/10/26 10:12:55 gregwilkins Exp $
+//Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
+//------------------------------------------------------------------------
+//Licensed 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.
+//========================================================================
+
+package com.acme;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSessionActivationListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+public class TestListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
+{
+ public void attributeAdded(HttpSessionBindingEvent se)
+ {
+ // System.err.println("attributedAdded "+se);
+ }
+
+ public void attributeRemoved(HttpSessionBindingEvent se)
+ {
+ // System.err.println("attributeRemoved "+se);
+ }
+
+ public void attributeReplaced(HttpSessionBindingEvent se)
+ {
+ // System.err.println("attributeReplaced "+se);
+ }
+
+ public void sessionWillPassivate(HttpSessionEvent se)
+ {
+ // System.err.println("sessionWillPassivate "+se);
+ }
+
+ public void sessionDidActivate(HttpSessionEvent se)
+ {
+ // System.err.println("sessionDidActivate "+se);
+ }
+
+ public void contextInitialized(ServletContextEvent sce)
+ {
+ // System.err.println("contextInitialized "+sce);
+ }
+
+ public void contextDestroyed(ServletContextEvent sce)
+ {
+ // System.err.println("contextDestroyed "+sce);
+ }
+
+ public void attributeAdded(ServletContextAttributeEvent scab)
+ {
+ // System.err.println("attributeAdded "+scab);
+ }
+
+ public void attributeRemoved(ServletContextAttributeEvent scab)
+ {
+ // System.err.println("attributeRemoved "+scab);
+ }
+
+ public void attributeReplaced(ServletContextAttributeEvent scab)
+ {
+ // System.err.println("attributeReplaced "+scab);
+ }
+
+ public void requestDestroyed(ServletRequestEvent sre)
+ {
+ // System.err.println("requestDestroyed "+sre);
+ }
+
+ public void requestInitialized(ServletRequestEvent sre)
+ {
+ // System.err.println("requestInitialized "+sre);
+ }
+
+ public void attributeAdded(ServletRequestAttributeEvent srae)
+ {
+ // System.err.println("attributeAdded "+srae);
+ }
+
+ public void attributeRemoved(ServletRequestAttributeEvent srae)
+ {
+ // System.err.println("attributeRemoved "+srae);
+ }
+
+ public void attributeReplaced(ServletRequestAttributeEvent srae)
+ {
+ // System.err.println("attributeReplaced "+srae);
+ }
+
+ public void sessionCreated(HttpSessionEvent se)
+ {
+ // System.err.println("sessionCreated "+se);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent se)
+ {
+ // System.err.println("sessionDestroyed "+se);
+ }
+
+}
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/README.TXT
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/README.TXT?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/README.TXT (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/README.TXT Fri Jul 18 08:01:51 2008
@@ -0,0 +1,12 @@
+
+This directory is scanned by the ContextDeployer instance
+configured by the standard $JETTY_HOME/etc/jetty.xml configuration.
+
+It should contain XmlConfiguration files that describe individual
+contexts to be deployed to the server. This directory is scanned
+for additions, removals and updates for hot deployment.
+
+Frequenty the context configuration files here will reference
+war files or directories from $JETTY_HOME/webapps. Care must be
+taken to avoid a WebAppDeployer deploying duplicates of such
+webapplications.
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.d/override-web.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.d/override-web.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.d/override-web.xml (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.d/override-web.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app
+ 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"
+ version="2.5">
+
+
+<!-- This web.xml format file is an override file that is applied to the test webapp AFTER
+ it has been configured by the default descriptor and the WEB-INF/web.xml descriptor -->
+
+ <!-- Add or override context init parameter -->
+ <context-param>
+ <param-name>context-override-example</param-name>
+ <param-value>a context value</param-value>
+ </context-param>
+
+ <!-- Add or override servlet init parameter -->
+ <servlet>
+ <servlet-name>Dump</servlet-name>
+ <init-param>
+ <param-name>servlet-override-example</param-name>
+ <param-value>a servlet value</param-value>
+ </init-param>
+ </servlet>
+
+ <!-- Add servlet mapping -->
+ <servlet-mapping>
+ <servlet-name>Dump</servlet-name>
+ <url-pattern>*.more</url-pattern>
+ </servlet-mapping>
+
+ <!-- Reset servlet class and/or start order -->
+ <servlet>
+ <servlet-name>Session</servlet-name>
+ <servlet-class>com.acme.SessionDump</servlet-class>
+ <load-on-startup>5</load-on-startup>
+ </servlet>
+
+</web-app>
+
+
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.xml (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/contexts/test.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+<!-- ==================================================================
+Configure and deploy the test web application in $(jetty.home)/webapps/test
+
+Note. If this file did not exist or used a context path other that /test
+then the default configuration of jetty.xml would discover the test
+webapplication with a WebAppDeployer. By specifying a context in this
+directory, additional configuration may be specified and hot deployments
+detected.
+===================================================================== -->
+
+<Configure class="org.mortbay.jetty.webapp.WebAppContext">
+
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Required minimal context configuration : -->
+ <!-- + contextPath -->
+ <!-- + war OR resourceBase -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <Set name="contextPath">/</Set>
+ <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- Optional context configuration -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <Set name="extractWAR">false</Set>
+ <Set name="copyWebDir">false</Set>
+ <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
+ <Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/contexts/test.d/override-web.xml</Set>
+
+ <!-- virtual hosts
+ <Set name="virtualHosts">
+ <Array type="String">
+ <Item>www.myVirtualDomain.com</Item>
+ <Item>localhost</Item>
+ <Item>127.0.0.1</Item>
+ </Array>
+ </Set>
+ -->
+
+ <!-- disable cookies
+ <Get name="sessionHandler">
+ <Get name="sessionManager">
+ <Set name="usingCookies" type="boolean">false</Set>
+ </Get>
+ </Get>
+ -->
+
+ <Get name="securityHandler">
+ <Set name="userRealm">
+ <New class="org.mortbay.jetty.security.HashUserRealm">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
+ <!-- To enable reload of realm when properties change, uncomment the following lines -->
+ <!-- changing refreshInterval (in seconds) as desired -->
+ <!--
+ <Set name="refreshInterval">5</Set>
+ <Call name="start"></Call>
+ -->
+ </New>
+ </Set>
+ <Set name="checkWelcomeFiles">true</Set>
+ </Get>
+
+ <!-- Non standard error page mapping -->
+ <Get name="errorHandler">
+ <Call name="addErrorPage">
+ <Arg type="int">500</Arg>
+ <Arg type="int">599</Arg>
+ <Arg type="String">/dump/errorCodeRangeMapping</Arg>
+ </Call>
+ </Get>
+
+</Configure>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-jaas.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-jaas.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-jaas.xml (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-jaas.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+<Configure id="Server" class="org.mortbay.jetty.Server">
+
+
+ <!-- ======================================================== -->
+ <!-- java.security.auth.login.config System property -->
+ <!-- This is usually a runtime parameter to the jvm, but -->
+ <!-- it is placed here for convenience. -->
+ <!-- ======================================================== -->
+ <Call class="java.lang.System" name="setProperty">
+ <Arg>java.security.auth.login.config</Arg>
+ <Arg><SystemProperty name="jetty.home" default="." />/etc/login.conf</Arg>
+ </Call>
+
+
+ <!-- ======================================================== -->
+ <!-- An example JAAS realm setup -->
+ <!-- For more information see the jetty wiki at -->
+ <!-- http://http://docs.codehaus.org/display/JETTY/JAAS -->
+ <!-- ======================================================== -->
+ <Set name="UserRealms">
+ <Array type="org.mortbay.jetty.security.UserRealm">
+ <Item>
+ <New class="org.mortbay.jetty.plus.jaas.JAASUserRealm">
+ <Set name="Name">Test JAAS Realm</Set>
+ <Set name="LoginModuleName">xyz</Set>
+ </New>
+ </Item>
+ </Array>
+ </Set>
+
+
+</Configure>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-logging.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-logging.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-logging.xml (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty-logging.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+
+<!-- =============================================================== -->
+<!-- Configure stderr and stdout to a Jetty rollover log file -->
+<!-- this configuration file should be used in combination with -->
+<!-- other configuration files. e.g. -->
+<!-- java -jar start.jar etc/jetty-logging.xml etc/jetty.xml -->
+<!-- =============================================================== -->
+<Configure id="Server" class="org.mortbay.jetty.Server">
+
+ <New id="ServerLog" class="java.io.PrintStream">
+ <Arg>
+ <New class="org.mortbay.util.RolloverFileOutputStream">
+ <Arg><SystemProperty name="jetty.home" default="."/>/../../../target/yyyy_mm_dd.stderrout.log</Arg>
+ <Arg type="boolean">false</Arg>
+ <Arg type="int">90</Arg>
+ <Arg><Call class="java.util.TimeZone" name="getTimeZone"><Arg>GMT</Arg></Call></Arg>
+ <Get id="ServerLogName" name="datedFilename"/>
+ </New>
+ </Arg>
+ </New>
+
+ <Call class="org.mortbay.log.Log" name="info"><Arg>Redirecting stderr/stdout to <Ref id="ServerLogName"/></Arg></Call>
+ <Call class="java.lang.System" name="setErr"><Arg><Ref id="ServerLog"/></Arg></Call>
+ <Call class="java.lang.System" name="setOut"><Arg><Ref id="ServerLog"/></Arg></Call>
+
+</Configure>
+
+
+
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty.xml?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty.xml (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/etc/jetty.xml Fri Jul 18 08:01:51 2008
@@ -0,0 +1,206 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+<!-- =============================================================== -->
+<!-- Configure the Jetty Server -->
+<!-- -->
+<!-- Documentation of this file format can be found at: -->
+<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
+<!-- -->
+<!-- =============================================================== -->
+
+
+<Configure id="Server" class="org.mortbay.jetty.Server">
+
+ <!-- =========================================================== -->
+ <!-- Server Thread Pool -->
+ <!-- =========================================================== -->
+ <Set name="ThreadPool">
+
+ <New class="org.mortbay.thread.QueuedThreadPool">
+ <Set name="minThreads">10</Set>
+ <Set name="maxThreads">25</Set>
+ <Set name="lowThreads">5</Set>
+ <Set name="SpawnOrShrinkAt">2</Set>
+ </New>
+
+ <!-- Optional Java 5 bounded threadpool with job queue
+ <New class="org.mortbay.thread.concurrent.ThreadPool">
+ <Set name="corePoolSize">50</Set>
+ <Set name="maximumPoolSize">50</Set>
+ </New>
+ -->
+ </Set>
+
+
+
+ <!-- =========================================================== -->
+ <!-- Set connectors -->
+ <!-- =========================================================== -->
+ <!-- One of each type! -->
+ <!-- =========================================================== -->
+
+ <!-- Use this connector for many frequently idle connections
+ and for threadless continuations.
+ -->
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.mortbay.jetty.nio.SelectChannelConnector">
+ <Set name="host"><SystemProperty name="jetty.host" /></Set>
+ <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
+ <Set name="maxIdleTime">30000</Set>
+ <Set name="Acceptors">2</Set>
+ <Set name="statsOn">false</Set>
+ <Set name="confidentialPort">8443</Set>
+ <Set name="lowResourcesConnections">5000</Set>
+ <Set name="lowResourcesMaxIdleTime">5000</Set>
+ </New>
+ </Arg>
+ </Call>
+
+ <!-- Use this connector if NIO is not available.
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.mortbay.jetty.bio.SocketConnector">
+ <Set name="port">8081</Set>
+ <Set name="maxIdleTime">50000</Set>
+ <Set name="lowResourceMaxIdleTime">1500</Set>
+ </New>
+ </Arg>
+ </Call>
+ -->
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- To add a HTTPS SSL listener -->
+ <!-- see jetty-ssl.xml to add an ssl connector. use -->
+ <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+
+ <!-- =========================================================== -->
+ <!-- Set up global session ID manager -->
+ <!-- =========================================================== -->
+ <!--
+ <Set name="sessionIdManager">
+ <New class="org.mortbay.jetty.servlet.HashSessionIdManager">
+ <Set name="workerName">node1</Set>
+ </New>
+ </Set>
+ -->
+
+ <!-- =========================================================== -->
+ <!-- Set handler Collection Structure -->
+ <!-- =========================================================== -->
+ <Set name="handler">
+ <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
+ <Set name="handlers">
+ <Array type="org.mortbay.jetty.Handler">
+ <Item>
+ <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
+ </Item>
+ <Item>
+ <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
+ </Item>
+ <Item>
+ <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
+ </Item>
+ </Array>
+ </Set>
+ </New>
+ </Set>
+
+ <!-- =========================================================== -->
+ <!-- Configure the context deployer -->
+ <!-- A context deployer will deploy contexts described in -->
+ <!-- configuration files discovered in a directory. -->
+ <!-- The configuration directory can be scanned for hot -->
+ <!-- deployments at the configured scanInterval. -->
+ <!-- -->
+ <!-- This deployer is configured to deploy contexts configured -->
+ <!-- in the $JETTY_HOME/contexts directory -->
+ <!-- -->
+ <!-- =========================================================== -->
+ <Call name="addLifeCycle">
+ <Arg>
+ <New class="org.mortbay.jetty.deployer.ContextDeployer">
+ <Set name="contexts"><Ref id="Contexts"/></Set>
+ <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
+ <Set name="scanInterval">1</Set>
+ </New>
+ </Arg>
+ </Call>
+
+ <!-- =========================================================== -->
+ <!-- Configure the webapp deployer. -->
+ <!-- A webapp deployer will deploy standard webapps discovered -->
+ <!-- in a directory at startup, without the need for additional -->
+ <!-- configuration files. It does not support hot deploy or -->
+ <!-- non standard contexts (see ContextDeployer above). -->
+ <!-- -->
+ <!-- This deployer is configured to deploy webapps from the -->
+ <!-- $JETTY_HOME/webapps directory -->
+ <!-- -->
+ <!-- Normally only one type of deployer need be used. -->
+ <!-- -->
+ <!-- =========================================================== -->
+ <Call name="addLifeCycle">
+ <Arg>
+ <New class="org.mortbay.jetty.deployer.WebAppDeployer">
+ <Set name="contexts"><Ref id="Contexts"/></Set>
+ <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
+ <Set name="parentLoaderPriority">false</Set>
+ <Set name="extract">true</Set>
+ <Set name="allowDuplicates">false</Set>
+ <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
+ </New>
+ </Arg>
+ </Call>
+
+ <!-- =========================================================== -->
+ <!-- Configure Authentication Realms -->
+ <!-- Realms may be configured for the entire server here, or -->
+ <!-- they can be configured for a specific web app in a context -->
+ <!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
+ <!-- example). -->
+ <!-- =========================================================== -->
+ <Set name="UserRealms">
+ <Array type="org.mortbay.jetty.security.UserRealm">
+ <Item>
+ <New class="org.mortbay.jetty.security.HashUserRealm">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
+ <Set name="refreshInterval">0</Set>
+ </New>
+ </Item>
+ </Array>
+ </Set>
+
+ <!-- =========================================================== -->
+ <!-- Configure Request Log -->
+ <!-- Request logs may be configured for the entire server here, -->
+ <!-- or they can be configured for a specific web app in a -->
+ <!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
+ <!-- for an example). -->
+ <!-- =========================================================== -->
+ <Ref id="RequestLog">
+ <Set name="requestLog">
+ <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
+ <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
+ <Set name="filenameDateFormat">yyyy_MM_dd</Set>
+ <Set name="retainDays">90</Set>
+ <Set name="append">true</Set>
+ <Set name="extended">true</Set>
+ <Set name="logCookies">false</Set>
+ <Set name="LogTimeZone">GMT</Set>
+ </New>
+ </Set>
+ </Ref>
+
+ <!-- =========================================================== -->
+ <!-- extra options -->
+ <!-- =========================================================== -->
+ <Set name="stopAtShutdown">true</Set>
+ <Set name="sendServerVersion">true</Set>
+ <Set name="sendDateHeader">true</Set>
+ <Set name="gracefulShutdown">1000</Set>
+
+</Configure>
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.conf
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.conf?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.conf (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.conf Fri Jul 18 08:01:51 2008
@@ -0,0 +1,5 @@
+xyz {
+org.mortbay.jetty.plus.jaas.spi.PropertyFileLoginModule required
+debug="true"
+file="${jetty.home}/etc/login.properties";
+};
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.properties
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.properties?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.properties (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/etc/login.properties Fri Jul 18 08:01:51 2008
@@ -0,0 +1 @@
+me=me,me,roleA
Added: turbine/fulcrum/trunk/jetty/src/test/jetty/etc/realm.properties
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/jetty/src/test/jetty/etc/realm.properties?rev=677925&view=auto
==============================================================================
--- turbine/fulcrum/trunk/jetty/src/test/jetty/etc/realm.properties (added)
+++ turbine/fulcrum/trunk/jetty/src/test/jetty/etc/realm.properties Fri Jul 18 08:01:51 2008
@@ -0,0 +1,21 @@
+#
+# This file defines users passwords and roles for a HashUserRealm
+#
+# The format is
+# <username>: <password>[,<rolename> ...]
+#
+# Passwords may be clear text, obfuscated or checksummed. The class
+# org.mortbay.util.Password should be used to generate obfuscated
+# passwords or password checksums
+#
+# If DIGEST Authentication is used, the password must be in a recoverable
+# format, either plain text or OBF:.
+#
+jetty: MD5:164c88b302622e17050af52c89945d44,user
+admin: CRYPT:ad1ks..kc.1Ug,server-administrator,content-administrator,admin
+other: OBF:1xmk1w261u9r1w1c1xmq
+plain: plain
+user: password
+
+# This entry is for digest auth. The credential is a MD5 hash of username:realmname:password
+digest: MD5:6e120743ad67abfbc385bc2bb754e297