Refactored continuation test harnessess

Continuations ISE rather than ignore bad transitions



git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@990 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-10-15 01:24:33 +00:00
parent eb04a44ca6
commit 9583051709
14 changed files with 856 additions and 270 deletions

View File

@ -1,4 +1,7 @@
jetty-7.0.1-SNAPSHOT jetty-7.0.1-SNAPSHOT
+ Refactored continuation test harnessess
+ Continuations ISE rather than ignore bad transitions
+ Improved start.jar usage text for properties
+ Promoted Jetty WebApp Verifier from Sandbox + Promoted Jetty WebApp Verifier from Sandbox
+ Promoted Jetty Centralized Logging from Sandbox + Promoted Jetty Centralized Logging from Sandbox
+ 274251 DefaultServlet supports exact match mode. + 274251 DefaultServlet supports exact match mode.
@ -16,13 +19,15 @@ jetty-7.0.1-SNAPSHOT
+ 291543 make bin/*.sh scripts executable in distribution + 291543 make bin/*.sh scripts executable in distribution
+ 291589 Update jetty-rewrite demo + 291589 Update jetty-rewrite demo
jetty-7.0.0.v20091005 October 5 2009 jetty-7.0.0.v20091005 5 October 2009
291340 Race condition in onException() notifications
jetty-7.0.0.RC6 September 21 2009
+ Fixed XSS issue in CookieDump demo servlet.
+ 289958 StatisticsServlet incorrectly adds StatisticsHandler + 289958 StatisticsServlet incorrectly adds StatisticsHandler
+ Remove printlns from jetty-plus + 289960 start.jar assumes command line args are configs
+ 290081 Eager consume LF after CR + 290081 Eager consume LF after CR
+ 290761 HttpExchange isDone handles intercepted events. + 290761 HttpExchange isDone handles intercepted events.
jetty-7.0.0.RC6 September 18th 2009
+ JETTY-719 Document state machine of jetty http client + JETTY-719 Document state machine of jetty http client
+ JETTY-780 CNFE during startup of webapp with spring-context >= 2.5.1 + JETTY-780 CNFE during startup of webapp with spring-context >= 2.5.1
+ JETTY-936 274251 Improved servlet matching and optimized' + JETTY-936 274251 Improved servlet matching and optimized'

View File

@ -6,7 +6,6 @@ import java.util.EventListener;
import javax.servlet.ServletRequestListener; import javax.servlet.ServletRequestListener;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** A Continuation Listener /** A Continuation Listener
* <p> * <p>
@ -35,4 +34,5 @@ public interface ContinuationListener extends EventListener
* @param continuation * @param continuation
*/ */
public void onTimeout(Continuation continuation); public void onTimeout(Continuation continuation);
} }

View File

@ -17,6 +17,8 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import org.eclipse.jetty.continuation.ContinuationListener;
/* temporary interface in anticipation of servlet 3.0 */ /* temporary interface in anticipation of servlet 3.0 */
public interface AsyncContext public interface AsyncContext
{ {
@ -34,6 +36,8 @@ public interface AsyncContext
public void dispatch(ServletContext context, String path); public void dispatch(ServletContext context, String path);
public void complete(); public void complete();
public void start(Runnable run); public void start(Runnable run);
public void setTimeout(long ms);
public void addContinuationListener(ContinuationListener listener);
} }

View File

