From c7d2d2794581b9dcbd1ff2de7e654faebabc60fe Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 9 Feb 2011 22:45:08 +0000 Subject: [PATCH] Bumping up jetty-test-helper to v1.2 to use Stress helper. git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2766 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../jetty/client/HttpExchangeTest.java | 4 +- .../jetty/client/SslHttpExchangeTest.java | 38 +++++++++---------- jetty-io/pom.xml | 5 +++ .../jetty/io/ThreadLocalBuffersTest.java | 6 +-- jetty-server/pom.xml | 5 +++ .../eclipse/jetty/server/AsyncStressTest.java | 6 +-- .../jetty/server/HttpServerTestFixture.java | 4 +- .../org/eclipse/jetty/server/StressTest.java | 10 ++--- pom.xml | 2 +- 9 files changed, 41 insertions(+), 39 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 46e2523fa94..7a4857b86f8 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -39,6 +39,7 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.toolchain.test.Stress; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; @@ -47,7 +48,6 @@ import org.eclipse.jetty.util.log.Log; */ public class HttpExchangeTest extends TestCase { - private boolean _stress=Boolean.getBoolean("STRESS"); protected int _maxConnectionsPerAddress = 2; protected String _scheme = "http://"; protected Server _server; @@ -85,7 +85,7 @@ public class HttpExchangeTest extends TestCase public void testPerf() throws Exception { - if (_stress) + if (Stress.isEnabled()) { sender(1,false); sender(1,true); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java index 6b4faf7c3ff..1a02ca0c586 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java @@ -13,12 +13,13 @@ package org.eclipse.jetty.client; -import java.io.File; +import static org.hamcrest.Matchers.*; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ssl.SslSocketConnector; -import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.junit.Assume; /** * Functional testing for HttpExchange. @@ -50,8 +51,7 @@ public class SslHttpExchangeTest extends HttpExchangeTest //SslSelectChannelConnector connector = new SslSelectChannelConnector(); SslSocketConnector connector = new SslSocketConnector(); - String keystore = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator - + "keystore"; + String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); connector.setPort(0); connector.setKeystore(keystore); @@ -63,6 +63,12 @@ public class SslHttpExchangeTest extends HttpExchangeTest { connector }); _connector=connector; } + + private void IgnoreTestOnBuggyIBM() { + // Use Junit 4.x to flag test as ignored if encountering IBM JVM + // Will show up in various junit reports as an ignored test as well. + Assume.assumeThat(System.getProperty("java.vendor").toLowerCase(),not(containsString("ibm"))); + } /* ------------------------------------------------------------ */ /** @@ -72,10 +78,8 @@ public class SslHttpExchangeTest extends HttpExchangeTest public void testGetWithContentExchange() throws Exception { // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532 - if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0) - super.testGetWithContentExchange(); - else - Log.warn("Skipped SSL testGetWithContentExchange on IBM JVM"); + IgnoreTestOnBuggyIBM(); + super.testGetWithContentExchange(); } /* ------------------------------------------------------------ */ @@ -86,10 +90,8 @@ public class SslHttpExchangeTest extends HttpExchangeTest public void testPerf() throws Exception { // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532 - if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0) - super.testPerf(); - else - Log.warn("Skipped SSL testPerf on IBM JVM"); + IgnoreTestOnBuggyIBM(); + super.testPerf(); } /* ------------------------------------------------------------ */ @@ -100,10 +102,8 @@ public class SslHttpExchangeTest extends HttpExchangeTest public void testPostWithContentExchange() throws Exception { // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532 - if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0) - super.testPostWithContentExchange(); - else - Log.warn("Skipped SSL testPostWithContentExchange on IBM JVM"); + IgnoreTestOnBuggyIBM(); + super.testPostWithContentExchange(); } /* ------------------------------------------------------------ */ @@ -114,9 +114,7 @@ public class SslHttpExchangeTest extends HttpExchangeTest public void testReserveConnections() throws Exception { // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532 - if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0) - super.testReserveConnections(); - else - Log.warn("Skipped SSL testReserveConnections on IBM JVM"); + IgnoreTestOnBuggyIBM(); + super.testReserveConnections(); } } diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index d8bb69397f0..9d88ad07953 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -17,6 +17,11 @@ jetty-util ${project.version} + + org.eclipse.jetty.toolchain + jetty-test-helper + test + junit junit diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/ThreadLocalBuffersTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/ThreadLocalBuffersTest.java index fcf773b5839..34b05649703 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/ThreadLocalBuffersTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/ThreadLocalBuffersTest.java @@ -17,17 +17,17 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; +import org.eclipse.jetty.toolchain.test.Stress; import org.junit.Test; import static org.junit.Assert.assertTrue; public class ThreadLocalBuffersTest { - public boolean _stress = Boolean.getBoolean("STRESS"); private InnerBuffers httpBuffers; private List threadList = new ArrayList(); - private int numThreads = _stress?100:10; - private int runTestLength = _stress?5000:1000; + private int numThreads = Stress.isEnabled()?100:10; + private int runTestLength = Stress.isEnabled()?5000:1000; private boolean runTest = false; private AtomicLong buffersRetrieved; diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index ee218296b2f..e764c0c16ec 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -84,6 +84,11 @@ + + org.eclipse.jetty.toolchain + jetty-test-helper + test + junit junit diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java index 2132f466a1b..95e8bf459b9 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java @@ -28,6 +28,7 @@ import org.eclipse.jetty.continuation.Continuation; import org.eclipse.jetty.continuation.ContinuationListener; import org.eclipse.jetty.server.handler.HandlerWrapper; import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.toolchain.test.Stress; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -46,7 +47,6 @@ public class AsyncStressTest protected int _port; protected Random _random = new Random(); protected QueuedThreadPool _threads=new QueuedThreadPool(); - protected boolean _stress; private final static String[][] __paths = { {"/path","NORMAL"}, @@ -60,7 +60,6 @@ public class AsyncStressTest @Before public void init() throws Exception { - _stress= Boolean.getBoolean("STRESS"); _threads.setMaxThreads(50); _server.setThreadPool(_threads); _connector = new SelectChannelConnector(); @@ -82,9 +81,8 @@ public class AsyncStressTest @Test public void testAsync() throws Throwable { - if (_stress) + if (Stress.isEnabled()) { - System.err.println("STRESS!"); doConnections(1600,240); } else diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java index 14caa2f0566..951f06142b9 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java @@ -14,15 +14,15 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.HandlerWrapper; +import org.eclipse.jetty.toolchain.test.Stress; import org.eclipse.jetty.util.IO; import org.junit.AfterClass; public class HttpServerTestFixture { // Useful constants - protected static final boolean stress = Boolean.getBoolean("STRESS"); protected static final long PAUSE=10L; - protected static final int LOOPS=stress?250:25; + protected static final int LOOPS=Stress.isEnabled()?250:25; protected static final String HOST="localhost"; protected static Server _server; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java index 9b1ea960a40..60005daec31 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java @@ -25,6 +25,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.handler.HandlerWrapper; import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.toolchain.test.Stress; import org.eclipse.jetty.util.BlockingArrayQueue; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; @@ -39,7 +40,6 @@ import static org.junit.Assert.assertTrue; public class StressTest { - private static boolean _stress; private static QueuedThreadPool _threads; private static Server _server; private static SelectChannelConnector _connector; @@ -78,8 +78,6 @@ public class StressTest @BeforeClass public static void init() throws Exception { - _stress= Boolean.getBoolean("STRESS"); - _threads = new QueuedThreadPool(new BlockingArrayQueue(4,4)); _threads.setMaxThreads(200); @@ -117,9 +115,8 @@ public class StressTest public void testNonPersistent() throws Throwable { doThreads(10,100,false); - if (_stress) + if (Stress.isEnabled()) { - System.err.println("STRESS!"); Thread.sleep(1000); doThreads(200,10,false); Thread.sleep(1000); @@ -131,9 +128,8 @@ public class StressTest public void testPersistent() throws Throwable { doThreads(20,100,true); - if (_stress) + if (Stress.isEnabled()) { - System.err.println("STRESS!"); Thread.sleep(1000); doThreads(200,10,true); Thread.sleep(1000); diff --git a/pom.xml b/pom.xml index 02845f60eaa..aa5e444390f 100644 --- a/pom.xml +++ b/pom.xml @@ -320,7 +320,7 @@ org.eclipse.jetty.toolchain jetty-test-helper - 1.0 + 1.2 org.slf4j