// test session creation
HttpServletRequest httpServletRequest = mocksControl.createMock(HttpServletRequest.class);
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());
Capture<BoshRequest> br = new Capture<BoshRequest>();
continuation.setAttribute(eq("request"), EasyMock.<BoshRequest> capture(br));
continuation.addContinuationListener(EasyMock.<ContinuationListener> anyObject());
continuation.suspend();
ServerFeatures serverFeatures = mocksControl.createMock(ServerFeatures.class);
expect(serverRuntimeContext.getServerFeatures()).andReturn(serverFeatures);
expect(serverFeatures.getAuthenticationMethods()).andReturn(Collections.<SASLMechanism> emptyList());
Capture<BoshResponse> captured = new Capture<BoshResponse>();
continuation.setAttribute(eq("response"), EasyMock.<BoshResponse> capture(captured));
continuation.resume();
mocksControl.replay();
Stanza boshRequest = createSessionRequest();
boshHandler.process(httpServletRequest, boshRequest);
mocksControl.verify();
assertEquals(httpServletRequest, br.getValue().getHttpServletRequest());
assertEquals(boshRequest, br.getValue().getBody());
Stanza response = new XMLUtil(new String(captured.getValue().getContent())).parse();
assertNotNull(response);
assertEquals("body", response.getName());
assertEquals(NamespaceURIs.XEP0124_BOSH, response.getNamespaceURI());
assertEquals("200", response.getAttributeValue("sid"));
assertEquals("vysper.org", response.getAttributeValue("from"));
assertEquals("60", response.getAttributeValue("wait"));
assertEquals("1", response.getAttributeValue("hold"));
assertEquals("1.9", response.getAttributeValue("ver"));
assertEquals(1, response.getInnerElements().size());
XMLElement streamFeatures = response.getInnerElements().get(0);
assertEquals("features", streamFeatures.getName());
assertEquals(NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS, streamFeatures.getNamespaceURI());
assertEquals(1, streamFeatures.getInnerElements().size());
XMLElement saslMechanisms = streamFeatures.getInnerElements().get(0);
assertEquals("mechanisms", saslMechanisms.getName());
assertEquals(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL, saslMechanisms.getNamespaceURI());
// 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());
StanzaProcessor stanzaProcessor = mocksControl.createMock(StanzaProcessor.class);
expect(serverRuntimeContext.getStanzaProcessor()).andReturn(stanzaProcessor);
Capture<Stanza> stanzaCaptured = new Capture<Stanza>();
stanzaProcessor.processStanza(eq(serverRuntimeContext), EasyMock.<SessionContext> anyObject(),
EasyMock.<Stanza> capture(stanzaCaptured), EasyMock.<SessionStateHolder> anyObject());