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:
parent
eb04a44ca6
commit
9583051709
13
VERSION.txt
13
VERSION.txt
|
@ -1,4 +1,7 @@
|
|||
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 Centralized Logging from Sandbox
|
||||
+ 274251 DefaultServlet supports exact match mode.
|
||||
|
@ -15,14 +18,16 @@ jetty-7.0.1-SNAPSHOT
|
|||
+ 291340 Race condition in onException() notifications
|
||||
+ 291543 make bin/*.sh scripts executable in distribution
|
||||
+ 291589 Update jetty-rewrite demo
|
||||
|
||||
jetty-7.0.0.v20091005 5 October 2009
|
||||
291340 Race condition in onException() notifications
|
||||
|
||||
jetty-7.0.0.v20091005 October 5 2009
|
||||
jetty-7.0.0.RC6 September 21 2009
|
||||
+ Fixed XSS issue in CookieDump demo servlet.
|
||||
+ 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
|
||||
+ 290761 HttpExchange isDone handles intercepted events.
|
||||
|
||||
jetty-7.0.0.RC6 September 18th 2009
|
||||
+ JETTY-719 Document state machine of jetty http client
|
||||
+ JETTY-780 CNFE during startup of webapp with spring-context >= 2.5.1
|
||||
+ JETTY-936 274251 Improved servlet matching and optimized'
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.EventListener;
|
|||
import javax.servlet.ServletRequestListener;
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** A Continuation Listener
|
||||
* <p>
|
||||
|
@ -35,4 +34,5 @@ public interface ContinuationListener extends EventListener
|
|||
* @param continuation
|
||||
*/
|
||||
public void onTimeout(Continuation continuation);
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import javax.servlet.ServletContext;
|
|||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
|
||||
/* temporary interface in anticipation of servlet 3.0 */
|
||||
public interface AsyncContext
|
||||
{
|
||||
|
@ -34,6 +36,8 @@ public interface AsyncContext
|
|||
public void dispatch(ServletContext context, String path);
|
||||
public void complete();
|
||||
public void start(Runnable run);
|
||||
public void setTimeout(long ms);
|
||||
public void addContinuationListener(ContinuationListener listener);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
@ -25,7 +28,6 @@ import org.eclipse.jetty.io.AsyncEndPoint;
|
|||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
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.thread.Timeout;
|
||||
|
||||
|
@ -66,7 +68,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected HttpConnection _connection;
|
||||
private Object _listeners;
|
||||
private List<ContinuationListener> _continuationListeners;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private int _state;
|
||||
|
@ -78,15 +80,11 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
private AsyncEventState _event;
|
||||
private volatile long _expireAt;
|
||||
|
||||
// private StringBuilder _history = new StringBuilder();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected AsyncContinuation()
|
||||
{
|
||||
_state=__IDLE;
|
||||
_initial=true;
|
||||
// _history.append(super.toString());
|
||||
// _history.append('\n');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -95,8 +93,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
synchronized(this)
|
||||
{
|
||||
_connection=connection;
|
||||
// _history.append(connection.toString());
|
||||
// _history.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,24 +101,23 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
{
|
||||
synchronized(this)
|
||||
{
|
||||
_listeners=LazyList.add(_listeners,listener);
|
||||
// _history.append('L');
|
||||
if (_continuationListeners==null)
|
||||
_continuationListeners=new ArrayList<ContinuationListener>();
|
||||
_continuationListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setAsyncTimeout(long ms)
|
||||
public void setTimeout(long ms)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
_timeoutMs=ms;
|
||||
// _history.append('T');
|
||||
// _history.append(ms);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public long getAsyncTimeout()
|
||||
public long getTimeout()
|
||||
{
|
||||
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()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('H');
|
||||
// _history.append(_connection.getRequest().getUri().toString());
|
||||
// _history.append(':');
|
||||
_responseWrapped=false;
|
||||
|
||||
switch(_state)
|
||||
{
|
||||
case __DISPATCHED:
|
||||
case __REDISPATCHED:
|
||||
case __COMPLETED:
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
|
||||
case __IDLE:
|
||||
_initial=true;
|
||||
_state=__DISPATCHED;
|
||||
return true;
|
||||
|
||||
case __ASYNCSTARTED:
|
||||
case __REDISPATCHING:
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
|
||||
|
||||
case __COMPLETING:
|
||||
_state=__UNCOMPLETED;
|
||||
return false;
|
||||
|
@ -260,7 +243,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
return true;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException(""+_state);
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,11 +258,9 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
{
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('S');
|
||||
_resumed=false;
|
||||
_expired=false;
|
||||
|
||||
// TODO move this to callers
|
||||
if (_event==null || request!=_event.getRequest() || response != _event.getResponse() || context != _event.getServletContext())
|
||||
_event=new AsyncEventState(context,request,response);
|
||||
else
|
||||
|
@ -293,25 +274,13 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
case __DISPATCHED:
|
||||
case __REDISPATCHED:
|
||||
_state=__ASYNCSTARTED;
|
||||
return;
|
||||
|
||||
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());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException(""+_state);
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -326,7 +295,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
{
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('U');
|
||||
List<ContinuationListener> listeners=_continuationListeners;
|
||||
|
||||
switch(_state)
|
||||
{
|
||||
case __REDISPATCHED:
|
||||
|
@ -362,8 +332,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
_state=__UNCOMPLETED;
|
||||
return true;
|
||||
|
||||
case __ASYNCWAIT:
|
||||
case __REDISPATCH:
|
||||
default:
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
}
|
||||
|
@ -376,18 +344,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
boolean dispatch=false;
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('D');
|
||||
switch(_state)
|
||||
{
|
||||
case __REDISPATCHED:
|
||||
case __DISPATCHED:
|
||||
case __IDLE:
|
||||
case __REDISPATCHING:
|
||||
case __COMPLETING:
|
||||
case __COMPLETED:
|
||||
case __UNCOMPLETED:
|
||||
return;
|
||||
|
||||
case __ASYNCSTARTED:
|
||||
_state=__REDISPATCHING;
|
||||
_resumed=true;
|
||||
|
@ -417,17 +375,17 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
/* ------------------------------------------------------------ */
|
||||
protected void expired()
|
||||
{
|
||||
Object listeners=null;
|
||||
final List<ContinuationListener> listeners;
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('E');
|
||||
switch(_state)
|
||||
{
|
||||
case __ASYNCSTARTED:
|
||||
case __ASYNCWAIT:
|
||||
listeners=_listeners;
|
||||
listeners=_continuationListeners;
|
||||
break;
|
||||
default:
|
||||
listeners=null;
|
||||
return;
|
||||
}
|
||||
_expired=true;
|
||||
|
@ -435,16 +393,11 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
|
||||
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
|
||||
{
|
||||
// synchronized (this)
|
||||
// {
|
||||
// _history.append('l');
|
||||
// _history.append(i);
|
||||
// }
|
||||
ContinuationListener listener=((ContinuationListener)LazyList.get(listeners,i));
|
||||
listener.onTimeout(this);
|
||||
}
|
||||
catch(Exception e)
|
||||
|
@ -456,7 +409,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('e');
|
||||
switch(_state)
|
||||
{
|
||||
case __ASYNCSTARTED:
|
||||
|
@ -478,16 +430,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
boolean dispatch=false;
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append('C');
|
||||
switch(_state)
|
||||
{
|
||||
case __IDLE:
|
||||
case __COMPLETED:
|
||||
case __REDISPATCHING:
|
||||
case __COMPLETING:
|
||||
case __REDISPATCH:
|
||||
return;
|
||||
|
||||
case __DISPATCHED:
|
||||
case __REDISPATCHED:
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
|
@ -520,34 +464,29 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
*/
|
||||
protected void doComplete()
|
||||
{
|
||||
Object listeners=null;
|
||||
final List<ContinuationListener> listeners;
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append("c");
|
||||
switch(_state)
|
||||
{
|
||||
case __UNCOMPLETED:
|
||||
_state=__COMPLETED;
|
||||
listeners=_listeners;
|
||||
listeners=_continuationListeners;
|
||||
break;
|
||||
|
||||
default:
|
||||
listeners=null;
|
||||
throw new IllegalStateException(this.getStatusString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (listeners!=null)
|
||||
{
|
||||
for(int i=0;i<LazyList.size(listeners);i++)
|
||||
for(int i=0;i<listeners.size();i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
// synchronized (this)
|
||||
// {
|
||||
// _history.append('l');
|
||||
// _history.append(i);
|
||||
// }
|
||||
((ContinuationListener)LazyList.get(listeners,i)).onComplete(this);
|
||||
listeners.get(i).onComplete(this);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -577,7 +516,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
_responseWrapped=false;
|
||||
cancelTimeout();
|
||||
_timeoutMs=DEFAULT_TIMEOUT;
|
||||
_listeners=null;
|
||||
_continuationListeners=null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,9 +525,8 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
{
|
||||
synchronized (this)
|
||||
{
|
||||
// _history.append("X");
|
||||
cancelTimeout();
|
||||
_listeners=null;
|
||||
_continuationListeners=null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,7 +570,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
}
|
||||
}
|
||||
else
|
||||
_connection.scheduleTimeout(_event._timeout,_timeoutMs);
|
||||
_connection.scheduleTimeout(_event,_timeoutMs);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -651,7 +589,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
{
|
||||
final AsyncEventState event=_event;
|
||||
if (event!=null)
|
||||
_connection.cancelTimeout(event._timeout);
|
||||
_connection.cancelTimeout(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -811,32 +749,15 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
{
|
||||
dispatch();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see Continuation#suspend(long)
|
||||
*/
|
||||
public void setTimeout(long timeoutMs)
|
||||
{
|
||||
setAsyncTimeout(timeoutMs);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see Continuation#suspend()
|
||||
*/
|
||||
public void suspend(ServletResponse response)
|
||||
{
|
||||
if (response instanceof ServletResponseWrapper)
|
||||
{
|
||||
_responseWrapped=true;
|
||||
AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),response);
|
||||
}
|
||||
else
|
||||
{
|
||||
_responseWrapped=false;
|
||||
AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),_connection.getResponse());
|
||||
}
|
||||
_responseWrapped=!(response instanceof Response);
|
||||
AsyncContinuation.this.suspend(_connection.getRequest().getServletContext(),_connection.getRequest(),response);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -845,7 +766,6 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
*/
|
||||
public void suspend()
|
||||
{
|
||||
// TODO simplify? move event creation to suspend(args)
|
||||
_responseWrapped=false;
|
||||
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 ServletRequest _request;
|
||||
private final ServletResponse _response;
|
||||
|
||||
ServletContext _dispatchContext;
|
||||
|
||||
String _path;
|
||||
final Timeout.Task _timeout = new Timeout.Task()
|
||||
{
|
||||
public void expired()
|
||||
{
|
||||
AsyncContinuation.this.expired();
|
||||
}
|
||||
};
|
||||
private ServletContext _dispatchContext;
|
||||
private String _path;
|
||||
|
||||
public AsyncEventState(ServletContext context, ServletRequest request, ServletResponse response)
|
||||
{
|
||||
|
@ -958,15 +869,11 @@ public class AsyncContinuation implements AsyncContext, Continuation
|
|||
public String getPath()
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
}
|
||||
|
||||
public String getHistory()
|
||||
{
|
||||
// synchronized (this)
|
||||
// {
|
||||
// return _history.toString();
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
public void expired()
|
||||
{
|
||||
AsyncContinuation.this.expired();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,20 +170,13 @@ public class Request implements HttpServletRequest
|
|||
setConnection(connection);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void addContinuationListener(ContinuationListener listener)
|
||||
{
|
||||
_async.addContinuationListener(listener);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void addEventListener(final EventListener listener)
|
||||
{
|
||||
if (listener instanceof ServletRequestAttributeListener)
|
||||
_requestAttributeListeners= LazyList.add(_requestAttributeListeners, listener);
|
||||
if (listener instanceof ContinuationListener)
|
||||
_async.addContinuationListener((ContinuationListener)listener);
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -1398,12 +1391,6 @@ public class Request implements HttpServletRequest
|
|||
_asyncSupported=supported;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setAsyncTimeout(long timeout)
|
||||
{
|
||||
_async.setAsyncTimeout(timeout);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* Set a request attribute.
|
||||
|
|
|
@ -197,10 +197,10 @@ public class AsyncContextTest extends TestCase
|
|||
b=in.read();
|
||||
}
|
||||
|
||||
if (_suspendFor>0)
|
||||
baseRequest.setAsyncTimeout(_suspendFor);
|
||||
baseRequest.addEventListener(__asyncListener);
|
||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||
asyncContext.addContinuationListener(__asyncListener);
|
||||
if (_suspendFor>0)
|
||||
asyncContext.setTimeout(_suspendFor);
|
||||
|
||||
if (_completeAfter>0)
|
||||
{
|
||||
|
|
|
@ -214,12 +214,11 @@ public class AsyncStressTest extends TestCase
|
|||
|
||||
if (suspend_for>=0)
|
||||
{
|
||||
if (suspend_for>0)
|
||||
baseRequest.setAsyncTimeout(suspend_for);
|
||||
baseRequest.addEventListener(__asyncListener);
|
||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||
|
||||
|
||||
asyncContext.addContinuationListener(__asyncListener);
|
||||
if (suspend_for>0)
|
||||
asyncContext.setTimeout(suspend_for);
|
||||
|
||||
if (complete_after>0)
|
||||
{
|
||||
TimerTask complete = new TimerTask()
|
||||
|
@ -241,7 +240,6 @@ public class AsyncStressTest extends TestCase
|
|||
System.err.println(uri+"=="+br.getUri());
|
||||
System.err.println(asyncContext+"=="+br.getAsyncContinuation());
|
||||
|
||||
System.err.println(((AsyncContinuation)asyncContext).getHistory());
|
||||
Log.warn(e);
|
||||
System.exit(1);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.mortbay.jetty.servlet.ServletHolder;
|
|||
import org.mortbay.util.IO;
|
||||
|
||||
|
||||
public class Jetty6ContinuationTest extends ContinuationBase
|
||||
public class Jetty6ContinuationNioFauxTest extends ContinuationBase
|
||||
{
|
||||
protected Server _server = new Server();
|
||||
protected ServletHandler _servletHandler;
|
||||
|
@ -39,14 +39,19 @@ public class Jetty6ContinuationTest extends ContinuationBase
|
|||
protected void setUp() throws Exception
|
||||
{
|
||||
_selectChannelConnector = new SelectChannelConnector();
|
||||
_socketConnector = new SocketConnector();
|
||||
_server.setConnectors(new Connector[]{ _selectChannelConnector,_socketConnector });
|
||||
_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","true");
|
||||
_server.start();
|
||||
|
||||
_port=_selectChannelConnector.getLocalPort();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
|
@ -54,44 +59,89 @@ public class Jetty6ContinuationTest extends ContinuationBase
|
|||
_server.stop();
|
||||
}
|
||||
|
||||
public void testJetty6Nio() throws Exception
|
||||
public void testContinuation() throws Exception
|
||||
{
|
||||
_filter.setInitParameter("debug","true");
|
||||
//_filter.setInitParameter("faux","false");
|
||||
_server.start();
|
||||
|
||||
_port=_selectChannelConnector.getLocalPort();
|
||||
doit("Jetty6Continuation");
|
||||
doNormal("FauxContinuation");
|
||||
}
|
||||
|
||||
public void testSleep() throws Exception
|
||||
{
|
||||
doSleep();
|
||||
}
|
||||
|
||||
public void testFauxNio() throws Exception
|
||||
public void testSuspend() throws Exception
|
||||
{
|
||||
_filter.setInitParameter("debug","true");
|
||||
_filter.setInitParameter("faux","true");
|
||||
_server.start();
|
||||
|
||||
_port=_selectChannelConnector.getLocalPort();
|
||||
doit("FauxContinuation");
|
||||
doSuspend();
|
||||
}
|
||||
|
||||
public void testJetty6Bio() throws Exception
|
||||
public void testSuspendWaitResume() throws Exception
|
||||
{
|
||||
_filter.setInitParameter("debug","true");
|
||||
//_filter.setInitParameter("faux","false");
|
||||
_server.start();
|
||||
|
||||
_port=_socketConnector.getLocalPort();
|
||||
doit("FauxContinuation");
|
||||
doSuspendWaitResume();
|
||||
}
|
||||
|
||||
public void testFauxBio() throws Exception
|
||||
public void testSuspendResume() throws Exception
|
||||
{
|
||||
_filter.setInitParameter("debug","true");
|
||||
_filter.setInitParameter("faux","true");
|
||||
_server.start();
|
||||
|
||||
_port=_socketConnector.getLocalPort();
|
||||
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
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -37,122 +37,150 @@ public abstract class ContinuationBase extends TestCase
|
|||
protected SuspendServlet _servlet=new SuspendServlet();
|
||||
protected int _port;
|
||||
|
||||
protected void doit(String type) throws Exception
|
||||
protected void doNormal(String type) throws Exception
|
||||
{
|
||||
String response;
|
||||
|
||||
response=process(null,null);
|
||||
String response=process(null,null);
|
||||
assertContains(type,response);
|
||||
assertContains("NORMAL",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertNotContains("history: onComplete",response);
|
||||
}
|
||||
|
||||
response=process("sleep=200",null);
|
||||
protected void doSleep() throws Exception
|
||||
{
|
||||
String response=process("sleep=200",null);
|
||||
assertContains("SLEPT",response);
|
||||
assertNotContains("history: onTimeout",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("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",response);
|
||||
|
||||
|
||||
response=process("suspend=1000&resume=10&suspend2=1000&resume2=10",null);
|
||||
}
|
||||
|
||||
protected void doSuspendWaitResumeSuspendWaitResume() throws Exception
|
||||
{
|
||||
String response=process("suspend=1000&resume=10&suspend2=1000&resume2=10",null);
|
||||
assertEquals(2,count(response,"history: suspend"));
|
||||
assertEquals(2,count(response,"history: resume"));
|
||||
assertEquals(0,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
assertContains("RESUMED",response);
|
||||
|
||||
response=process("suspend=1000&resume=10&suspend2=1000&resume2=10",null);
|
||||
assertEquals(2,count(response,"history: suspend"));
|
||||
assertEquals(2,count(response,"history: resume"));
|
||||
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);
|
||||
}
|
||||
|
||||
protected void doSuspendWaitResumeSuspendComplete() throws Exception
|
||||
{
|
||||
String response=process("suspend=1000&resume=10&suspend2=1000&complete2=10",null);
|
||||
assertEquals(2,count(response,"history: suspend"));
|
||||
assertEquals(1,count(response,"history: resume"));
|
||||
assertEquals(0,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
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(1,count(response,"history: resume"));
|
||||
assertEquals(1,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
assertContains("TIMEOUT",response);
|
||||
|
||||
}
|
||||
|
||||
|
||||
response=process("suspend=10&suspend2=1000&resume2=10",null);
|
||||
protected void doSuspendTimeoutSuspendResume() throws Exception
|
||||
{
|
||||
String response=process("suspend=10&suspend2=1000&resume2=10",null);
|
||||
assertEquals(2,count(response,"history: suspend"));
|
||||
assertEquals(1,count(response,"history: resume"));
|
||||
assertEquals(1,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
assertContains("RESUMED",response);
|
||||
|
||||
response=process("suspend=10&suspend2=1000&resume2=10",null);
|
||||
assertEquals(2,count(response,"history: suspend"));
|
||||
assertEquals(1,count(response,"history: resume"));
|
||||
assertEquals(1,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
assertContains("RESUMED",response);
|
||||
|
||||
response=process("suspend=10&suspend2=1000&complete2=10",null);
|
||||
}
|
||||
|
||||
protected void doSuspendTimeoutSuspendComplete() throws Exception
|
||||
{
|
||||
String response=process("suspend=10&suspend2=1000&complete2=10",null);
|
||||
assertEquals(2,count(response,"history: suspend"));
|
||||
assertEquals(0,count(response,"history: resume"));
|
||||
assertEquals(1,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
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(0,count(response,"history: resume"));
|
||||
assertEquals(2,count(response,"history: onTimeout"));
|
||||
assertEquals(1,count(response,"history: onComplete"));
|
||||
assertContains("TIMEOUT",response);
|
||||
|
||||
}
|
||||
|
||||
response=process("suspend=200&resume=10&undispatch=true",null);
|
||||
protected void doSuspendThrowResume() throws Exception
|
||||
{
|
||||
String response=process("suspend=200&resume=10&undispatch=true",null);
|
||||
assertContains("RESUMED",response);
|
||||
assertNotContains("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",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);
|
||||
assertNotContains("history: onTimeout",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
|
||||
{
|
||||
final Continuation continuation = ContinuationSupport.getContinuation(request,response);
|
||||
final Continuation continuation = ContinuationSupport.getContinuation(request);
|
||||
|
||||
response.addHeader("history",continuation.getClass().toString());
|
||||
|
||||
|
@ -436,8 +464,7 @@ public abstract class ContinuationBase extends TestCase
|
|||
}
|
||||
|
||||
|
||||
private static ContinuationListener __listener =
|
||||
new ContinuationListener()
|
||||
private static ContinuationListener __listener = new ContinuationListener()
|
||||
{
|
||||
public void onComplete(Continuation continuation)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,10 @@ public class ContinuationTest extends ContinuationBase
|
|||
_servletHandler=servletContext.getServletHandler();
|
||||
ServletHolder holder=new ServletHolder(_servlet);
|
||||
_servletHandler.addServletWithMapping(holder,"/");
|
||||
|
||||
_server.start();
|
||||
_port=_connector.getLocalPort();
|
||||
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
|
@ -53,12 +57,90 @@ public class ContinuationTest extends ContinuationBase
|
|||
|
||||
public void testContinuation() throws Exception
|
||||
{
|
||||
_server.start();
|
||||
_port=_connector.getLocalPort();
|
||||
|
||||
doit("AsyncContinuation");
|
||||
doNormal("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
|
||||
{
|
||||
return IO.toString(in);
|
||||
|
|
|
@ -43,6 +43,13 @@ public class FauxContinuationTest extends ContinuationBase
|
|||
_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=_connector.getLocalPort();
|
||||
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
|
@ -50,26 +57,92 @@ public class FauxContinuationTest extends ContinuationBase
|
|||
_server.stop();
|
||||
}
|
||||
|
||||
public void testFaux() throws Exception
|
||||
public void testContinuation() throws Exception
|
||||
{
|
||||
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
|
||||
_filter.setInitParameter("debug","true");
|
||||
_filter.setInitParameter("faux","true");
|
||||
_server.start();
|
||||
_port=_connector.getLocalPort();
|
||||
|
||||
doit("FauxContinuation");
|
||||
doNormal("FauxContinuation");
|
||||
}
|
||||
|
||||
public void testSleep() throws Exception
|
||||
{
|
||||
doSleep();
|
||||
}
|
||||
|
||||
public void testNoFauxDefaults() throws Exception
|
||||
public void testSuspend() throws Exception
|
||||
{
|
||||
_filter=_servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
|
||||
_filter.setInitParameter("debug","true");
|
||||
_server.start();
|
||||
_port=_connector.getLocalPort();
|
||||
|
||||
doit("AsyncContinuation");
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue