BoshDecoder { public void decode() throws IOException, SAXException { IoBuffer ioBuf = IoBuffer.allocate(1024); ioBuf.setAutoExpand(true); byte[] buf = new byte[1024]; InputStream in = request.getInputStream(); for (;;) { int i = in.read(buf); if (i == -1) { break; } ioBuf.put(buf, 0, i); } ioBuf.flip(); reader.parse(ioBuf, CharsetUtil.getDecoder()); } BoshDecoder(BoshHandler boshHandler, HttpServletRequest req); void decode();  }
@Test public void testDecode() throws IOException, SAXException { ServletInputStream input = new ServletInputStreamMock("<body rid='3549788615' xmlns='http: expect(request.getInputStream()).andReturn(input); Capture<Stanza> captured = new Capture<Stanza>(); boshHandler.process(EasyMock.<HttpServletRequest>notNull(), EasyMock.<Stanza>capture(captured)); mocksControl.replay(); boshDecoder.decode(); mocksControl.verify(); Stanza request = captured.getValue(); assertNotNull(request); assertEquals("body", request.getName()); assertEquals(NamespaceURIs.XEP0124_BOSH, request.getNamespaceURI()); assertEquals("3549788615", request.getAttributeValue("rid")); assertEquals("vysper.org", request.getAttributeValue("to")); assertEquals("60", request.getAttributeValue("wait")); assertEquals("1", request.getAttributeValue("hold")); assertEquals("1.6", request.getAttributeValue("ver")); assertEquals("1.0", request.getAttributeValue(NamespaceURIs.URN_XMPP_XBOSH, "version")); assertEquals("en", request.getAttributeValue(NamespaceURIs.XML, "lang")); }