Fixed tests.
This commit is contained in:
parent
14dba64164
commit
4211653095
|
@ -59,6 +59,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
@ -79,7 +80,14 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
|
||||
MetaData.Request metaData = newRequest("GET", new HttpFields());
|
||||
HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true);
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>(), new Stream.Listener.Adapter());
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Stream stream)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
}
|
||||
}, new Stream.Listener.Adapter());
|
||||
|
||||
Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
@ -87,7 +95,15 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
@Test
|
||||
public void testServerEnforcingIdleTimeoutWithUnrespondedStream() throws Exception
|
||||
{
|
||||
startServer(new ServerSessionListener.Adapter());
|
||||
startServer(new ServerSessionListener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
connector.setIdleTimeout(idleTimeout);
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
@ -103,7 +119,14 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
// The request is not replied, and the server should idle timeout.
|
||||
MetaData.Request metaData = newRequest("GET", new HttpFields());
|
||||
HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true);
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>(), new Stream.Listener.Adapter());
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Stream stream)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
}
|
||||
}, new Stream.Listener.Adapter());
|
||||
|
||||
Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
@ -118,6 +141,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
{
|
||||
try
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
Thread.sleep(2 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
|
@ -146,7 +170,14 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
MetaData.Request metaData = newRequest("GET", new HttpFields());
|
||||
HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true);
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>(), new Stream.Listener.Adapter()
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Stream stream)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
}
|
||||
}, new Stream.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public void onHeaders(Stream stream, HeadersFrame frame)
|
||||
|
@ -170,6 +201,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
@ -187,7 +219,14 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
Session session = newClient(new Session.Listener.Adapter());
|
||||
MetaData.Request metaData = newRequest("GET", new HttpFields());
|
||||
HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true);
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>(), new Stream.Listener.Adapter());
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Stream stream)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
}
|
||||
}, new Stream.Listener.Adapter());
|
||||
|
||||
Assert.assertTrue(closeLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
@ -198,6 +237,13 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
final CountDownLatch closeLatch = new CountDownLatch(1);
|
||||
startServer(new ServerSessionListener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(Session session, GoAwayFrame frame)
|
||||
{
|
||||
|
@ -209,7 +255,14 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
Session session = newClient(new Session.Listener.Adapter());
|
||||
MetaData.Request metaData = newRequest("GET", new HttpFields());
|
||||
HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true);
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>(), new Stream.Listener.Adapter());
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Stream stream)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
}
|
||||
}, new Stream.Listener.Adapter());
|
||||
|
||||
Assert.assertTrue(closeLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
@ -223,6 +276,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
@ -242,7 +296,14 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
MetaData.Request metaData = newRequest("GET", new HttpFields());
|
||||
HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true);
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>(), new Stream.Listener.Adapter()
|
||||
session.newStream(requestFrame, new Promise.Adapter<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Stream stream)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
}
|
||||
}, new Stream.Listener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public void onHeaders(Stream stream, HeadersFrame frame)
|
||||
|
@ -361,7 +422,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIdleTimeoutIsInterruptedWhenReceiving() throws Exception
|
||||
public void testStreamIdleTimeoutIsNotEnforcedWhenReceiving() throws Exception
|
||||
{
|
||||
final CountDownLatch timeoutLatch = new CountDownLatch(1);
|
||||
startServer(new ServerSessionListener.Adapter()
|
||||
|
|
|
@ -1,10 +1,2 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.LEVEL=INFO
|
||||
org.eclipse.jetty.STACKS=true
|
||||
org.eclipse.jetty.SOURCE=false
|
||||
org.eclipse.jetty.http2.hpack.LEVEL=debug
|
||||
#org.eclipse.jetty.spdy.LEVEL=DEBUG
|
||||
#org.eclipse.jetty.server.LEVEL=DEBUG
|
||||
#org.eclipse.jetty.io.LEVEL=DEBUG
|
||||
#org.eclipse.jetty.io.ssl.LEVEL=DEBUG
|
||||
#org.eclipse.jetty.spdy.server.LEVEL=DEBUG
|
||||
org.eclipse.jetty.http2.LEVEL=INFO
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.http2.server;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -46,9 +45,6 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
|
|||
import org.eclipse.jetty.http2.frames.PingFrame;
|
||||
import org.eclipse.jetty.http2.frames.SettingsFrame;
|
||||
import org.eclipse.jetty.http2.generator.Generator;
|
||||
import org.eclipse.jetty.http2.hpack.HpackContext;
|
||||
import org.eclipse.jetty.http2.hpack.HpackDecoder;
|
||||
import org.eclipse.jetty.http2.hpack.HpackEncoder;
|
||||
import org.eclipse.jetty.http2.parser.ErrorCode;
|
||||
import org.eclipse.jetty.http2.parser.Parser;
|
||||
import org.eclipse.jetty.http2.parser.PrefaceParser;
|
||||
|
@ -86,9 +82,6 @@ public class HTTP2ServerTest
|
|||
generator = new Generator(byteBufferPool);
|
||||
|
||||
server.start();
|
||||
HpackContext.LOG.setDebugEnabled(true);
|
||||
HpackEncoder.LOG.setDebugEnabled(true);
|
||||
HpackDecoder.LOG.setDebugEnabled(true);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -355,7 +348,7 @@ public class HTTP2ServerTest
|
|||
}
|
||||
}
|
||||
|
||||
private void parseResponse(Socket client, Parser parser) throws IOException
|
||||
private boolean parseResponse(Socket client, Parser parser) throws IOException
|
||||
{
|
||||
byte[] buffer = new byte[2048];
|
||||
InputStream input = client.getInputStream();
|
||||
|
@ -365,13 +358,13 @@ public class HTTP2ServerTest
|
|||
try
|
||||
{
|
||||
int read = input.read(buffer);
|
||||
if (read <= 0)
|
||||
throw new EOFException();
|
||||
if (read < 0)
|
||||
return true;
|
||||
parser.parse(ByteBuffer.wrap(buffer, 0, read));
|
||||
}
|
||||
catch (SocketTimeoutException x)
|
||||
{
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.http2.LEVEL=INFO
|
||||
org.eclipse.jetty.http2.hpack.LEVEL=DEBUG
|
||||
|
||||
|
|
Loading…
Reference in New Issue