From c3582ceae2d5ebc3d645d2737cf72cc4f1855e1e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 5 Jan 2015 13:32:55 +0100 Subject: [PATCH] Fixed test to be more reliable. --- .../eclipse/jetty/proxy/ProxyServletTest.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java index cf349c9e924..2d3ae2b8312 100644 --- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java +++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java @@ -130,7 +130,9 @@ public class ProxyServletTest private void prepareProxy(Map initParams) throws Exception { - proxy = new Server(); + QueuedThreadPool proxyPool = new QueuedThreadPool(); + proxyPool.setName("proxy"); + proxy = new Server(proxyPool); HttpConfiguration configuration = new HttpConfiguration(); configuration.setSendDateHeader(false); @@ -154,6 +156,9 @@ public class ProxyServletTest private HttpClient prepareClient() throws Exception { HttpClient result = new HttpClient(); + QueuedThreadPool clientPool = new QueuedThreadPool(); + clientPool.setName("client"); + result.setExecutor(clientPool); result.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyConnector.getLocalPort())); result.start(); return result; @@ -161,7 +166,9 @@ public class ProxyServletTest private void prepareServer(HttpServlet servlet) throws Exception { - server = new Server(); + QueuedThreadPool serverPool = new QueuedThreadPool(); + serverPool.setName("server"); + server = new Server(serverPool); serverConnector = new ServerConnector(server); server.addConnector(serverConnector); @@ -312,8 +319,19 @@ public class ProxyServletTest @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - if (req.getHeader("Via") != null) - resp.addHeader(PROXIED_HEADER, "true"); + try + { + // Give some time to the proxy to + // upload the content to the server. + Thread.sleep(1000); + + if (req.getHeader("Via") != null) + resp.addHeader(PROXIED_HEADER, "true"); + } + catch (InterruptedException x) + { + throw new InterruptedIOException(); + } } });