From 7796a4902031d51782a7f5214fcf1a7c86b48b3c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 18 Oct 2012 16:36:21 +1100 Subject: [PATCH] 392237 cleaned up client test exceptions --- .../jetty/client/HttpClientContinueTest.java | 49 ++++++++++++------- .../client/HttpConnectionLifecycleTest.java | 3 ++ .../jetty/client/HttpRequestAbortTest.java | 9 ++++ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientContinueTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientContinueTest.java index 8aa84edfe76..fd4e2a3a519 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientContinueTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientContinueTest.java @@ -35,10 +35,13 @@ import org.eclipse.jetty.client.util.BytesContentProvider; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; +import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.annotation.Slow; import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Assert; import org.junit.Test; @@ -417,24 +420,34 @@ public class HttpClientContinueTest extends AbstractHttpClientServerTest } }); - byte[] content = new byte[1024]; - final CountDownLatch latch = new CountDownLatch(1); - client.newRequest("localhost", connector.getLocalPort()) - .scheme(scheme) - .header(HttpHeader.EXPECT.asString(), HttpHeaderValue.CONTINUE.asString()) - .content(new BytesContentProvider(content)) - .send(new BufferingResponseListener() - { - @Override - public void onComplete(Result result) - { - Assert.assertTrue(result.isFailed()); - Assert.assertNotNull(result.getRequestFailure()); - Assert.assertNotNull(result.getResponseFailure()); - latch.countDown(); - } - }); + try + { + Log.getLogger(HttpChannel.class).info("Expecting Close warning..."); + ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true); - Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); + byte[] content = new byte[1024]; + final CountDownLatch latch = new CountDownLatch(1); + client.newRequest("localhost", connector.getLocalPort()) + .scheme(scheme) + .header(HttpHeader.EXPECT.asString(), HttpHeaderValue.CONTINUE.asString()) + .content(new BytesContentProvider(content)) + .send(new BufferingResponseListener() + { + @Override + public void onComplete(Result result) + { + Assert.assertTrue(result.isFailed()); + Assert.assertNotNull(result.getRequestFailure()); + Assert.assertNotNull(result.getResponseFailure()); + latch.countDown(); + } + }); + + Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); + } + finally + { + ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false); + } } } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java index e8bc8bdcd76..ee80a191081 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java @@ -36,6 +36,7 @@ import org.eclipse.jetty.client.util.ByteBufferContentProvider; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.annotation.Slow; +import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Assert; @@ -403,6 +404,8 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest final BlockingQueue activeConnections = destination.getActiveConnections(); Assert.assertEquals(0, activeConnections.size()); + Log.getLogger(HttpConnection.class).info("Expecting java.lang.IllegalStateException: HttpParser{s=CLOSED,..."); + final CountDownLatch latch = new CountDownLatch(1); client.newRequest(host, port) .scheme(scheme) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java index e4178b58966..1f841bb3b96 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java @@ -32,8 +32,11 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.util.ByteBufferContentProvider; +import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Assert; import org.junit.Test; @@ -169,6 +172,8 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest // reads -1 with a pending exchange and fails the response with an EOFException try { + Log.getLogger(HttpChannel.class).info("Excpecting java.nio.channels.ClosedChannelException..."); + ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true); ContentResponse response = client.newRequest("localhost", connector.getLocalPort()) .scheme(scheme) .listener(new Request.Listener.Empty() @@ -210,5 +215,9 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest throw x; } } + finally + { + ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false); + } } }