First working test for end-to-end request/response processing on

server side.
This commit is contained in:
Simone Bordet 2014-06-10 13:29:50 +02:00
parent b55dba82a5
commit f2e8edca9c
3 changed files with 18 additions and 4 deletions

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.http2.server;
import org.eclipse.jetty.http2.HTTP2Connection;
import org.eclipse.jetty.http2.HTTP2Session;
import org.eclipse.jetty.http2.IStream;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.api.server.ServerSessionListener;
@ -82,7 +83,7 @@ public class HTTP2ServerConnectionFactory extends AbstractConnectionFactory
{
LOG.debug("Received {} on {}", frame, stream);
HttpTransportOverHTTP2 transport = new HttpTransportOverHTTP2();
HttpTransportOverHTTP2 transport = new HttpTransportOverHTTP2((IStream)stream, frame);
HttpInputOverHTTP2 input = new HttpInputOverHTTP2();
HttpChannelOverHTTP2 channel = new HttpChannelOverHTTP2(connector, httpConfiguration, endPoint, transport, input);
stream.setAttribute(CHANNEL_ATTRIBUTE, channel);

View File

@ -34,8 +34,14 @@ import org.eclipse.jetty.util.Callback;
public class HttpTransportOverHTTP2 implements HttpTransport
{
private final AtomicBoolean commit = new AtomicBoolean();
private final IStream stream = null;
private final HeadersFrame request = null;
private final IStream stream;
private final HeadersFrame request;
public HttpTransportOverHTTP2(IStream stream, HeadersFrame request)
{
this.stream = stream;
this.request = request;
}
@Override
public void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, Callback callback)

View File

@ -22,6 +22,8 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@ -80,11 +82,13 @@ public class HTTP2ServerTest
@Test
public void testRequestResponseNoContent() throws Exception
{
final CountDownLatch latch = new CountDownLatch(1);
startServer(new HttpServlet()
{
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
latch.countDown();
}
});
@ -120,9 +124,12 @@ public class HTTP2ServerTest
parser.parse(buffer);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
HeadersFrame response = frameRef.get();
Assert.assertNotNull(response);
MetaData.Response responseMetaData = (MetaData.Response)response.getMetaData();
Assert.assertEquals(200, responseMetaData.getStatus());
}
}
}