You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by be...@apache.org on 2012/04/19 16:38:39 UTC

svn commit: r1327968 - in /mina/vysper/trunk: ./ server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/ server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/

Author: berndf
Date: Thu Apr 19 14:38:39 2012
New Revision: 1327968

URL: http://svn.apache.org/viewvc?rev=1327968&view=rev
Log:
VYSPER-307: remove proprietary Jetty Continuations,  use pure Async Servlet 3.0. Contributed by Stig Runar Vangen. Thanks for contributing!

Modified:
    mina/vysper/trunk/pom.xml
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java
    mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java

Modified: mina/vysper/trunk/pom.xml
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/pom.xml?rev=1327968&r1=1327967&r2=1327968&view=diff
==============================================================================
--- mina/vysper/trunk/pom.xml (original)
+++ mina/vysper/trunk/pom.xml Thu Apr 19 14:38:39 2012
@@ -215,19 +215,19 @@
       <dependency>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-websocket</artifactId>
-        <version>7.5.1.v20110908</version>
+        <version>8.1.2.v20120308</version>
       </dependency>
 
       <dependency>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-servlet</artifactId>
-        <version>7.5.1.v20110908</version>
+        <version>8.1.2.v20120308</version>
       </dependency>
 
       <dependency>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-webapp</artifactId>
-        <version>7.5.1.v20110908</version>
+        <version>8.1.2.v20120308</version>
       </dependency>
 
       <!-- Test dependencies -->

Modified: mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java?rev=1327968&r1=1327967&r2=1327968&view=diff
==============================================================================
--- mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java (original)
+++ mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/main/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContext.java Thu Apr 19 14:38:39 2012
@@ -19,11 +19,17 @@
  */
 package org.apache.vysper.xmpp.extension.xep0124;
 
+import java.io.IOException;
 import java.util.LinkedList;
 import java.util.Queue;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.vysper.xml.fragment.Renderer;
 import org.apache.vysper.xml.fragment.XMLElement;
@@ -33,9 +39,6 @@ import org.apache.vysper.xmpp.server.Ser
 import org.apache.vysper.xmpp.server.SessionState;
 import org.apache.vysper.xmpp.stanza.Stanza;
 import org.apache.vysper.xmpp.writer.StanzaWriter;
-import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationListener;
-import org.eclipse.jetty.continuation.ContinuationSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -246,10 +249,9 @@ public class BoshBackedSessionContext ex
                 }
             }
         }
-        
-        Continuation continuation = ContinuationSupport.getContinuation(req.getHttpServletRequest());
-        continuation.setAttribute("response", boshResponse);
-        continuation.resume();
+
+        final AsyncContext asyncContext = this.saveResponse(req, boshResponse);
+        asyncContext.dispatch();
         latestWriteTimestamp = System.currentTimeMillis();
         updateInactivityChecker();
     }
@@ -287,9 +289,9 @@ public class BoshBackedSessionContext ex
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("rid = {} - BOSH writing response: {}", rid, new String(boshResponse.getContent()));
         }
-        Continuation continuation = ContinuationSupport.getContinuation(req.getHttpServletRequest());
-        continuation.setAttribute("response", boshResponse);
-        continuation.resume();
+
+        final AsyncContext asyncContext = this.saveResponse(req, boshResponse);
+        asyncContext.dispatch();
         close();
     }
 
@@ -305,9 +307,10 @@ public class BoshBackedSessionContext ex
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("rid = {} - BOSH writing response: {}", req.getRid(), new String(boshResponse.getContent()));
             }
-            Continuation continuation = ContinuationSupport.getContinuation(req.getHttpServletRequest());
-            continuation.setAttribute("response", boshResponse);
-            continuation.resume();
+
+            final AsyncContext asyncContext =
+                    this.saveResponse(req, boshResponse);
+            asyncContext.dispatch();
         }
         
         serverRuntimeContext.getResourceRegistry().unbindSession(this);
@@ -461,10 +464,12 @@ public class BoshBackedSessionContext ex
      * The synchronization on the session object ensures that there will be no concurrent writes or other concurrent
      * expirations for the BOSH client while the current request expires.
      */
-    synchronized private void requestExpired(Continuation continuation) {
-        BoshRequest req = (BoshRequest) continuation.getAttribute("request");
+    private synchronized void requestExpired(final AsyncContext context) {
+        final BoshRequest req =
+                (BoshRequest) context.getRequest().getAttribute("request");
         if (req == null) {
-            LOGGER.warn("Continuation expired without having an associated request!");
+            LOGGER.warn("Continuation expired without having "
+                    + "an associated request!");
             return;
         }
         LOGGER.debug("rid = {} - BOSH request expired", req.getRid());
@@ -487,11 +492,10 @@ public class BoshBackedSessionContext ex
         // reset the inactivity
         currentInactivity = inactivity;
         
-        Continuation continuation = ContinuationSupport.getContinuation(br.getHttpServletRequest());
-        addContinuationExpirationListener(continuation);
-        continuation.setTimeout(wait * 1000);
-        continuation.setAttribute("request", br);
-        continuation.suspend();
+        final AsyncContext context = br.getHttpServletRequest().startAsync();
+        this.addContinuationExpirationListener(context);
+        context.setTimeout(this.wait * 1000);
+        br.getHttpServletRequest().setAttribute("request", br);
 
         final int currentRequests = requests;
         synchronized (requestsWindow) {
@@ -614,7 +618,7 @@ public class BoshBackedSessionContext ex
         }
     }
     
-    private void respondToPause(int pause) {
+    protected void respondToPause(int pause) {
         LOGGER.debug("Setting inactivity period to {}", pause);
         currentInactivity = pause;
         for (;;) {
@@ -626,29 +630,36 @@ public class BoshBackedSessionContext ex
         }
     }
     
-    private void sendBrokenConnectionReport(long report, long delta) {
+    protected void sendBrokenConnectionReport(long report, long delta) {
         Stanza body = boshHandler.getTerminateResponse();
         body = boshHandler.addAttribute(body, "report", Long.toString(report));
         body = boshHandler.addAttribute(body, "time", Long.toString(delta));
         writeBOSHResponse(body);
     }
     
-    private void addContinuationExpirationListener(Continuation continuation) {
+    protected void addContinuationExpirationListener(final AsyncContext context) {
         // listen the continuation to be notified when the request expires
-        continuation.addContinuationListener(new ContinuationListener() {
+        context.addListener(new AsyncListener() {
 
-            public void onTimeout(Continuation continuation) {
-                requestExpired(continuation);
+            public void onTimeout(AsyncEvent event) throws IOException {
+                BoshBackedSessionContext.this.requestExpired(context);
             }
 
-            public void onComplete(Continuation continuation) {
+            public void onStartAsync(AsyncEvent event) throws IOException {
                 // ignore
             }
 
+            public void onError(AsyncEvent event) throws IOException {
+                LOGGER.warn("Async error", event.getThrowable());
+            }
+
+            public void onComplete(AsyncEvent event) throws IOException {
+                // ignore
+            }
         });
     }
-    
-    private void resendResponse(BoshRequest br) {
+
+    protected void resendResponse(BoshRequest br) {
         final Long rid = br.getRid();
         BoshResponse boshResponse = sentResponses.get(rid);
         if (boshResponse == null) {
@@ -658,14 +669,14 @@ public class BoshBackedSessionContext ex
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("rid = {} - BOSH writing response (resending): {}", rid, new String(boshResponse.getContent()));
         }
-        Continuation continuation = ContinuationSupport.getContinuation(br.getHttpServletRequest());
-        continuation.setAttribute("response", boshResponse);
-        continuation.resume();
-        latestWriteTimestamp = System.currentTimeMillis();
-        updateInactivityChecker();
+
+        final AsyncContext asyncContext = this.saveResponse(br, boshResponse);
+        asyncContext.dispatch();
+        this.latestWriteTimestamp = System.currentTimeMillis();
+        this.updateInactivityChecker();
     }
 
-    private BoshResponse getBoshResponse(Stanza stanza, Long ack) {
+    protected BoshResponse getBoshResponse(Stanza stanza, Long ack) {
         if (ack != null) {
             stanza = boshHandler.addAttribute(stanza, "ack", ack.toString());
         }
@@ -695,4 +706,10 @@ public class BoshBackedSessionContext ex
         }
     }
 
+    protected AsyncContext saveResponse(final BoshRequest boshRequest, final BoshResponse boshResponse) {
+        final HttpServletRequest request = boshRequest.getHttpServletRequest();
+        final AsyncContext asyncContext = request.getAsyncContext();
+        request.setAttribute("response", boshResponse);
+        return asyncContext;
+    }
 }

Modified: mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java?rev=1327968&r1=1327967&r2=1327968&view=diff
==============================================================================
--- mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java (original)
+++ mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshBackedSessionContextTest.java Thu Apr 19 14:38:39 2012
@@ -26,6 +26,11 @@ import static org.easymock.EasyMock.expe
 import static org.easymock.EasyMock.expectLastCall;
 import static org.junit.Assert.assertEquals;
 
+import java.io.IOException;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.vysper.xml.fragment.Renderer;
@@ -37,8 +42,6 @@ import org.apache.vysper.xmpp.stanza.Sta
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
-import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationListener;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -72,17 +75,19 @@ public class BoshBackedSessionContextTes
 
     @Test
     public void testWrite0() {
-        Continuation continuation = mocksControl.createMock(Continuation.class);
         HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
-        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
+        AsyncContext asyncContext = mocksControl.createMock(AsyncContext.class);
+        expect(httpServletRequest.startAsync()).andReturn(asyncContext);
+        expectLastCall().atLeastOnce();
+        expect(httpServletRequest.getAsyncContext()).andReturn(asyncContext);
         expectLastCall().atLeastOnce();
-        continuation.setTimeout(anyLong());
-        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
-        continuation.suspend();
-        continuation.resume();
-        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
+        asyncContext.setTimeout(anyLong());
+        asyncContext.dispatch();
+        expectLastCall().atLeastOnce();
+        httpServletRequest.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
+        asyncContext.addListener(EasyMock.<AsyncListener> anyObject());
         Capture<BoshResponse> captured = new Capture<BoshResponse>();
-        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
+        httpServletRequest.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
         mocksControl.replay();
 
         BoshBackedSessionContext boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, serverRuntimeContext, inactivityChecker);
@@ -115,36 +120,39 @@ public class BoshBackedSessionContextTes
     }
 
     @Test
-    public void testRequestExpired() {
+    public void testRequestExpired() throws IOException {
         Stanza emtpyStanza = new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH).build();
 
         // addRequest
         HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
-        Continuation continuation = mocksControl.createMock(Continuation.class);
-        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
+        AsyncContext asyncContext = mocksControl.createMock(AsyncContext.class);
+        expect(httpServletRequest.startAsync()).andReturn(asyncContext).atLeastOnce();
+        expect(httpServletRequest.getAsyncContext()).andReturn(asyncContext).atLeastOnce();
+        asyncContext.setTimeout(anyLong());
+        httpServletRequest.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
+
+        expect(asyncContext.getRequest()).andReturn(httpServletRequest).atLeastOnce();
+        asyncContext.dispatch();
         expectLastCall().atLeastOnce();
-        continuation.setTimeout(anyLong());
-        continuation.suspend();
-        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
 
-        Capture<ContinuationListener> listenerCaptured = new Capture<ContinuationListener>();
-        continuation.addContinuationListener(EasyMock.<ContinuationListener> capture(listenerCaptured));
-        
+        Capture<AsyncListener> listenerCaptured = new Capture<AsyncListener>();
+        asyncContext.addListener(EasyMock.<AsyncListener> capture(listenerCaptured));
+
+        AsyncEvent asyncEvent = mocksControl.createMock(AsyncEvent.class);
+
         BoshRequest br = new BoshRequest(httpServletRequest, emtpyStanza, 1L);
 
         // requestExpired
-        expect(continuation.getAttribute("request")).andReturn(br);
+        expect(httpServletRequest.getAttribute("request")).andReturn(br);
         Capture<BoshResponse> responseCaptured = new Capture<BoshResponse>();
-        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(responseCaptured));
+        httpServletRequest.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(responseCaptured));
 
         // write0
-        continuation.resume();
-
         mocksControl.replay();
         BoshBackedSessionContext boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, serverRuntimeContext, inactivityChecker);
         
         boshBackedSessionContext.insertRequest(br);
-        listenerCaptured.getValue().onTimeout(continuation);
+        listenerCaptured.getValue().onTimeout(asyncEvent);
         mocksControl.verify();
 
         assertEquals(new Renderer(emtpyStanza).getComplete(), new String(responseCaptured.getValue().getContent()));
@@ -156,30 +164,35 @@ public class BoshBackedSessionContextTes
         // addRequest
         HttpServletRequest httpServletRequest1 = mocksControl.createMock(HttpServletRequest.class);
         HttpServletRequest httpServletRequest2 = mocksControl.createMock(HttpServletRequest.class);
-        Continuation continuation1 = mocksControl.createMock(Continuation.class);
-        Continuation continuation2 = mocksControl.createMock(Continuation.class);
-        expect(httpServletRequest1.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation1);
-        expectLastCall().atLeastOnce();
-        expect(httpServletRequest2.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation2);
-        expectLastCall().atLeastOnce();
-        continuation1.setTimeout(anyLong());
-        continuation1.suspend();
+        AsyncContext asyncContext1 = mocksControl.createMock(AsyncContext.class);
+        AsyncContext asyncContext2 = mocksControl.createMock(AsyncContext.class);
+
+        expect(httpServletRequest1.startAsync()).andReturn(asyncContext1).atLeastOnce();
+        expect(httpServletRequest1.getAsyncContext()).andReturn(asyncContext1).atLeastOnce();
+
+        expect(httpServletRequest2.startAsync()).andReturn(asyncContext2).atLeastOnce();
+        expect(httpServletRequest2.getAsyncContext()).andReturn(asyncContext2).anyTimes();
+
+        asyncContext1.setTimeout(anyLong());
         Capture<BoshRequest> br1 = new Capture<BoshRequest>();
-        continuation1.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br1));
-        continuation2.setTimeout(anyLong());
-        continuation2.suspend();
+        httpServletRequest1.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br1));
+
+        asyncContext2.setTimeout(anyLong());
         Capture<BoshRequest> br2 = new Capture<BoshRequest>();
-        continuation2.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br2));
-        continuation1.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
-        continuation2.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
-        
+        httpServletRequest2.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br2));
+
+        asyncContext1.addListener(EasyMock.<AsyncListener> anyObject());
+        asyncContext2.addListener(EasyMock.<AsyncListener> anyObject());
+
+        asyncContext1.dispatch();
+        expectLastCall().atLeastOnce();
+
         Stanza body = new StanzaBuilder("body", NamespaceURIs.XEP0124_BOSH).build();
         expect(boshHandler.addAttribute(eq(body), eq("ack"), Long.toString(EasyMock.anyLong()))).andReturn(body);
 
         // write0
         Capture<BoshResponse> captured = new Capture<BoshResponse>();