@ -13,6 +13,9 @@
package org.eclipse.jetty.server; package org.eclipse.jetty.server;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
@ -25,7 +28,6 @@ import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandler.Context; import org.eclipse.jetty.server.handler.ContextHandler.Context;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.Timeout; import org.eclipse.jetty.util.thread.Timeout;
@ -66,7 +68,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected HttpConnection _connection; protected HttpConnection _connection;
private Object _listeners; private List<ContinuationListener> _continuationListeners;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
private int _state; private int _state;
@ -78,15 +80,11 @@ public class AsyncContinuation implements AsyncContext, Continuation
private AsyncEventState _event; private AsyncEventState _event;
private volatile long _expireAt; private volatile long _expireAt;
// private StringBuilder _history = new StringBuilder();
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected AsyncContinuation() protected AsyncContinuation()
{ {
_state=__IDLE; _state=__IDLE;
_initial=true; _initial=true;
// _history.append(super.toString());
// _history.append('\n');
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -95,8 +93,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
synchronized(this) synchronized(this)
{ {
_connection=connection; _connection=connection;
// _history.append(connection.toString());
// _history.append('\n');
} }
} }
@ -105,24 +101,23 @@ public class AsyncContinuation implements AsyncContext, Continuation
{ {
synchronized(this) synchronized(this)
{ {
_listeners=LazyList.add(_listeners,listener); if (_continuationListeners==null)
// _history.append('L'); _continuationListeners=new ArrayList<ContinuationListener>();
_continuationListeners.add(listener);
} }
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void setAsyncTimeout(long ms) public void setTimeout(long ms)
{ {
synchronized(this) synchronized(this)
{ {
_timeoutMs=ms; _timeoutMs=ms;
// _history.append('T');
// _history.append(ms);
} }
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public long getAsyncTimeout() public long getTimeout()
{ {
synchronized(this) synchronized(this)
{ {
@ -220,34 +215,22 @@ public class AsyncContinuation implements AsyncContext, Continuation
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* (non-Javadoc) /**
* @see javax.servlet.ServletRequest#resume() * @return false if the handling of the request should not proceed
*/ */
protected boolean handling() protected boolean handling()
{ {
synchronized (this) synchronized (this)
{ {
// _history.append('H');
// _history.append(_connection.getRequest().getUri().toString());
// _history.append(':');
_responseWrapped=false; _responseWrapped=false;
switch(_state) switch(_state)
{ {
case __DISPATCHED:
case __REDISPATCHED:
case __COMPLETED:
throw new IllegalStateException(this.getStatusString());
case __IDLE: case __IDLE:
_initial=true; _initial=true;
_state=__DISPATCHED; _state=__DISPATCHED;
return true; return true;
case __ASYNCSTARTED:
case __REDISPATCHING:
throw new IllegalStateException(this.getStatusString());
case __COMPLETING: case __COMPLETING:
_state=__UNCOMPLETED; _state=__UNCOMPLETED;
return false; return false;
@ -260,7 +243,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
return true; return true;
default: default:
throw new IllegalStateException(""+_state); throw new IllegalStateException(this.getStatusString());
} }
} }
} }
@ -275,11 +258,9 @@ public class AsyncContinuation implements AsyncContext, Continuation
{ {
synchronized (this) synchronized (this)
{ {
// _history.append('S');
_resumed=false; _resumed=false;
_expired=false; _expired=false;
// TODO move this to callers
if (_event==null || request!=_event.getRequest() || response != _event.getResponse() || context != _event.getServletContext()) if (_event==null || request!=_event.getRequest() || response != _event.getResponse() || context != _event.getServletContext())
_event=new AsyncEventState(context,request,response); _event=new AsyncEventState(context,request,response);
else else
@ -293,25 +274,13 @@ public class AsyncContinuation implements AsyncContext, Continuation
case __DISPATCHED: case __DISPATCHED:
case __REDISPATCHED: case __REDISPATCHED:
_state=__ASYNCSTARTED; _state=__ASYNCSTARTED;
return; break;
case __IDLE:
throw new IllegalStateException(this.getStatusString());
case __ASYNCSTARTED:
case __REDISPATCHING:
return;
case __COMPLETING:
case __ASYNCWAIT:
case __REDISPATCH:
case __COMPLETED:
throw new IllegalStateException(this.getStatusString());
default: default:
throw new IllegalStateException(""+_state); throw new IllegalStateException(this.getStatusString());
} }
} }
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -326,7 +295,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
{ {
synchronized (this) synchronized (this)
{ {
// _history.append('U'); List<ContinuationListener> listeners=_continuationListeners;
switch(_state) switch(_state)
{ {
case __REDISPATCHED: case __REDISPATCHED:
@ -362,8 +332,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
_state=__UNCOMPLETED; _state=__UNCOMPLETED;
return true; return true;
case __ASYNCWAIT:
case __REDISPATCH:
default: default:
throw new IllegalStateException(this.getStatusString()); throw new IllegalStateException(this.getStatusString());
} }
@ -376,18 +344,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
boolean dispatch=false; boolean dispatch=false;
synchronized (this) synchronized (this)
{ {
// _history.append('D');
switch(_state) switch(_state)
{ {
case __REDISPATCHED:
case __DISPATCHED:
case __IDLE:
case __REDISPATCHING:
case __COMPLETING:
case __COMPLETED:
case __UNCOMPLETED:
return;
case __ASYNCSTARTED: case __ASYNCSTARTED:
_state=__REDISPATCHING; _state=__REDISPATCHING;
_resumed=true; _resumed=true;
@ -417,17 +375,17 @@ public class AsyncContinuation implements AsyncContext, Continuation
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected void expired() protected void expired()
{ {
Object listeners=null; final List<ContinuationListener> listeners;
synchronized (this) synchronized (this)
{ {
// _history.append('E');
switch(_state) switch(_state)
{ {
case __ASYNCSTARTED: case __ASYNCSTARTED:
case __ASYNCWAIT: case __ASYNCWAIT:
listeners=_listeners; listeners=_continuationListeners;
break; break;
default: default:
listeners=null;
return; return;
} }
_expired=true; _expired=true;
@ -435,16 +393,11 @@ public class AsyncContinuation implements AsyncContext, Continuation
if (listeners!=null) if (listeners!=null)
{ {
for(int i=0;i<LazyList.size(listeners);i++) for (int i=0;i<listeners.size();i++)
{ {
ContinuationListener listener=listeners.get(i);
try try
{ {
// synchronized (this)
// {
// _history.append('l');
// _history.append(i);
// }
ContinuationListener listener=((ContinuationListener)LazyList.get(listeners,i));
listener.onTimeout(this); listener.onTimeout(this);
} }
catch(Exception e) catch(Exception e)
@ -456,7 +409,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
synchronized (this) synchronized (this)
{ {
// _history.append('e');
switch(_state) switch(_state)
{ {
case __ASYNCSTARTED: case __ASYNCSTARTED:
@ -478,16 +430,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
boolean dispatch=false; boolean dispatch=false;
synchronized (this) synchronized (this)
{ {
// _history.append('C');
switch(_state) switch(_state)
{ {
case __IDLE:
case __COMPLETED:
case __REDISPATCHING:
case __COMPLETING:
case __REDISPATCH:
return;
case __DISPATCHED: case __DISPATCHED:
case __REDISPATCHED: case __REDISPATCHED:
throw new IllegalStateException(this.getStatusString()); throw new IllegalStateException(this.getStatusString());
@ -520,34 +464,29 @@ public class AsyncContinuation implements AsyncContext, Continuation
*/ */
protected void doComplete() protected void doComplete()
{ {
Object listeners=null; final List<ContinuationListener> listeners;
synchronized (this) synchronized (this)
{ {
// _history.append("c");
switch(_state) switch(_state)
{ {
case __UNCOMPLETED: case __UNCOMPLETED:
_state=__COMPLETED; _state=__COMPLETED;
listeners=_listeners; listeners=_continuationListeners;
break; break;
default: default:
listeners=null;
throw new IllegalStateException(this.getStatusString()); throw new IllegalStateException(this.getStatusString());
} }
} }
if (listeners!=null) if (listeners!=null)
{ {
for(int i=0;i<LazyList.size(listeners);i++) for(int i=0;i<listeners.size();i++)
{ {
try try
{ {
// synchronized (this) listeners.get(i).onComplete(this);
// {
// _history.append('l');
// _history.append(i);
// }
((ContinuationListener)LazyList.get(listeners,i)).onComplete(this);
} }
catch(Exception e) catch(Exception e)
{ {
@ -577,7 +516,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
_responseWrapped=false; _responseWrapped=false;
cancelTimeout(); cancelTimeout();
_timeoutMs=DEFAULT_TIMEOUT; _timeoutMs=DEFAULT_TIMEOUT;
_listeners=null; _continuationListeners=null;
} }
} }
@ -586,9 +525,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
{ {
synchronized (this) synchronized (this)
{ {
// _history.append("X");
cancelTimeout(); cancelTimeout();
_listeners=null; _continuationListeners=null;
} }
} }
@ -632,7 +570,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
} }
} }
else else
_connection.scheduleTimeout(_event._timeout,_timeoutMs); _connection.scheduleTimeout(_event,_timeoutMs);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -651,7 +589,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
{ {
final AsyncEventState event=_event; final AsyncEventState event=_event;
if (event!=null) if (event!=null)
_connection.cancelTimeout(event._timeout); _connection.cancelTimeout(event);
} }
} }
@ -812,31 +750,14 @@ public class AsyncContinuation implements AsyncContext, Continuation
dispatch(); dispatch();
} }
/* ------------------------------------------------------------ */
/**
* @see Continuation#suspend(long)
*/
public void setTimeout(long timeoutMs)
{
setAsyncTimeout(timeoutMs);
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** /**
* @see Continuation#suspend() * @see Continuation#suspend()
*/ */
public void suspend(ServletResponse response) public void suspend(ServletResponse response)
{ {
if (response instanceof ServletResponseWrapper) _responseWrapped=!(response instanceof Response);
{ AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),response);
_responseWrapped=true;
AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),response);
}
else
{
_responseWrapped=false;
AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),_connection.getResponse());
}
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -845,7 +766,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
*/ */
public void suspend() public void suspend()
{ {
// TODO simplify? move event creation to suspend(args)
_responseWrapped=false; _responseWrapped=false;
AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),_connection.getResponse()); AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),_connection.getResponse());
} }
@ -906,22 +826,13 @@ public class AsyncContinuation implements AsyncContext, Continuation
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public class AsyncEventState public class AsyncEventState extends Timeout.Task
{ {
private final ServletContext _suspendedContext; private final ServletContext _suspendedContext;
private final ServletRequest _request; private final ServletRequest _request;
private final ServletResponse _response; private final ServletResponse _response;
private ServletContext _dispatchContext;
ServletContext _dispatchContext; private String _path;
String _path;
final Timeout.Task _timeout = new Timeout.Task()
{
public void expired()
{
AsyncContinuation.this.expired();
}
};
public AsyncEventState(ServletContext context, ServletRequest request, ServletResponse response) public AsyncEventState(ServletContext context, ServletRequest request, ServletResponse response)
{ {
@ -959,14 +870,10 @@ public class AsyncContinuation implements AsyncContext, Continuation
{ {
return _path; return _path;
} }
}
public String getHistory() public void expired()
{ {
// synchronized (this) AsyncContinuation.this.expired();
// { }
// return _history.toString();
// }
return null;
} }
} }

View File

@ -170,20 +170,13 @@ public class Request implements HttpServletRequest
setConnection(connection); setConnection(connection);
} }
/* ------------------------------------------------------------ */
public void addContinuationListener(ContinuationListener listener)
{
_async.addContinuationListener(listener);
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void addEventListener(final EventListener listener) public void addEventListener(final EventListener listener)
{ {
if (listener instanceof ServletRequestAttributeListener) if (listener instanceof ServletRequestAttributeListener)
_requestAttributeListeners= LazyList.add(_requestAttributeListeners, listener); _requestAttributeListeners= LazyList.add(_requestAttributeListeners, listener);
if (listener instanceof ContinuationListener) if (listener instanceof ContinuationListener)
_async.addContinuationListener((ContinuationListener)listener); throw new IllegalArgumentException();
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -1398,12 +1391,6 @@ public class Request implements HttpServletRequest
_asyncSupported=supported; _asyncSupported=supported;
} }
/* ------------------------------------------------------------ */
public void setAsyncTimeout(long timeout)
{
_async.setAsyncTimeout(timeout);
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* Set a request attribute. * Set a request attribute.

View File

@ -197,10 +197,10 @@ public class AsyncContextTest extends TestCase
b=in.read(); b=in.read();
} }
if (_suspendFor>0)
baseRequest.setAsyncTimeout(_suspendFor);
baseRequest.addEventListener(__asyncListener);
final AsyncContext asyncContext = baseRequest.startAsync(); final AsyncContext asyncContext = baseRequest.startAsync();
asyncContext.addContinuationListener(__asyncListener);
if (_suspendFor>0)
asyncContext.setTimeout(_suspendFor);
if (_completeAfter>0) if (_completeAfter>0)
{ {

View File

@ -214,11 +214,10 @@ public class AsyncStressTest extends TestCase
if (suspend_for>=0) if (suspend_for>=0)
{ {
if (suspend_for>0)
baseRequest.setAsyncTimeout(suspend_for);
baseRequest.addEventListener(__asyncListener);
final AsyncContext asyncContext = baseRequest.startAsync(); final AsyncContext asyncContext = baseRequest.startAsync();
asyncContext.addContinuationListener(__asyncListener);
if (suspend_for>0)
asyncContext.setTimeout(suspend_for);
if (complete_after>0) if (complete_after>0)
{ {
@ -241,7 +240,6 @@ public class AsyncStressTest extends TestCase
System.err.println(uri+"=="+br.getUri()); System.err.println(uri+"=="+br.getUri());
System.err.println(asyncContext+"=="+br.getAsyncContinuation()); System.err.println(asyncContext+"=="+br.getAsyncContinuation());
System.err.println(((AsyncContinuation)asyncContext).getHistory());
Log.warn(e); Log.warn(e);
System.exit(1); System.exit(1);
} }

View File

@ -0,0 +1,151 @@
// ========================================================================
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.continuation;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jetty.continuation.test.ContinuationBase;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.FilterHolder;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.util.IO;
public class Jetty6ContinuationBioFauxTest extends ContinuationBase
{
protected Server _server = new Server();
protected ServletHandler _servletHandler;
protected SocketConnector _socketConnector;
FilterHolder _filter;
protected void setUp() throws Exception
{
_socketConnector = new SocketConnector();
_server.setConnectors(new Connector[]{ _socketConnector });
Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS);
_server.setHandler(servletContext);
_servletHandler=servletContext.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet);
_servletHandler.addServletWithMapping(holder,"/");
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
_filter.setInitParameter("debug","true");
_filter.setInitParameter("faux","true");
_server.start();
_port=_socketConnector.getLocalPort();
}
protected void tearDown() throws Exception
{
_server.stop();
}
public void testContinuation() throws Exception
{
doNormal("FauxContinuation");
}
public void testSleep() throws Exception
{
doSleep();
}
public void testSuspend() throws Exception
{
doSuspend();
}
public void testSuspendWaitResume() throws Exception
{
doSuspendWaitResume();
}
public void testSuspendResume() throws Exception
{
doSuspendResume();
}
public void testSuspendWaitComplete() throws Exception
{
doSuspendWaitComplete();
}
public void testSuspendComplete() throws Exception
{
doSuspendComplete();
}
public void testSuspendWaitResumeSuspendWaitResume() throws Exception
{
doSuspendWaitResumeSuspendWaitResume();
}
public void testSuspendWaitResumeSuspendComplete() throws Exception
{
doSuspendWaitResumeSuspendComplete();
}
public void testSuspendWaitResumeSuspend() throws Exception
{
doSuspendWaitResumeSuspend();
}
public void testSuspendTimeoutSuspendResume() throws Exception
{
doSuspendTimeoutSuspendResume();
}
public void testSuspendTimeoutSuspendComplete() throws Exception
{
doSuspendTimeoutSuspendComplete();
}
public void testSuspendTimeoutSuspend() throws Exception
{
doSuspendTimeoutSuspend();
}
public void testSuspendThrowResume() throws Exception
{
doSuspendThrowResume();
}
public void testSuspendResumeThrow() throws Exception
{
doSuspendResumeThrow();
}
public void testSuspendThrowComplete() throws Exception
{
doSuspendThrowComplete();
}
public void testSuspendCompleteThrow() throws Exception
{
doSuspendCompleteThrow();
}
protected String toString(InputStream in) throws IOException
{
return IO.toString(in);
}
}

View File

@ -0,0 +1,151 @@
// ========================================================================
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.continuation;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jetty.continuation.test.ContinuationBase;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.FilterHolder;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.util.IO;
public class Jetty6ContinuationBioTest extends ContinuationBase
{
protected Server _server = new Server();
protected ServletHandler _servletHandler;
protected SocketConnector _socketConnector;
FilterHolder _filter;
protected void setUp() throws Exception
{
_socketConnector = new SocketConnector();
_server.setConnectors(new Connector[]{ _socketConnector });
Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS);
_server.setHandler(servletContext);
_servletHandler=servletContext.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet);
_servletHandler.addServletWithMapping(holder,"/");
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
_filter.setInitParameter("debug","true");
//_filter.setInitParameter("faux","false");
_server.start();
_port=_socketConnector.getLocalPort();
}
protected void tearDown() throws Exception
{
_server.stop();
}
public void testContinuation() throws Exception
{
doNormal("FauxContinuation");
}
public void testSleep() throws Exception
{
doSleep();
}
public void testSuspend() throws Exception
{
doSuspend();
}
public void testSuspendWaitResume() throws Exception
{
doSuspendWaitResume();
}
public void testSuspendResume() throws Exception
{
doSuspendResume();
}
public void testSuspendWaitComplete() throws Exception
{
doSuspendWaitComplete();
}
public void testSuspendComplete() throws Exception
{
doSuspendComplete();
}
public void testSuspendWaitResumeSuspendWaitResume() throws Exception
{
doSuspendWaitResumeSuspendWaitResume();
}
public void testSuspendWaitResumeSuspendComplete() throws Exception
{
doSuspendWaitResumeSuspendComplete();
}
public void testSuspendWaitResumeSuspend() throws Exception
{
doSuspendWaitResumeSuspend();
}
public void testSuspendTimeoutSuspendResume() throws Exception
{
doSuspendTimeoutSuspendResume();
}
public void testSuspendTimeoutSuspendComplete() throws Exception
{
doSuspendTimeoutSuspendComplete();
}
public void testSuspendTimeoutSuspend() throws Exception
{
doSuspendTimeoutSuspend();
}
public void testSuspendThrowResume() throws Exception
{
doSuspendThrowResume();
}
public void testSuspendResumeThrow() throws Exception
{
doSuspendResumeThrow();
}
public void testSuspendThrowComplete() throws Exception
{
doSuspendThrowComplete();
}
public void testSuspendCompleteThrow() throws Exception
{
doSuspendCompleteThrow();
}
protected String toString(InputStream in) throws IOException
{
return IO.toString(in);
}
}

View File

@ -28,7 +28,7 @@ import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.util.IO; import org.mortbay.util.IO;
public class Jetty6ContinuationTest extends ContinuationBase public class Jetty6ContinuationNioFauxTest extends ContinuationBase
{ {
protected Server _server = new Server(); protected Server _server = new Server();
protected ServletHandler _servletHandler; protected ServletHandler _servletHandler;
@ -39,14 +39,19 @@ public class Jetty6ContinuationTest extends ContinuationBase
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
_selectChannelConnector = new SelectChannelConnector(); _selectChannelConnector = new SelectChannelConnector();
_socketConnector = new SocketConnector(); _server.setConnectors(new Connector[]{ _selectChannelConnector });
_server.setConnectors(new Connector[]{ _selectChannelConnector,_socketConnector });
Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS); Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS);
_server.setHandler(servletContext); _server.setHandler(servletContext);
_servletHandler=servletContext.getServletHandler(); _servletHandler=servletContext.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet); ServletHolder holder=new ServletHolder(_servlet);
_servletHandler.addServletWithMapping(holder,"/"); _servletHandler.addServletWithMapping(holder,"/");
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0); _filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
_filter.setInitParameter("debug","true");
_filter.setInitParameter("faux","true");
_server.start();
_port=_selectChannelConnector.getLocalPort();
} }
protected void tearDown() throws Exception protected void tearDown() throws Exception
@ -54,44 +59,89 @@ public class Jetty6ContinuationTest extends ContinuationBase
_server.stop(); _server.stop();
} }
public void testJetty6Nio() throws Exception public void testContinuation() throws Exception
{ {
_filter.setInitParameter("debug","true"); doNormal("FauxContinuation");
//_filter.setInitParameter("faux","false");
_server.start();
_port=_selectChannelConnector.getLocalPort();
doit("Jetty6Continuation");
} }
public void testFauxNio() throws Exception public void testSleep() throws Exception
{ {
_filter.setInitParameter("debug","true"); doSleep();
_filter.setInitParameter("faux","true");
_server.start();
_port=_selectChannelConnector.getLocalPort();
doit("FauxContinuation");
} }
public void testJetty6Bio() throws Exception public void testSuspend() throws Exception
{ {
_filter.setInitParameter("debug","true"); doSuspend();
//_filter.setInitParameter("faux","false");
_server.start();
_port=_socketConnector.getLocalPort();
doit("FauxContinuation");
} }
public void testFauxBio() throws Exception public void testSuspendWaitResume() throws Exception
{ {
_filter.setInitParameter("debug","true"); doSuspendWaitResume();
_filter.setInitParameter("faux","true"); }
_server.start();
_port=_socketConnector.getLocalPort(); public void testSuspendResume() throws Exception
doit("FauxContinuation"); {
doSuspendResume();
}
public void testSuspendWaitComplete() throws Exception
{
doSuspendWaitComplete();
}
public void testSuspendComplete() throws Exception
{
doSuspendComplete();
}
public void testSuspendWaitResumeSuspendWaitResume() throws Exception
{
doSuspendWaitResumeSuspendWaitResume();
}
public void testSuspendWaitResumeSuspendComplete() throws Exception
{
doSuspendWaitResumeSuspendComplete();
}
public void testSuspendWaitResumeSuspend() throws Exception
{
doSuspendWaitResumeSuspend();
}
public void testSuspendTimeoutSuspendResume() throws Exception
{
doSuspendTimeoutSuspendResume();
}
public void testSuspendTimeoutSuspendComplete() throws Exception
{
doSuspendTimeoutSuspendComplete();
}
public void testSuspendTimeoutSuspend() throws Exception
{
doSuspendTimeoutSuspend();
}
public void testSuspendThrowResume() throws Exception
{
doSuspendThrowResume();
}
public void testSuspendResumeThrow() throws Exception
{
doSuspendResumeThrow();
}
public void testSuspendThrowComplete() throws Exception
{
doSuspendThrowComplete();
}
public void testSuspendCompleteThrow() throws Exception
{
doSuspendCompleteThrow();
} }
protected String toString(InputStream in) throws IOException protected String toString(InputStream in) throws IOException

View File

@ -0,0 +1,151 @@
// ========================================================================
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.continuation;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jetty.continuation.test.ContinuationBase;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.FilterHolder;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.util.IO;
public class Jetty6ContinuationNioTest extends ContinuationBase
{
protected Server _server = new Server();
protected ServletHandler _servletHandler;
protected SelectChannelConnector _selectChannelConnector;
FilterHolder _filter;
protected void setUp() throws Exception
{
_selectChannelConnector = new SelectChannelConnector();
_server.setConnectors(new Connector[]{ _selectChannelConnector });
Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS);
_server.setHandler(servletContext);
_servletHandler=servletContext.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet);
_servletHandler.addServletWithMapping(holder,"/");
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
_filter.setInitParameter("debug","true");
//_filter.setInitParameter("faux","false");
_server.start();
_port=_selectChannelConnector.getLocalPort();
}
protected void tearDown() throws Exception
{
_server.stop();
}
public void testContinuation() throws Exception
{
doNormal("Jetty6Continuation");
}
public void testSleep() throws Exception
{
doSleep();
}
public void testSuspend() throws Exception
{
doSuspend();
}
public void testSuspendWaitResume() throws Exception
{
doSuspendWaitResume();
}
public void testSuspendResume() throws Exception
{
doSuspendResume();
}
public void testSuspendWaitComplete() throws Exception
{
doSuspendWaitComplete();
}
public void testSuspendComplete() throws Exception
{
doSuspendComplete();
}
public void testSuspendWaitResumeSuspendWaitResume() throws Exception
{
doSuspendWaitResumeSuspendWaitResume();
}
public void testSuspendWaitResumeSuspendComplete() throws Exception
{
doSuspendWaitResumeSuspendComplete();
}
public void testSuspendWaitResumeSuspend() throws Exception
{
doSuspendWaitResumeSuspend();
}
public void testSuspendTimeoutSuspendResume() throws Exception
{
doSuspendTimeoutSuspendResume();
}
public void testSuspendTimeoutSuspendComplete() throws Exception
{
doSuspendTimeoutSuspendComplete();
}
public void testSuspendTimeoutSuspend() throws Exception
{
doSuspendTimeoutSuspend();
}
public void testSuspendThrowResume() throws Exception
{
doSuspendThrowResume();
}
public void testSuspendResumeThrow() throws Exception
{
doSuspendResumeThrow();
}
public void testSuspendThrowComplete() throws Exception
{
doSuspendThrowComplete();
}
public void testSuspendCompleteThrow() throws Exception
{
doSuspendCompleteThrow();
}
protected String toString(InputStream in) throws IOException
{
return IO.toString(in);
}
}

View File

@ -37,122 +37,150 @@ public abstract class ContinuationBase extends TestCase
protected SuspendServlet _servlet=new SuspendServlet(); protected SuspendServlet _servlet=new SuspendServlet();
protected int _port; protected int _port;
protected void doit(String type) throws Exception protected void doNormal(String type) throws Exception
{ {
String response; String response=process(null,null);
response=process(null,null);
assertContains(type,response); assertContains(type,response);
assertContains("NORMAL",response); assertContains("NORMAL",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertNotContains("history: onComplete",response); assertNotContains("history: onComplete",response);
}
response=process("sleep=200",null); protected void doSleep() throws Exception
{
String response=process("sleep=200",null);
assertContains("SLEPT",response); assertContains("SLEPT",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertNotContains("history: onComplete",response); assertNotContains("history: onComplete",response);
}
response=process("suspend=200",null); protected void doSuspend() throws Exception
{
String response=process("suspend=200",null);
assertContains("TIMEOUT",response); assertContains("TIMEOUT",response);
assertContains("history: onTimeout",response); assertContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&resume=10",null); protected void doSuspendWaitResume() throws Exception
{
String response=process("suspend=200&resume=10",null);
assertContains("RESUMED",response); assertContains("RESUMED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&resume=0",null); protected void doSuspendResume() throws Exception
{
String response=process("suspend=200&resume=0",null);
assertContains("RESUMED",response); assertContains("RESUMED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&complete=10",null); protected void doSuspendWaitComplete() throws Exception
{
String response=process("suspend=200&complete=10",null);
assertContains("COMPLETED",response); assertContains("COMPLETED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&complete=0",null); protected void doSuspendComplete() throws Exception
{
String response=process("suspend=200&complete=0",null);
assertContains("COMPLETED",response); assertContains("COMPLETED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
protected void doSuspendWaitResumeSuspendWaitResume() throws Exception
response=process("suspend=1000&resume=10&suspend2=1000&resume2=10",null); {
String response=process("suspend=1000&resume=10&suspend2=1000&resume2=10",null);
assertEquals(2,count(response,"history: suspend")); assertEquals(2,count(response,"history: suspend"));
assertEquals(2,count(response,"history: resume")); assertEquals(2,count(response,"history: resume"));
assertEquals(0,count(response,"history: onTimeout")); assertEquals(0,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete")); assertEquals(1,count(response,"history: onComplete"));
assertContains("RESUMED",response); assertContains("RESUMED",response);
}
response=process("suspend=1000&resume=10&suspend2=1000&resume2=10",null); protected void doSuspendWaitResumeSuspendComplete() throws Exception
assertEquals(2,count(response,"history: suspend")); {
assertEquals(2,count(response,"history: resume")); String response=process("suspend=1000&resume=10&suspend2=1000&complete2=10",null);
assertEquals(0,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete"));
assertContains("RESUMED",response);
response=process("suspend=1000&resume=10&suspend2=1000&complete2=10",null);
assertEquals(2,count(response,"history: suspend")); assertEquals(2,count(response,"history: suspend"));
assertEquals(1,count(response,"history: resume")); assertEquals(1,count(response,"history: resume"));
assertEquals(0,count(response,"history: onTimeout")); assertEquals(0,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete")); assertEquals(1,count(response,"history: onComplete"));
assertContains("COMPLETED",response); assertContains("COMPLETED",response);
}
response=process("suspend=1000&resume=10&suspend2=10",null); protected void doSuspendWaitResumeSuspend() throws Exception
{
String response=process("suspend=1000&resume=10&suspend2=10",null);
assertEquals(2,count(response,"history: suspend")); assertEquals(2,count(response,"history: suspend"));
assertEquals(1,count(response,"history: resume")); assertEquals(1,count(response,"history: resume"));
assertEquals(1,count(response,"history: onTimeout")); assertEquals(1,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete")); assertEquals(1,count(response,"history: onComplete"));
assertContains("TIMEOUT",response); assertContains("TIMEOUT",response);
}
protected void doSuspendTimeoutSuspendResume() throws Exception
{
response=process("suspend=10&suspend2=1000&resume2=10",null); String response=process("suspend=10&suspend2=1000&resume2=10",null);
assertEquals(2,count(response,"history: suspend")); assertEquals(2,count(response,"history: suspend"));
assertEquals(1,count(response,"history: resume")); assertEquals(1,count(response,"history: resume"));
assertEquals(1,count(response,"history: onTimeout")); assertEquals(1,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete")); assertEquals(1,count(response,"history: onComplete"));
assertContains("RESUMED",response); assertContains("RESUMED",response);
}
response=process("suspend=10&suspend2=1000&resume2=10",null); protected void doSuspendTimeoutSuspendComplete() throws Exception
assertEquals(2,count(response,"history: suspend")); {
assertEquals(1,count(response,"history: resume")); String response=process("suspend=10&suspend2=1000&complete2=10",null);
assertEquals(1,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete"));
assertContains("RESUMED",response);
response=process("suspend=10&suspend2=1000&complete2=10",null);
assertEquals(2,count(response,"history: suspend")); assertEquals(2,count(response,"history: suspend"));
assertEquals(0,count(response,"history: resume")); assertEquals(0,count(response,"history: resume"));
assertEquals(1,count(response,"history: onTimeout")); assertEquals(1,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete")); assertEquals(1,count(response,"history: onComplete"));
assertContains("COMPLETED",response); assertContains("COMPLETED",response);
}
response=process("suspend=10&suspend2=10",null); protected void doSuspendTimeoutSuspend() throws Exception
{
String response=process("suspend=10&suspend2=10",null);
assertEquals(2,count(response,"history: suspend")); assertEquals(2,count(response,"history: suspend"));
assertEquals(0,count(response,"history: resume")); assertEquals(0,count(response,"history: resume"));
assertEquals(2,count(response,"history: onTimeout")); assertEquals(2,count(response,"history: onTimeout"));
assertEquals(1,count(response,"history: onComplete")); assertEquals(1,count(response,"history: onComplete"));
assertContains("TIMEOUT",response); assertContains("TIMEOUT",response);
}
protected void doSuspendThrowResume() throws Exception
response=process("suspend=200&resume=10&undispatch=true",null); {
String response=process("suspend=200&resume=10&undispatch=true",null);
assertContains("RESUMED",response); assertContains("RESUMED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&resume=0&undispatch=true",null); protected void doSuspendResumeThrow() throws Exception
{
String response=process("suspend=200&resume=0&undispatch=true",null);
assertContains("RESUMED",response); assertContains("RESUMED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&complete=10&undispatch=true",null); protected void doSuspendThrowComplete() throws Exception
{
String response=process("suspend=200&complete=10&undispatch=true",null);
assertContains("COMPLETED",response); assertContains("COMPLETED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
}
response=process("suspend=200&complete=0&undispatch=true",null); protected void doSuspendCompleteThrow() throws Exception
{
String response=process("suspend=200&complete=0&undispatch=true",null);
assertContains("COMPLETED",response); assertContains("COMPLETED",response);
assertNotContains("history: onTimeout",response); assertNotContains("history: onTimeout",response);
assertContains("history: onComplete",response); assertContains("history: onComplete",response);
@ -226,7 +254,7 @@ public abstract class ContinuationBase extends TestCase
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
{ {
final Continuation continuation = ContinuationSupport.getContinuation(request,response); final Continuation continuation = ContinuationSupport.getContinuation(request);
response.addHeader("history",continuation.getClass().toString()); response.addHeader("history",continuation.getClass().toString());
@ -436,8 +464,7 @@ public abstract class ContinuationBase extends TestCase
} }
private static ContinuationListener __listener = private static ContinuationListener __listener = new ContinuationListener()
new ContinuationListener()
{ {
public void onComplete(Continuation continuation) public void onComplete(Continuation continuation)
{ {

View File

@ -44,6 +44,10 @@ public class ContinuationTest extends ContinuationBase
_servletHandler=servletContext.getServletHandler(); _servletHandler=servletContext.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet); ServletHolder holder=new ServletHolder(_servlet);
_servletHandler.addServletWithMapping(holder,"/"); _servletHandler.addServletWithMapping(holder,"/");
_server.start();
_port=_connector.getLocalPort();
} }
protected void tearDown() throws Exception protected void tearDown() throws Exception
@ -53,12 +57,90 @@ public class ContinuationTest extends ContinuationBase
public void testContinuation() throws Exception public void testContinuation() throws Exception
{ {
_server.start(); doNormal("AsyncContinuation");
_port=_connector.getLocalPort();
doit("AsyncContinuation");
} }
public void testSleep() throws Exception
{
doSleep();
}
public void testSuspend() throws Exception
{
doSuspend();
}
public void testSuspendWaitResume() throws Exception
{
doSuspendWaitResume();
}
public void testSuspendResume() throws Exception
{
doSuspendResume();
}
public void testSuspendWaitComplete() throws Exception
{
doSuspendWaitComplete();
}
public void testSuspendComplete() throws Exception
{
doSuspendComplete();
}
public void testSuspendWaitResumeSuspendWaitResume() throws Exception
{
doSuspendWaitResumeSuspendWaitResume();
}
public void testSuspendWaitResumeSuspendComplete() throws Exception
{
doSuspendWaitResumeSuspendComplete();
}
public void testSuspendWaitResumeSuspend() throws Exception
{
doSuspendWaitResumeSuspend();
}
public void testSuspendTimeoutSuspendResume() throws Exception
{
doSuspendTimeoutSuspendResume();
}
public void testSuspendTimeoutSuspendComplete() throws Exception
{
doSuspendTimeoutSuspendComplete();
}
public void testSuspendTimeoutSuspend() throws Exception
{
doSuspendTimeoutSuspend();
}
public void testSuspendThrowResume() throws Exception
{
doSuspendThrowResume();
}
public void testSuspendResumeThrow() throws Exception
{
doSuspendResumeThrow();
}
public void testSuspendThrowComplete() throws Exception
{
doSuspendThrowComplete();
}
public void testSuspendCompleteThrow() throws Exception
{
doSuspendCompleteThrow();
}
protected String toString(InputStream in) throws IOException protected String toString(InputStream in) throws IOException
{ {
return IO.toString(in); return IO.toString(in);

View File

@ -43,6 +43,13 @@ public class FauxContinuationTest extends ContinuationBase
_servletHandler=servletContext.getServletHandler(); _servletHandler=servletContext.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet); ServletHolder holder=new ServletHolder(_servlet);
_servletHandler.addServletWithMapping(holder,"/"); _servletHandler.addServletWithMapping(holder,"/");
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
_filter.setInitParameter("debug","true");
_filter.setInitParameter("faux","true");
_server.start();
_port=_connector.getLocalPort();
} }
protected void tearDown() throws Exception protected void tearDown() throws Exception
@ -50,27 +57,93 @@ public class FauxContinuationTest extends ContinuationBase
_server.stop(); _server.stop();
} }
public void testFaux() throws Exception public void testContinuation() throws Exception
{ {
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0); doNormal("FauxContinuation");
_filter.setInitParameter("debug","true");
_filter.setInitParameter("faux","true");
_server.start();
_port=_connector.getLocalPort();
doit("FauxContinuation");
} }
public void testNoFauxDefaults() throws Exception public void testSleep() throws Exception
{ {
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0); doSleep();
_filter.setInitParameter("debug","true");
_server.start();
_port=_connector.getLocalPort();
doit("AsyncContinuation");
} }
public void testSuspend() throws Exception
{
doSuspend();
}
public void testSuspendWaitResume() throws Exception
{
doSuspendWaitResume();
}
public void testSuspendResume() throws Exception
{
doSuspendResume();
}
public void testSuspendWaitComplete() throws Exception
{
doSuspendWaitComplete();
}
public void testSuspendComplete() throws Exception
{
doSuspendComplete();
}
public void testSuspendWaitResumeSuspendWaitResume() throws Exception
{
doSuspendWaitResumeSuspendWaitResume();
}
public void testSuspendWaitResumeSuspendComplete() throws Exception
{
doSuspendWaitResumeSuspendComplete();
}
public void testSuspendWaitResumeSuspend() throws Exception
{
doSuspendWaitResumeSuspend();
}
public void testSuspendTimeoutSuspendResume() throws Exception
{
doSuspendTimeoutSuspendResume();
}
public void testSuspendTimeoutSuspendComplete() throws Exception
{
doSuspendTimeoutSuspendComplete();
}
public void testSuspendTimeoutSuspend() throws Exception
{
doSuspendTimeoutSuspend();
}
public void testSuspendThrowResume() throws Exception
{
doSuspendThrowResume();
}
public void testSuspendResumeThrow() throws Exception
{
doSuspendResumeThrow();
}
public void testSuspendThrowComplete() throws Exception
{
doSuspendThrowComplete();
}
public void testSuspendCompleteThrow() throws Exception
{
doSuspendCompleteThrow();
}
protected String toString(InputStream in) throws IOException protected String toString(InputStream in) throws IOException
{ {
return IO.toString(in); return IO.toString(in);