diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java index 4e23f4797bd7..11d990491e92 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java @@ -22,14 +22,18 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Stream; import org.awaitility.Awaitility; +import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; @@ -41,6 +45,7 @@ import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.QuietException; import org.eclipse.jetty.logging.StacklessLogging; +import org.eclipse.jetty.server.Components; import org.eclipse.jetty.server.ConnectionMetaData; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Context; @@ -54,6 +59,8 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.Session; +import org.eclipse.jetty.server.TunnelSupport; import org.eclipse.jetty.server.internal.HttpChannelState; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -873,7 +880,7 @@ public void testSetTempDirectoryBad(boolean persistent, File badTempDir) private static class ScopeListener implements ContextHandler.ContextScopeListener { - private static final Request NULL = new Request.Wrapper(null); + private static final Request NULL = new Request.Wrapper(new TestableRequest()); private final ThreadLocal _context = new ThreadLocal<>(); private final ThreadLocal _request = new ThreadLocal<>(); @@ -902,6 +909,160 @@ void assertInContext(Context context, Request request) } } + private static class TestableRequest implements Request + { + @Override + public Object removeAttribute(String name) + { + return null; + } + + @Override + public Object setAttribute(String name, Object attribute) + { + return null; + } + + @Override + public Object getAttribute(String name) + { + return null; + } + + @Override + public Set getAttributeNameSet() + { + return null; + } + + @Override + public void clearAttributes() + { + } + + @Override + public String getId() + { + return null; + } + + @Override + public Components getComponents() + { + return null; + } + + @Override + public ConnectionMetaData getConnectionMetaData() + { + return null; + } + + @Override + public String getMethod() + { + return null; + } + + @Override + public HttpURI getHttpURI() + { + return null; + } + + @Override + public Context getContext() + { + return null; + } + + @Override + public HttpFields getHeaders() + { + return null; + } + + @Override + public HttpFields getTrailers() + { + return null; + } + + public List getCookies() + { + return null; + } + + @Override + public long getBeginNanoTime() + { + return 0; + } + + @Override + public long getHeadersNanoTime() + { + return 0; + } + + @Override + public boolean isSecure() + { + return false; + } + + @Override + public long getLength() + { + return 0; + } + + @Override + public Content.Chunk read() + { + return null; + } + + @Override + public boolean consumeAvailable() + { + return false; + } + + @Override + public void demand(Runnable demandCallback) + { + } + + @Override + public void fail(Throwable failure) + { + } + + @Override + public boolean addErrorListener(Predicate onError) + { + return false; + } + + @Override + public TunnelSupport getTunnelSupport() + { + return null; + } + + @Override + public void addHttpStreamWrapper(Function wrapper) + { + } + + @Override + public Session getSession(boolean create) + { + return null; + } + } + @Test public void testGraceful() throws Exception {