390256: Remove Jetty6 Support
This commit is contained in:
parent
1cfa277c6c
commit
41d9db8d52
|
@ -83,7 +83,7 @@ public class WebApplicationProxyImpl implements WebApplicationProxy
|
|||
/** List of classpath files. */
|
||||
private List classPathFiles;
|
||||
|
||||
/** Jetty6 Web Application Context. */
|
||||
/** Jetty Web Application Context. */
|
||||
private WebAppContext webAppContext;
|
||||
|
||||
/** Extra scan targets. */
|
||||
|
|
|
@ -22,37 +22,9 @@
|
|||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Import-Package>javax.servlet.*;version="2.6.0",org.mortbay.log.*;version="[6.1,7)";resolution:=optional,org.mortbay.util.ajax.*;version="[6.1,7)";resolution:=optional,*</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>artifact-jar</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-jar</id>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
|
@ -66,13 +38,6 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
<version>3.0.0.v201112011016</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>6.1.26</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -33,15 +33,14 @@ import javax.servlet.ServletResponse;
|
|||
/**
|
||||
* <p>ContinuationFilter must be applied to servlet paths that make use of
|
||||
* the asynchronous features provided by {@link Continuation} APIs, but that
|
||||
* are deployed in servlet containers that are neither Jetty (>= 7) nor a
|
||||
* are deployed in servlet containers that are a
|
||||
* compliant Servlet 3.0 container.</p>
|
||||
* <p>The following init parameters may be used to configure the filter (these are mostly for testing):</p>
|
||||
* <dl>
|
||||
* <dt>debug</dt><dd>Boolean controlling debug output</dd>
|
||||
* <dt>jetty6</dt><dd>Boolean to force use of Jetty 6 continuations</dd>
|
||||
* <dt>faux</dt><dd>Boolean to force use of faux continuations</dd>
|
||||
* </dl>
|
||||
* <p>If the servlet container is not Jetty (either 6 or 7) nor a Servlet 3
|
||||
* <p>If the servlet container is not Jetty 7+ nor a Servlet 3
|
||||
* container, then "faux" continuations will be used.</p>
|
||||
* <p>Faux continuations will just put the thread that called {@link Continuation#suspend()}
|
||||
* in wait, and will notify that thread when {@link Continuation#resume()} or
|
||||
|
@ -54,7 +53,6 @@ public class ContinuationFilter implements Filter
|
|||
static boolean _initialized;
|
||||
static boolean __debug; // shared debug status
|
||||
private boolean _faux;
|
||||
private boolean _jetty6;
|
||||
private boolean _filtered;
|
||||
ServletContext _context;
|
||||
private boolean _debug;
|
||||
|
@ -69,25 +67,17 @@ public class ContinuationFilter implements Filter
|
|||
if (_debug)
|
||||
__debug=true;
|
||||
|
||||
param=filterConfig.getInitParameter("jetty6");
|
||||
if (param==null)
|
||||
param=filterConfig.getInitParameter("partial");
|
||||
if (param!=null)
|
||||
_jetty6=Boolean.parseBoolean(param);
|
||||
else
|
||||
_jetty6=ContinuationSupport.__jetty6 && !jetty_7_or_greater;
|
||||
|
||||
param=filterConfig.getInitParameter("partial");
|
||||
param=filterConfig.getInitParameter("faux");
|
||||
if (param!=null)
|
||||
_faux=Boolean.parseBoolean(param);
|
||||
else
|
||||
_faux=!(jetty_7_or_greater || _jetty6 || _context.getMajorVersion()>=3);
|
||||
_faux=!(jetty_7_or_greater || _context.getMajorVersion()>=3);
|
||||
|
||||
_filtered=_faux||_jetty6;
|
||||
_filtered=_faux;
|
||||
if (_debug)
|
||||
_context.log("ContinuationFilter "+
|
||||
" jetty="+jetty_7_or_greater+
|
||||
" jetty6="+_jetty6+
|
||||
" faux="+_faux+
|
||||
" filtered="+_filtered+
|
||||
" servlet3="+ContinuationSupport.__servlet3);
|
||||
|
|
|
@ -23,20 +23,17 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.ServletRequestWrapper;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** ContinuationSupport.
|
||||
/**
|
||||
* ContinuationSupport.
|
||||
*
|
||||
* Factory class for accessing Continuation instances, which with either be
|
||||
* native to the container (jetty >= 6), a servlet 3.0 or a faux continuation.
|
||||
*
|
||||
* a servlet 3.0 or a faux continuation.
|
||||
*/
|
||||
public class ContinuationSupport
|
||||
{
|
||||
static final boolean __jetty6;
|
||||
static final boolean __servlet3;
|
||||
static final Class<?> __waitingContinuation;
|
||||
static final Constructor<? extends Continuation> __newServlet3Continuation;
|
||||
static final Constructor<? extends Continuation> __newJetty6Continuation;
|
||||
static
|
||||
{
|
||||
boolean servlet3Support=false;
|
||||
|
@ -59,27 +56,6 @@ public class ContinuationSupport
|
|||
__newServlet3Continuation=s3cc;
|
||||
}
|
||||
|
||||
boolean jetty6Support=false;
|
||||
Constructor<? extends Continuation>j6cc=null;
|
||||
try
|
||||
{
|
||||
Class<?> jetty6ContinuationClass = ContinuationSupport.class.getClassLoader().loadClass("org.mortbay.util.ajax.Continuation");
|
||||
boolean jetty6=jetty6ContinuationClass!=null;
|
||||
if (jetty6)
|
||||
{
|
||||
Class<? extends Continuation> j6c = ContinuationSupport.class.getClassLoader().loadClass("org.eclipse.jetty.continuation.Jetty6Continuation").asSubclass(Continuation.class);
|
||||
j6cc=j6c.getConstructor(ServletRequest.class, jetty6ContinuationClass);
|
||||
jetty6Support=true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
finally
|
||||
{
|
||||
__jetty6=jetty6Support;
|
||||
__newJetty6Continuation=j6cc;
|
||||
}
|
||||
|
||||
Class<?> waiting=null;
|
||||
try
|
||||
{
|
||||
|
@ -128,24 +104,6 @@ public class ContinuationSupport
|
|||
}
|
||||
}
|
||||
|
||||
if (__jetty6)
|
||||
{
|
||||
Object c=request.getAttribute("org.mortbay.jetty.ajax.Continuation");
|
||||
try
|
||||
{
|
||||
if (c==null || __waitingContinuation==null || __waitingContinuation.isInstance(c))
|
||||
continuation=new FauxContinuation(request);
|
||||
else
|
||||
continuation= __newJetty6Continuation.newInstance(request,c);
|
||||
request.setAttribute(Continuation.ATTRIBUTE,continuation);
|
||||
return continuation;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("!(Jetty || Servlet 3.0 || ContinuationFilter)");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,266 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletResponseWrapper;
|
||||
|
||||
import org.mortbay.log.Log;
|
||||
import org.mortbay.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This implementation of Continuation is used by {@link ContinuationSupport}
|
||||
* when it detects that the application is deployed in a jetty-6 server.
|
||||
* This continuation requires the {@link ContinuationFilter} to be deployed.
|
||||
*/
|
||||
public class Jetty6Continuation implements ContinuationFilter.FilteredContinuation
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Jetty6Continuation.class.getName());
|
||||
|
||||
// Exception reused for all continuations
|
||||
// Turn on debug in ContinuationFilter to see real stack trace.
|
||||
private final static ContinuationThrowable __exception = new ContinuationThrowable();
|
||||
|
||||
private final ServletRequest _request;
|
||||
private ServletResponse _response;
|
||||
private final org.mortbay.util.ajax.Continuation _j6Continuation;
|
||||
|
||||
private Throwable _retry;
|
||||
private int _timeout;
|
||||
private boolean _initial=true;
|
||||
private volatile boolean _completed=false;
|
||||
private volatile boolean _resumed=false;
|
||||
private volatile boolean _expired=false;
|
||||
private boolean _responseWrapped=false;
|
||||
private List<ContinuationListener> _listeners;
|
||||
|
||||
public Jetty6Continuation(ServletRequest request, org.mortbay.util.ajax.Continuation continuation)
|
||||
{
|
||||
if (!ContinuationFilter._initialized)
|
||||
{
|
||||
LOG.warn("!ContinuationFilter installed",null,null);
|
||||
throw new IllegalStateException("!ContinuationFilter installed");
|
||||
}
|
||||
_request=request;
|
||||
_j6Continuation=continuation;
|
||||
}
|
||||
|
||||
public void addContinuationListener(final ContinuationListener listener)
|
||||
{
|
||||
if (_listeners==null)
|
||||
_listeners=new ArrayList<ContinuationListener>();
|
||||
_listeners.add(listener);
|
||||
}
|
||||
|
||||
public void complete()
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
if (_resumed)
|
||||
throw new IllegalStateException();
|
||||
_completed=true;
|
||||
if (_j6Continuation.isPending())
|
||||
_j6Continuation.resume();
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.continuation.Continuation#getAttribute(java.lang.String)
|
||||
*/
|
||||
public Object getAttribute(String name)
|
||||
{
|
||||
return _request.getAttribute(name);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.continuation.Continuation#removeAttribute(java.lang.String)
|
||||
*/
|
||||
public void removeAttribute(String name)
|
||||
{
|
||||
_request.removeAttribute(name);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.continuation.Continuation#setAttribute(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public void setAttribute(String name, Object attribute)
|
||||
{
|
||||
_request.setAttribute(name,attribute);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public ServletResponse getServletResponse()
|
||||
{
|
||||
return _response;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isExpired()
|
||||
{
|
||||
return _expired;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isInitial()
|
||||
{
|
||||
return _initial;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isResumed()
|
||||
{
|
||||
return _resumed;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isSuspended()
|
||||
{
|
||||
return _retry!=null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void resume()
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
if (_completed)
|
||||
throw new IllegalStateException();
|
||||
_resumed=true;
|
||||
if (_j6Continuation.isPending())
|
||||
_j6Continuation.resume();
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setTimeout(long timeoutMs)
|
||||
{
|
||||
_timeout=(timeoutMs>Integer.MAX_VALUE)?Integer.MAX_VALUE:(int)timeoutMs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.continuation.Continuation#suspend(javax.servlet.ServletResponse)
|
||||
*/
|
||||
public void suspend(ServletResponse response)
|
||||
{
|
||||
try
|
||||
{
|
||||
_response=response;
|
||||
_responseWrapped=_response instanceof ServletResponseWrapper;
|
||||
_resumed=false;
|
||||
_expired=false;
|
||||
_completed=false;
|
||||
_j6Continuation.suspend(_timeout);
|
||||
}
|
||||
catch(Throwable retry)
|
||||
{
|
||||
_retry=retry;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void suspend()
|
||||
{
|
||||
try
|
||||
{
|
||||
_response=null;
|
||||
_responseWrapped=false;
|
||||
_resumed=false;
|
||||
_expired=false;
|
||||
_completed=false;
|
||||
_j6Continuation.suspend(_timeout);
|
||||
}
|
||||
catch(Throwable retry)
|
||||
{
|
||||
_retry=retry;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isResponseWrapped()
|
||||
{
|
||||
return _responseWrapped;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.continuation.Continuation#undispatch()
|
||||
*/
|
||||
public void undispatch()
|
||||
{
|
||||
if (isSuspended())
|
||||
{
|
||||
if (ContinuationFilter.__debug)
|
||||
throw new ContinuationThrowable();
|
||||
throw __exception;
|
||||
}
|
||||
throw new IllegalStateException("!suspended");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean enter(ServletResponse response)
|
||||
{
|
||||
_response=response;
|
||||
_expired=!_j6Continuation.isResumed();
|
||||
|
||||
if (_initial)
|
||||
return true;
|
||||
|
||||
_j6Continuation.reset();
|
||||
|
||||
if (_expired)
|
||||
{
|
||||
if (_listeners!=null)
|
||||
{
|
||||
for (ContinuationListener l: _listeners)
|
||||
l.onTimeout(this);
|
||||
}
|
||||
}
|
||||
|
||||
return !_completed;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean exit()
|
||||
{
|
||||
_initial=false;
|
||||
|
||||
Throwable th=_retry;
|
||||
_retry=null;
|
||||
if (th instanceof Error)
|
||||
throw (Error)th;
|
||||
if (th instanceof RuntimeException)
|
||||
throw (RuntimeException)th;
|
||||
|
||||
if (_listeners!=null)
|
||||
{
|
||||
for (ContinuationListener l: _listeners)
|
||||
l.onComplete(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-project</artifactId>
|
||||
<version>8.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>test-continuation-jetty6</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Test :: Continuation - (Jetty 6)</name>
|
||||
<description>Asynchronous API</description>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- DO NOT DEPLOY (or Release) -->
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5-20081211</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>${servlet.spec.groupId}</groupId>
|
||||
<artifactId>${servlet.spec.artifactId}</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>test-continuation</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>${servlet.spec.groupId}</groupId>
|
||||
<artifactId>${servlet.spec.artifactId}</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty</artifactId>
|
||||
<version>6.1.26</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>servlet-api-2.5</artifactId>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,428 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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 java.net.Socket;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
|
||||
public abstract class ContinuationBase extends TestCase
|
||||
{
|
||||
protected SuspendServlet _servlet=new SuspendServlet();
|
||||
protected int _port;
|
||||
|
||||
protected void doit(String type) throws Exception
|
||||
{
|
||||
String response;
|
||||
|
||||
response=process(null,null);
|
||||
assertContains(type,response);
|
||||
assertContains("NORMAL",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertNotContains("history: onComplete",response);
|
||||
|
||||
response=process("sleep=200",null);
|
||||
assertContains("SLEPT",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertNotContains("history: onComplete",response);
|
||||
|
||||
response=process("suspend=200",null);
|
||||
assertContains("TIMEOUT",response);
|
||||
assertContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",response);
|
||||
|
||||
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);
|
||||
assertContains("RESUMED",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",response);
|
||||
|
||||
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);
|
||||
assertContains("COMPLETED",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",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&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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private int count(String responses,String substring)
|
||||
{
|
||||
int count=0;
|
||||
int i=responses.indexOf(substring);
|
||||
while (i>=0)
|
||||
{
|
||||
count++;
|
||||
i=responses.indexOf(substring,i+substring.length());
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
protected void assertContains(String content,String response)
|
||||
{
|
||||
assertEquals("HTTP/1.1 200 OK",response.substring(0,15));
|
||||
if (response.indexOf(content,15)<0)
|
||||
{
|
||||
System.err.println(content+" NOT IN '"+response+"'");
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertNotContains(String content,String response)
|
||||
{
|
||||
assertEquals("HTTP/1.1 200 OK",response.substring(0,15));
|
||||
if (response.indexOf(content,15)>=0)
|
||||
{
|
||||
System.err.println(content+" IS IN '"+response+"'");
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized String process(String query,String content) throws Exception
|
||||
{
|
||||
String request = "GET /";
|
||||
|
||||
if (query!=null)
|
||||
request+="?"+query;
|
||||
request+=" HTTP/1.1\r\n"+
|
||||
"Host: localhost\r\n"+
|
||||
"Connection: close\r\n";
|
||||
if (content!=null)
|
||||
request+="Content-Length: "+content.length()+"\r\n";
|
||||
request+="\r\n" + content;
|
||||
|
||||
Socket socket = new Socket("localhost",_port);
|
||||
socket.getOutputStream().write(request.getBytes("UTF-8"));
|
||||
|
||||
String response = toString(socket.getInputStream());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
protected abstract String toString(InputStream in) throws IOException;
|
||||
|
||||
|
||||
private static class SuspendServlet extends HttpServlet
|
||||
{
|
||||
private Timer _timer=new Timer();
|
||||
|
||||
public SuspendServlet()
|
||||
{}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
final Continuation continuation = ContinuationSupport.getContinuation(request,response);
|
||||
|
||||
response.addHeader("history",continuation.getClass().toString());
|
||||
|
||||
int read_before=0;
|
||||
long sleep_for=-1;
|
||||
long suspend_for=-1;
|
||||
long suspend2_for=-1;
|
||||
long resume_after=-1;
|
||||
long resume2_after=-1;
|
||||
long complete_after=-1;
|
||||
long complete2_after=-1;
|
||||
|
||||
if (request.getParameter("read")!=null)
|
||||
read_before=Integer.parseInt(request.getParameter("read"));
|
||||
if (request.getParameter("sleep")!=null)
|
||||
sleep_for=Integer.parseInt(request.getParameter("sleep"));
|
||||
if (request.getParameter("suspend")!=null)
|
||||
suspend_for=Integer.parseInt(request.getParameter("suspend"));
|
||||
if (request.getParameter("suspend2")!=null)
|
||||
suspend2_for=Integer.parseInt(request.getParameter("suspend2"));
|
||||
if (request.getParameter("resume")!=null)
|
||||
resume_after=Integer.parseInt(request.getParameter("resume"));
|
||||
if (request.getParameter("resume2")!=null)
|
||||
resume2_after=Integer.parseInt(request.getParameter("resume2"));
|
||||
if (request.getParameter("complete")!=null)
|
||||
complete_after=Integer.parseInt(request.getParameter("complete"));
|
||||
if (request.getParameter("complete2")!=null)
|
||||
complete2_after=Integer.parseInt(request.getParameter("complete2"));
|
||||
|
||||
if (continuation.isInitial())
|
||||
{
|
||||
if (read_before>0)
|
||||
{
|
||||
byte[] buf=new byte[read_before];
|
||||
request.getInputStream().read(buf);
|
||||
}
|
||||
else if (read_before<0)
|
||||
{
|
||||
InputStream in = request.getInputStream();
|
||||
int b=in.read();
|
||||
while(b!=-1)
|
||||
b=in.read();
|
||||
}
|
||||
|
||||
if (suspend_for>=0)
|
||||
{
|
||||
if (suspend_for>0)
|
||||
continuation.setTimeout(suspend_for);
|
||||
continuation.addContinuationListener(__listener);
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","suspend");
|
||||
continuation.suspend();
|
||||
|
||||
if (complete_after>0)
|
||||
{
|
||||
TimerTask complete = new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(complete,complete_after);
|
||||
}
|
||||
}
|
||||
else if (complete_after==0)
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
else if (resume_after>0)
|
||||
{
|
||||
TimerTask resume = new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(resume,resume_after);
|
||||
}
|
||||
}
|
||||
else if (resume_after==0)
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
}
|
||||
else if (sleep_for>=0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(sleep_for);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("SLEPT\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("NORMAL\n");
|
||||
}
|
||||
}
|
||||
else if (suspend2_for>=0 && request.getAttribute("2nd")==null)
|
||||
{
|
||||
request.setAttribute("2nd","cycle");
|
||||
|
||||
if (suspend2_for>0)
|
||||
continuation.setTimeout(suspend2_for);
|
||||
// continuation.addContinuationListener(__listener);
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","suspend");
|
||||
continuation.suspend();
|
||||
|
||||
if (complete2_after>0)
|
||||
{
|
||||
TimerTask complete = new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(complete,complete2_after);
|
||||
}
|
||||
}
|
||||
else if (complete2_after==0)
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("COMPLETED\n");
|
||||
continuation.complete();
|
||||
}
|
||||
else if (resume2_after>0)
|
||||
{
|
||||
TimerTask resume = new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
};
|
||||
synchronized (_timer)
|
||||
{
|
||||
_timer.schedule(resume,resume2_after);
|
||||
}
|
||||
}
|
||||
else if (resume2_after==0)
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","resume");
|
||||
continuation.resume();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (continuation.isExpired())
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("TIMEOUT\n");
|
||||
}
|
||||
else if (continuation.isResumed())
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("RESUMED\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.getOutputStream().println("unknown???\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static ContinuationListener __listener =
|
||||
new ContinuationListener()
|
||||
{
|
||||
public void onComplete(Continuation continuation)
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","onComplete");
|
||||
}
|
||||
|
||||
public void onTimeout(Continuation continuation)
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","onTimeout");
|
||||
continuation.resume();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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 javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
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 FauxContinuationTest extends ContinuationBase
|
||||
{
|
||||
protected Server _server = new Server();
|
||||
protected ServletHandler _servletHandler;
|
||||
protected SelectChannelConnector _connector;
|
||||
FilterHolder _filter;
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
_connector = new SelectChannelConnector();
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
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);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
_server.stop();
|
||||
}
|
||||
|
||||
public void testFaux() throws Exception
|
||||
{
|
||||
_filter.setInitParameter("debug","true");
|
||||
_filter.setInitParameter("faux","true");
|
||||
_server.start();
|
||||
_port=_connector.getLocalPort();
|
||||
|
||||
doit("FauxContinuation");
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String toString(InputStream in) throws IOException
|
||||
{
|
||||
return IO.toString(in);
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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 Jetty6ContinuationNioFauxTest extends ContinuationBase
|
||||
{
|
||||
protected Server _server = new Server();
|
||||
protected ServletHandler _servletHandler;
|
||||
protected SelectChannelConnector _selectChannelConnector;
|
||||
protected SocketConnector _socketConnector;
|
||||
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","true");
|
||||
_server.start();
|
||||
|
||||
_port=_selectChannelConnector.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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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;
|
||||
|
||||
@Override
|
||||
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");
|
||||
_server.start();
|
||||
|
||||
_port=_selectChannelConnector.getLocalPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toString(InputStream in) throws IOException
|
||||
{
|
||||
return IO.toString(in);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 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 org.eclipse.jetty.servlets.ProxyServlet;
|
||||
import org.junit.Ignore;
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
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;
|
||||
|
||||
@Ignore("Not a test case")
|
||||
public class TestProxyServer
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
|
||||
server.setConnectors(new Connector[]{ selectChannelConnector });
|
||||
selectChannelConnector.setPort(8080);
|
||||
|
||||
Context servletContext = new Context(Context.NO_SECURITY|Context.NO_SESSIONS);
|
||||
server.setHandler(servletContext);
|
||||
ServletHandler servletHandler=servletContext.getServletHandler();
|
||||
|
||||
|
||||
ServletHolder proxy=new ServletHolder(ProxyServlet.Transparent.class);
|
||||
servletHandler.addServletWithMapping(proxy,"/ws/*");
|
||||
proxy.setInitParameter("ProxyTo","http://www.webtide.com");
|
||||
proxy.setInitParameter("Prefix","/ws");
|
||||
|
||||
FilterHolder filter=servletHandler.addFilterWithMapping(ContinuationFilter.class,"/*",0);
|
||||
filter.setInitParameter("debug","true");
|
||||
|
||||
server.start();
|
||||
server.join();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue