Merge pull request #2584 from lachlan-roberts/jetty-9.4.x-stackTraceRemoval

removal of exception stack traces in tests
This commit is contained in:
Greg Wilkins 2018-05-30 15:51:17 +02:00 committed by GitHub
commit 80ae15e9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 39 deletions

View File

@ -150,7 +150,10 @@ public abstract class SslBytesTest
}
catch (IOException x)
{
x.printStackTrace();
logger.info(x.getClass() + ": " + x.getMessage());
if(logger.isDebugEnabled())
logger.debug(x);
}
}

View File

@ -351,8 +351,7 @@ public class MimeTypes
if (type==null)
{
if (type==null)
type=__dftMimeMap.get("*");
type=__dftMimeMap.get("*");
}
return type;

View File

@ -835,7 +835,10 @@ public class SocketChannelEndPointTest
}
catch (InterruptedException | EofException e)
{
LOG.info(e);
if(LOG.isDebugEnabled())
LOG.debug(e);
else
LOG.info(e.getClass().getName());
}
catch (Exception e)
{

View File

@ -18,14 +18,9 @@
package org.eclipse.jetty.websocket.jsr356.misbehaving;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import javax.websocket.ContainerProvider;
import javax.websocket.WebSocketContainer;
@ -37,15 +32,15 @@ import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.jsr356.EchoHandler;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
public class MisbehavingClassTest
{
@Rule
public ExpectedException expectedException = ExpectedException.none();
private static Server server;
private static EchoHandler handler;
private static URI serverUri;
@ -100,20 +95,21 @@ public class MisbehavingClassTest
try (StacklessLogging logging = new StacklessLogging(EndpointRuntimeOnOpen.class, WebSocketSession.class))
{
// expecting IOException during onOpen
expectedException.expect(IOException.class);
expectedException.expectCause(instanceOf(RuntimeException.class));
container.connectToServer(socket, serverUri);
expectedException.reportMissingExceptionWithMessage("Should have failed .connectToServer()");
assertThat("Close should have occurred",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true));
try
{
container.connectToServer(socket, serverUri);
fail("Should have failed .connectToServer()");
}
catch (IOException e)
{
assertThat(e.getCause(), instanceOf(RuntimeException.class));
}
Throwable cause = socket.errors.pop();
assertThat("Error",cause,instanceOf(RuntimeException.class));
assertThat("Close should have occurred", socket.closeLatch.await(10,TimeUnit.SECONDS), is(true));
assertThat("Error", socket.errors.pop(), instanceOf(RuntimeException.class));
}
}
@SuppressWarnings("Duplicates")
@Test
public void testAnnotatedRuntimeOnOpen() throws Exception
{
@ -123,16 +119,18 @@ public class MisbehavingClassTest
try (StacklessLogging logging = new StacklessLogging(AnnotatedRuntimeOnOpen.class, WebSocketSession.class))
{
// expecting IOException during onOpen
expectedException.expect(IOException.class);
expectedException.expectCause(instanceOf(RuntimeException.class));
container.connectToServer(socket, serverUri);
expectedException.reportMissingExceptionWithMessage("Should have failed .connectToServer()");
assertThat("Close should have occurred",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true));
try
{
container.connectToServer(socket, serverUri);
fail("Should have failed .connectToServer()");
}
catch (IOException e)
{
assertThat(e.getCause(), instanceOf(RuntimeException.class));
}
Throwable cause = socket.errors.pop();
assertThat("Error",cause,instanceOf(ArrayIndexOutOfBoundsException.class));
assertThat("Close should have occurred", socket.closeLatch.await(10,TimeUnit.SECONDS), is(true));
assertThat("Error",socket.errors.pop(), instanceOf(RuntimeException.class));
}
}
}

View File

@ -49,7 +49,11 @@ public abstract class TrackingSocket
protected void addError(Throwable t)
{
LOG.warn(t);
LOG.warn(t.getClass() + ": " + t.getMessage());
if(LOG.isDebugEnabled())
LOG.debug(t);
errorQueue.offer(t);
}

View File

@ -92,8 +92,8 @@ public class MisbehavingClassTest
Future<BlockheadConnection> connFut = request.sendAsync();
try (BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT);
StacklessLogging ignore = new StacklessLogging(ListenerRuntimeOnConnectSocket.class, WebSocketSession.class))
try (StacklessLogging ignore = new StacklessLogging(ListenerRuntimeOnConnectSocket.class, WebSocketSession.class);
BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT))
{
LinkedBlockingQueue<WebSocketFrame> frames = clientConn.getFrameQueue();
WebSocketFrame frame = frames.poll(Timeouts.POLL_EVENT, Timeouts.POLL_EVENT_UNIT);
@ -126,8 +126,8 @@ public class MisbehavingClassTest
Future<BlockheadConnection> connFut = request.sendAsync();
try (BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT);
StacklessLogging scope = new StacklessLogging(AnnotatedRuntimeOnConnectSocket.class, WebSocketSession.class))
try (StacklessLogging scope = new StacklessLogging(AnnotatedRuntimeOnConnectSocket.class, WebSocketSession.class);
BlockheadConnection clientConn = connFut.get(Timeouts.CONNECT, Timeouts.CONNECT_UNIT))
{
LinkedBlockingQueue<WebSocketFrame> frames = clientConn.getFrameQueue();
WebSocketFrame frame = frames.poll(Timeouts.POLL_EVENT, Timeouts.POLL_EVENT_UNIT);

View File

@ -55,6 +55,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Assume;
@ -430,7 +431,7 @@ public class ServerTimeoutsTest extends AbstractTest
});
setServerIdleTimeout(idleTimeout);
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class, QueuedThreadPool.class))
{
DeferredContentProvider contentProvider = new DeferredContentProvider();
CountDownLatch resultLatch = new CountDownLatch(1);