Hiding exception stack printed by a successful test.

This commit is contained in:
Simone Bordet 2015-04-24 12:26:36 +02:00
parent 2912f222ba
commit 3d5164b651
1 changed files with 33 additions and 22 deletions

View File

@ -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);
}
}
}