-        continuation1.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
-        continuation1.resume();
+        httpServletRequest1.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
 
         mocksControl.replay();
         BoshBackedSessionContext boshBackedSessionContext = new BoshBackedSessionContext(boshHandler, serverRuntimeContext, inactivityChecker);
@@ -190,7 +203,7 @@ public class BoshBackedSessionContextTes
         boshBackedSessionContext.insertRequest(new BoshRequest(httpServletRequest2, body, 2L));
         boshBackedSessionContext.writeBOSHResponse(body);
         mocksControl.verify();
-        
+
         assertEquals(httpServletRequest1, br1.getValue().getHttpServletRequest());
         assertEquals(httpServletRequest2, br2.getValue().getHttpServletRequest());
 
@@ -201,14 +214,16 @@ public class BoshBackedSessionContextTes
     @Test
     public void testAddRequestWithDelayedResponses() {
         HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
-        Continuation continuation = mocksControl.createMock(Continuation.class);
-        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
-        expectLastCall().atLeastOnce();
-        continuation.setTimeout(anyLong());
-        continuation.suspend();
-        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
+        AsyncContext asyncContext = mocksControl.createMock(AsyncContext.class);
+        expect(httpServletRequest.startAsync()).andReturn(asyncContext).atLeastOnce();
+        expect(httpServletRequest.getAsyncContext()).andReturn(asyncContext).atLeastOnce();
+        asyncContext.setTimeout(anyLong());
+        httpServletRequest.setAttribute(eq("request"), EasyMock.<BoshRequest> notNull());
 
-        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
+        asyncContext.addListener(EasyMock.<AsyncListener> anyObject());
+
+        asyncContext.dispatch();
+        expectLastCall().atLeastOnce();
 
         Stanza body1 = mocksControl.createMock(Stanza.class);
         Stanza body2 = mocksControl.createMock(Stanza.class);
@@ -217,8 +232,7 @@ public class BoshBackedSessionContextTes
                 .andReturn(body);
         expectLastCall().times(2);
 
-        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> anyObject());
-        continuation.resume();
+        httpServletRequest.setAttribute(eq("response"), EasyMock.<BoshResponse> anyObject());
 
         mocksControl.replay();
 
