From 3d5164b65152542dc7da3748676ff5a3ebe76a1a Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 24 Apr 2015 12:26:36 +0200 Subject: [PATCH] Hiding exception stack printed by a successful test. --- .../jetty/http2/server/HTTP2ServerTest.java | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java index a3573781b91..29f8d22b3ed 100644 --- a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java +++ b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java @@ -48,10 +48,12 @@ import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.ManagedSelector; import org.eclipse.jetty.io.SelectChannelEndPoint; +import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.log.StdErrLog; import org.junit.Assert; import org.junit.Test; @@ -351,32 +353,41 @@ public class HTTP2ServerTest extends AbstractServerTest @Test public void testNonISOHeader() throws Exception { - startServer(new HttpServlet() + StdErrLog logger = StdErrLog.getLogger(HttpChannel.class); + logger.setHideStacks(true); + try { - @Override - protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + startServer(new HttpServlet() { - // Invalid header name, the connection must be closed. - response.setHeader("Euro_(\u20AC)", "42"); + @Override + protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + // Invalid header name, the connection must be closed. + response.setHeader("Euro_(\u20AC)", "42"); + } + }); + + ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); + generator.control(lease, new PrefaceFrame()); + MetaData.Request metaData = newRequest("GET", new HttpFields()); + generator.control(lease, new HeadersFrame(1, metaData, null, true)); + + try (Socket client = new Socket("localhost", connector.getLocalPort())) + { + OutputStream output = client.getOutputStream(); + for (ByteBuffer buffer : lease.getByteBuffers()) + output.write(BufferUtil.toArray(buffer)); + output.flush(); + + Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter(), 4096, 8192); + boolean closed = parseResponse(client, parser); + + Assert.assertTrue(closed); } - }); - - ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool); - generator.control(lease, new PrefaceFrame()); - MetaData.Request metaData = newRequest("GET", new HttpFields()); - generator.control(lease, new HeadersFrame(1, metaData, null, true)); - - try (Socket client = new Socket("localhost", connector.getLocalPort())) + } + finally { - OutputStream output = client.getOutputStream(); - for (ByteBuffer buffer : lease.getByteBuffers()) - output.write(BufferUtil.toArray(buffer)); - output.flush(); - - Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter(), 4096, 8192); - boolean closed = parseResponse(client, parser); - - Assert.assertTrue(closed); + logger.setHideStacks(false); } } }