More tests for the HTTP over SPDY layer.
This commit is contained in:
parent
5db861c0c8
commit
dc1e8350b2
|
@ -287,7 +287,7 @@ public class HTTPOverSPDYTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPOSTWithParametersInTwoFrames() throws Exception
|
||||
public void testPOSTWithParametersInTwoFramesTwoReads() throws Exception
|
||||
{
|
||||
final String path = "/foo";
|
||||
final String data1 = "a=1&";
|
||||
|
@ -333,4 +333,49 @@ public class HTTPOverSPDYTest
|
|||
Assert.assertTrue(handlerLatch.await(5, TimeUnit.SECONDS));
|
||||
Assert.assertTrue(replyLatch.await(5, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPOSTWithParametersInTwoFramesOneRead() throws Exception
|
||||
{
|
||||
final String path = "/foo";
|
||||
final String data1 = "a=1&";
|
||||
final String data2 = "b=2";
|
||||
final CountDownLatch handlerLatch = new CountDownLatch(1);
|
||||
start(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse)
|
||||
throws IOException, ServletException
|
||||
{
|
||||
request.setHandled(true);
|
||||
Assert.assertEquals("POST", httpRequest.getMethod());
|
||||
Assert.assertEquals("1", httpRequest.getParameter("a"));
|
||||
Assert.assertEquals("2", httpRequest.getParameter("b"));
|
||||
handlerLatch.countDown();
|
||||
}
|
||||
}, null);
|
||||
|
||||
Headers headers = new Headers();
|
||||
headers.put("method", "POST");
|
||||
headers.put("url", "http://localhost:" + connector.getLocalPort() + path);
|
||||
headers.put("version", "HTTP/1.1");
|
||||
headers.put("content-type", "application/x-www-form-urlencoded");
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
Stream stream = session.syn(SPDY.V2, new SynInfo(headers, false), new Stream.FrameListener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public void onReply(Stream stream, ReplyInfo replyInfo)
|
||||
{
|
||||
Assert.assertTrue(replyInfo.isClose());
|
||||
Headers replyHeaders = replyInfo.getHeaders();
|
||||
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
|
||||
replyLatch.countDown();
|
||||
}
|
||||
});
|
||||
stream.data(new StringDataInfo(data1, false));
|
||||
stream.data(new StringDataInfo(data2, true));
|
||||
|
||||
Assert.assertTrue(handlerLatch.await(5, TimeUnit.SECONDS));
|
||||
Assert.assertTrue(replyLatch.await(5, TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue