Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGreg Wilkins2013-09-27 07:47:31 +0000
committerGreg Wilkins2013-09-27 07:47:31 +0000
commit7dec90fafb8c219ca4a2a98b3b97afe470eec397 (patch)
treee4d8c88bcce6466c3416bfc52216850d5534039d /tests
parent0fac295cd82b59085d4aae5ca6792b2cda752455 (diff)
downloadorg.eclipse.jetty.project-7dec90fafb8c219ca4a2a98b3b97afe470eec397.tar.gz
org.eclipse.jetty.project-7dec90fafb8c219ca4a2a98b3b97afe470eec397.tar.xz
org.eclipse.jetty.project-7dec90fafb8c219ca4a2a98b3b97afe470eec397.zip
some demo cleanups
Diffstat (limited to 'tests')
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.d/override-web.xml (renamed from tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/etc/override-web.xml)11
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml2
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java214
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java18
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java4
5 files changed, 132 insertions, 117 deletions
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/etc/override-web.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.d/override-web.xml
index 08327c5dcb..c2bb1ebd18 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/etc/override-web.xml
+++ b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.d/override-web.xml
@@ -38,22 +38,17 @@
<load-on-startup>5</load-on-startup>
</servlet>
- <!-- Uncomment to override the setup of the test filter -->
- <!--
+ <!-- Allow remote access to test webapp -->
<filter>
<filter-name>TestFilter</filter-name>
<filter-class>com.acme.TestFilter</filter-class>
<async-support>true</async-support>
<init-param>
<param-name>remote</param-name>
- <param-value>false</param-value>
+ <param-value>true</param-value>
</init-param>
</filter>
- <filter-mapping>
- <filter-name>TestFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- -->
+
</web-app>
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml
index 73493e105a..a5b5bf8cde 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml
+++ b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml
@@ -27,7 +27,7 @@ detected.
<Set name="extractWAR">true</Set>
<Set name="copyWebDir">false</Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
- <Set name="overrideDescriptor"><Property name="jetty.base" default="."/>/etc/override-web.xml</Set>
+ <Set name="overrideDescriptor"><Property name="jetty.webapps" default="."/>/override-web.xml</Set>
<!-- Enable WebSocket container -->
<Call name="setAttribute">
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java
index 326015ba64..3d237ab60d 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java
+++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java
@@ -36,6 +36,9 @@ import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -51,9 +54,6 @@ import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
-import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationListener;
-import org.eclipse.jetty.continuation.ContinuationSupport;
/**
* Dump Servlet Request.
@@ -176,59 +176,18 @@ public class Dump extends HttpServlet
}
}
- if (request.getAttribute("RESUME")==null && request.getParameter("resume")!=null)
+ if (request.getParameter("startAsync")!=null && request.getAttribute("ASYNC")!=Boolean.TRUE)
{
- request.setAttribute("RESUME",Boolean.TRUE);
-
- final long resume=Long.parseLong(request.getParameter("resume"));
- final Continuation continuation = ContinuationSupport.getContinuation(request);
- _timer.schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- continuation.resume();
- }
- },resume);
-
- }
-
- if (request.getParameter("complete")!=null)
- {
- final long complete=Long.parseLong(request.getParameter("complete"));
- _timer.schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- try
- {
- response.setContentType("text/html");
- response.getOutputStream().println("<h1>COMPLETED</h1>");
- Continuation continuation = ContinuationSupport.getContinuation(request);
- continuation.complete();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- },complete);
- }
-
- if (request.getParameter("suspend")!=null && request.getAttribute("SUSPEND")!=Boolean.TRUE)
- {
- request.setAttribute("SUSPEND",Boolean.TRUE);
+ request.setAttribute("ASYNC",Boolean.TRUE);
try
{
- Continuation continuation = ContinuationSupport.getContinuation(request);
- continuation.setTimeout(Long.parseLong(request.getParameter("suspend")));
- continuation.suspend();
-
- continuation.addContinuationListener(new ContinuationListener()
+ final AsyncContext async=request.startAsync(request,response);
+ async.setTimeout(Long.parseLong(request.getParameter("startAsync")));
+ async.addListener(new AsyncListener()
{
+
@Override
- public void onTimeout(Continuation continuation)
+ public void onTimeout(AsyncEvent event) throws IOException
{
response.addHeader("Dump","onTimeout");
try
@@ -238,22 +197,73 @@ public class Dump extends HttpServlet
response.setContentType("text/plain");
response.getOutputStream().println("EXPIRED");
}
- continuation.complete();
+ async.complete();
}
catch (IOException e)
{
getServletContext().log("",e);
}
}
-
+
@Override
- public void onComplete(Continuation continuation)
+ public void onStartAsync(AsyncEvent event) throws IOException
+ {
+ response.addHeader("Dump","onStartAsync");
+ }
+
+ @Override
+ public void onError(AsyncEvent event) throws IOException
+ {
+ response.addHeader("Dump","onError");
+ }
+
+ @Override
+ public void onComplete(AsyncEvent event) throws IOException
{
response.addHeader("Dump","onComplete");
}
});
- continuation.undispatch();
+ if (request.getParameter("dispatch")!=null)
+ {
+ request.setAttribute("RESUME",Boolean.TRUE);
+
+ final long resume=Long.parseLong(request.getParameter("dispatch"));
+ _timer.schedule(new TimerTask()
+ {
+ @Override
+ public void run()
+ {
+ async.dispatch();
+ }
+ },resume);
+ }
+
+ if (request.getParameter("complete")!=null)
+ {
+ final long complete=Long.parseLong(request.getParameter("complete"));
+ _timer.schedule(new TimerTask()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ response.setContentType("text/html");
+ response.getOutputStream().println("<h1>COMPLETED</h1>");
+ async.complete();
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ },complete);
+ }
+
+
+
+ return;
}
catch(Exception e)
{
@@ -424,48 +434,20 @@ public class Dump extends HttpServlet
pout.write("<h1>Dump Servlet</h1>\n");
pout.write("<table width=\"95%\">");
pout.write("<tr>\n");
- pout.write("<th align=\"right\">getMethod:&nbsp;</th>");
- pout.write("<td>" + notag(request.getMethod())+"</td>");
- pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getContentLength:&nbsp;</th>");
pout.write("<td>"+Integer.toString(request.getContentLength())+"</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getContentType:&nbsp;</th>");
pout.write("<td>"+notag(request.getContentType())+"</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRequestURI:&nbsp;</th>");
- pout.write("<td>"+notag(request.getRequestURI())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRequestURL:&nbsp;</th>");
- pout.write("<td>"+notag(request.getRequestURL().toString())+"</td>");
- pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getContextPath:&nbsp;</th>");
pout.write("<td>"+request.getContextPath()+"</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getServletPath:&nbsp;</th>");
- pout.write("<td>"+notag(request.getServletPath())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getPathInfo:&nbsp;</th>");
- pout.write("<td>"+notag(request.getPathInfo())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getPathTranslated:&nbsp;</th>");
- pout.write("<td>"+notag(request.getPathTranslated())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getQueryString:&nbsp;</th>");
- pout.write("<td>"+notag(request.getQueryString())+"</td>");
- pout.write("</tr><tr>\n");
-
- pout.write("<th align=\"right\">getProtocol:&nbsp;</th>");
- pout.write("<td>"+request.getProtocol()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getScheme:&nbsp;</th>");
- pout.write("<td>"+request.getScheme()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getServerName:&nbsp;</th>");
- pout.write("<td>"+notag(request.getServerName())+"</td>");
+ pout.write("<th align=\"right\">getDispatcherType:&nbsp;</th>");
+ pout.write("<td>"+request.getDispatcherType()+"</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getServerPort:&nbsp;</th>");
- pout.write("<td>"+Integer.toString(request.getServerPort())+"</td>");
+ pout.write("<th align=\"right\">getLocale:&nbsp;</th>");
+ pout.write("<td>"+request.getLocale()+"</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getLocalName:&nbsp;</th>");
pout.write("<td>"+request.getLocalName()+"</td>");
@@ -476,11 +458,20 @@ public class Dump extends HttpServlet
pout.write("<th align=\"right\">getLocalPort:&nbsp;</th>");
pout.write("<td>"+Integer.toString(request.getLocalPort())+"</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRemoteUser:&nbsp;</th>");
- pout.write("<td>"+request.getRemoteUser()+"</td>");
+ pout.write("<th align=\"right\">getMethod:&nbsp;</th>");
+ pout.write("<td>" + notag(request.getMethod())+"</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getUserPrincipal:&nbsp;</th>");
- pout.write("<td>"+request.getUserPrincipal()+"</td>");
+ pout.write("<th align=\"right\">getPathInfo:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getPathInfo())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getPathTranslated:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getPathTranslated())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getProtocol:&nbsp;</th>");
+ pout.write("<td>"+request.getProtocol()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getQueryString:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getQueryString())+"</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRemoteAddr:&nbsp;</th>");
pout.write("<td>"+request.getRemoteAddr()+"</td>");
@@ -491,23 +482,48 @@ public class Dump extends HttpServlet
pout.write("<th align=\"right\">getRemotePort:&nbsp;</th>");
pout.write("<td>"+request.getRemotePort()+"</td>");
pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRemoteUser:&nbsp;</th>");
+ pout.write("<td>"+request.getRemoteUser()+"</td>");
+ pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRequestedSessionId:&nbsp;</th>");
pout.write("<td>"+request.getRequestedSessionId()+"</td>");
pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRequestURI:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getRequestURI())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getRequestURL:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getRequestURL().toString())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getScheme:&nbsp;</th>");
+ pout.write("<td>"+request.getScheme()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServerName:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getServerName())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServletPath:&nbsp;</th>");
+ pout.write("<td>"+notag(request.getServletPath())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getServerPort:&nbsp;</th>");
+ pout.write("<td>"+Integer.toString(request.getServerPort())+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">getUserPrincipal:&nbsp;</th>");
+ pout.write("<td>"+request.getUserPrincipal()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">isAsyncStarted():&nbsp;</th>");
+ pout.write("<td>"+request.isAsyncStarted()+"</td>");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\">isAsyncSupported():&nbsp;</th>");
+ pout.write("<td>"+request.isAsyncSupported()+"</td>");
+ pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">isSecure():&nbsp;</th>");
pout.write("<td>"+request.isSecure()+"</td>");
-
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">encodeRedirectURL(/foo?bar):&nbsp;</th>");
- pout.write("<td>"+response.encodeRedirectURL("/foo?bar")+"</td>");
-
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">isUserInRole(admin):&nbsp;</th>");
pout.write("<td>"+request.isUserInRole("admin")+"</td>");
-
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getLocale:&nbsp;</th>");
- pout.write("<td>"+request.getLocale()+"</td>");
+ pout.write("<th align=\"right\">encodeRedirectURL(/foo?bar):&nbsp;</th>");
+ pout.write("<td>"+response.encodeRedirectURL("/foo?bar")+"</td>");
+
Enumeration<Locale> locales= request.getLocales();
while (locales.hasMoreElements())
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java
index fe697513a9..a99e6f748a 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java
+++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestListener.java
@@ -126,16 +126,20 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
//// System.err.println("Overridding web.xml constraints not possible:" +!unchanged.isEmpty());
/* For servlet 3.0 */
- FilterRegistration.Dynamic registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName());
+ FilterRegistration registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName());
if (registration != null) //otherwise defined in web.xml
{
- registration.setInitParameter("remote", "false");
- registration.setAsyncSupported(true);
- registration.addMappingForUrlPatterns(
- EnumSet.of(DispatcherType.ERROR,DispatcherType.ASYNC,DispatcherType.FORWARD,DispatcherType.INCLUDE,DispatcherType.REQUEST),
- true,
- new String[]{"/*"});
+ ((FilterRegistration.Dynamic)registration).setAsyncSupported(true);
}
+ else
+ {
+ registration=sce.getServletContext().getFilterRegistration("TestFilter");
+ }
+ registration.setInitParameter("remote", "false");
+ registration.addMappingForUrlPatterns(
+ EnumSet.of(DispatcherType.ERROR,DispatcherType.ASYNC,DispatcherType.FORWARD,DispatcherType.INCLUDE,DispatcherType.REQUEST),
+ true,
+ new String[]{"/*"});
}
@Override
diff --git a/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java b/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java
index fde8fabe86..abad1cded1 100644
--- a/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java
+++ b/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java
@@ -100,7 +100,7 @@ public class TestServer
httpConnector.setIdleTimeout(30000);
server.addConnector(httpConnector);
-
+ /*
// SSL configurations
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(jetty_root + "/jetty-server/src/main/config/etc/keystore");
@@ -135,7 +135,7 @@ public class TestServer
spdyConnector.setIdleTimeout(15000);
server.addConnector(spdyConnector);
-
+ */
// Handlers
HandlerCollection handlers = new HandlerCollection();

Back to the top