@@ -229,5 +243,4 @@ public class BoshBackedSessionContextTes
         boshBackedSessionContext.insertRequest(new BoshRequest(httpServletRequest, body, 1L));
         mocksControl.verify();
     }
-
-}
\ No newline at end of file
+}

Modified: mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java?rev=1327968&r1=1327967&r2=1327968&view=diff
==============================================================================
--- mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java (original)
+++ mina/vysper/trunk/server/extensions/xep0124-xep0206-bosh/src/test/java/org/apache/vysper/xmpp/extension/xep0124/BoshHandlerTest.java Thu Apr 19 14:38:39 2012
@@ -25,11 +25,12 @@ import static org.easymock.EasyMock.anyL
 import static org.easymock.EasyMock.createControl;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
 
 import java.io.IOException;
 import java.util.Collections;
 
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncListener;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.vysper.xml.fragment.XMLElement;
@@ -47,8 +48,6 @@ import org.apache.vysper.xmpp.stanza.Sta
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
-import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationListener;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -81,14 +80,14 @@ public class BoshHandlerTest {
         expect(serverRuntimeContext.getNextSessionId()).andReturn("200");
         expect(serverRuntimeContext.getServerEnitity()).andReturn(new EntityImpl(null, "vysper.org", null));
         expect(serverRuntimeContext.getDefaultXMLLang()).andReturn("en");
-        Continuation continuation = mocksControl.createMock(Continuation.class);
-        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
-        expectLastCall().atLeastOnce();
-        continuation.setTimeout(anyLong());
+        AsyncContext asyncContext = mocksControl.createMock(AsyncContext.class);
+        expect(httpServletRequest.startAsync()).andReturn(asyncContext).atLeastOnce();
+        expect(httpServletRequest.getAsyncContext()).andReturn(asyncContext).atLeastOnce();
+        asyncContext.setTimeout(anyLong());
         Capture<BoshRequest> br = new Capture<BoshRequest>();
-        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
-        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
-        continuation.suspend();
+        httpServletRequest.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
+        asyncContext.addListener(EasyMock.<AsyncListener> anyObject());
+        asyncContext.dispatch();
 
         ServerFeatures serverFeatures = mocksControl.createMock(ServerFeatures.class);
         expect(serverRuntimeContext.getServerFeatures()).andReturn(serverFeatures);
@@ -96,8 +95,7 @@ public class BoshHandlerTest {
         expect(serverRuntimeContext.getModule(InBandRegistrationModule.class)).andReturn(null);
 
         Capture<BoshResponse> captured = new Capture<BoshResponse>();
-        continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
-        continuation.resume();
+        httpServletRequest.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
         mocksControl.replay();
 
         Stanza boshRequest = createSessionRequest();
@@ -127,12 +125,11 @@ public class BoshHandlerTest {
 
         // test session retrieval, retrieves the session above identified by sid=200
         mocksControl.reset();
-        expect(httpServletRequest.getAttribute(Continuation.ATTRIBUTE)).andReturn(continuation);
-        expectLastCall().atLeastOnce();
-        continuation.setTimeout(anyLong());
-        continuation.suspend();
-        continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
-        continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
+        expect(httpServletRequest.startAsync()).andReturn(asyncContext).atLeastOnce();
+        expect(httpServletRequest.getAsyncContext()).andReturn(asyncContext).anyTimes();
+        asyncContext.setTimeout(anyLong());
+        httpServletRequest.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
+        asyncContext.addListener(EasyMock.<AsyncListener> anyObject());
         StanzaProcessor stanzaProcessor = mocksControl.createMock(StanzaProcessor.class);
         expect(serverRuntimeContext.getStanzaProcessor()).andReturn(stanzaProcessor);
         Capture<Stanza> stanzaCaptured = new Capture<Stanza>();
@@ -220,4 +217,4 @@ public class BoshHandlerTest {
         return body.build();
     }
 
-}
\ No newline at end of file
+}