From: kkolinko Date: Mon, 25 Jul 2011 20:46:11 +0000 (+0000) Subject: Converted the tests to JUnit 4. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e9b84d5baaa299f73e2b519758418426ba5cbdd4;p=tomcat7.0 Converted the tests to JUnit 4. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1150899 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/org/apache/tomcat/util/http/mapper/TestMapperWelcomeFiles.java b/test/org/apache/tomcat/util/http/mapper/TestMapperWelcomeFiles.java index 06c052bb2..095dc8fa9 100644 --- a/test/org/apache/tomcat/util/http/mapper/TestMapperWelcomeFiles.java +++ b/test/org/apache/tomcat/util/http/mapper/TestMapperWelcomeFiles.java @@ -26,13 +26,19 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Tomcat; -import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.catalina.startup.TomcatBaseTestJUnit4; import org.apache.tomcat.util.buf.ByteChunk; -public class TestMapperWelcomeFiles extends TomcatBaseTest { +public class TestMapperWelcomeFiles extends TomcatBaseTestJUnit4 { + @Test public void testWelcomeFileNotStrict() throws Exception { Tomcat tomcat = getTomcatInstance(); @@ -59,7 +65,8 @@ public class TestMapperWelcomeFiles extends TomcatBaseTest { assertEquals(HttpServletResponse.SC_OK, rc); assertTrue(bc.toString().contains("Servlet")); } - + + @Test public void testWelcomeFileStrict() throws Exception { Tomcat tomcat = getTomcatInstance(); diff --git a/test/org/apache/tomcat/util/net/TestClientCert.java b/test/org/apache/tomcat/util/net/TestClientCert.java index 7d22ff441..2a02ef35a 100644 --- a/test/org/apache/tomcat/util/net/TestClientCert.java +++ b/test/org/apache/tomcat/util/net/TestClientCert.java @@ -18,8 +18,12 @@ package org.apache.tomcat.util.net; import java.util.Arrays; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + import org.apache.catalina.startup.Tomcat; -import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.catalina.startup.TomcatBaseTestJUnit4; import org.apache.tomcat.util.buf.ByteChunk; /** @@ -27,8 +31,9 @@ import org.apache.tomcat.util.buf.ByteChunk; * generated using a test CA the files for which are in the Tomcat PMC private * repository since not all of them are AL2 licensed. */ -public class TestClientCert extends TomcatBaseTest { - +public class TestClientCert extends TomcatBaseTestJUnit4 { + + @Test public void testClientCertGet() throws Exception { if (!TesterSupport.isRenegotiationSupported(getTomcatInstance())) { return; @@ -44,25 +49,28 @@ public class TestClientCert extends TomcatBaseTest { assertEquals("OK", res.toString()); } + @Test public void testClientCertPostSmaller() throws Exception { Tomcat tomcat = getTomcatInstance(); int bodySize = tomcat.getConnector().getMaxSavePostSize() / 2; doTestClientCertPost(bodySize, false); } + @Test public void testClientCertPostSame() throws Exception { Tomcat tomcat = getTomcatInstance(); int bodySize = tomcat.getConnector().getMaxSavePostSize(); doTestClientCertPost(bodySize, false); } + @Test public void testClientCertPostLarger() throws Exception { Tomcat tomcat = getTomcatInstance(); int bodySize = tomcat.getConnector().getMaxSavePostSize() * 2; doTestClientCertPost(bodySize, true); } - public void doTestClientCertPost(int bodySize, boolean expectProtectedFail) + private void doTestClientCertPost(int bodySize, boolean expectProtectedFail) throws Exception { if (!TesterSupport.isRenegotiationSupported(getTomcatInstance())) { return; diff --git a/test/org/apache/tomcat/util/net/TestCustomSsl.java b/test/org/apache/tomcat/util/net/TestCustomSsl.java index 2896602a7..36fe3854b 100644 --- a/test/org/apache/tomcat/util/net/TestCustomSsl.java +++ b/test/org/apache/tomcat/util/net/TestCustomSsl.java @@ -21,9 +21,15 @@ import java.net.SocketException; import javax.net.ssl.SSLHandshakeException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Test; + import org.apache.catalina.connector.Connector; import org.apache.catalina.startup.Tomcat; -import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.catalina.startup.TomcatBaseTestJUnit4; import org.apache.coyote.ProtocolHandler; import org.apache.coyote.http11.AbstractHttp11JsseProtocol; import org.apache.tomcat.util.buf.ByteChunk; @@ -34,8 +40,9 @@ import org.apache.tomcat.util.net.jsse.TesterBug50640SslImpl; * generated using a test CA the files for which are in the Tomcat PMC private * repository since not all of them are AL2 licensed. */ -public class TestCustomSsl extends TomcatBaseTest { +public class TestCustomSsl extends TomcatBaseTestJUnit4 { + @Test public void testCustomSslImplementation() throws Exception { TesterSupport.configureClientSsl(); @@ -71,10 +78,12 @@ public class TestCustomSsl extends TomcatBaseTest { assertTrue(res.toString().indexOf("

Hello World!

") > 0); } + @Test public void testCustomTrustManager1() throws Exception { doTestCustomTrustManager(false); } - + + @Test public void testCustomTrustManager2() throws Exception { doTestCustomTrustManager(true); } diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java index e564927fb..a1751ebbf 100644 --- a/test/org/apache/tomcat/util/net/TestSsl.java +++ b/test/org/apache/tomcat/util/net/TestSsl.java @@ -30,8 +30,13 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Test; + import org.apache.catalina.startup.Tomcat; -import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.catalina.startup.TomcatBaseTestJUnit4; import org.apache.tomcat.util.buf.ByteChunk; /** @@ -39,8 +44,9 @@ import org.apache.tomcat.util.buf.ByteChunk; * generated using a test CA the files for which are in the Tomcat PMC private * repository since not all of them are AL2 licensed. */ -public class TestSsl extends TomcatBaseTest { +public class TestSsl extends TomcatBaseTestJUnit4 { + @Test public void testSimpleSsl() throws Exception { TesterSupport.configureClientSsl(); @@ -57,6 +63,7 @@ public class TestSsl extends TomcatBaseTest { assertTrue(res.toString().indexOf("

Hello World!

") > 0); } + @Test public void testKeyPass() throws Exception { TesterSupport.configureClientSsl(); @@ -76,7 +83,8 @@ public class TestSsl extends TomcatBaseTest { boolean handshakeDone = false; - + + @Test public void testRenegotiateFail() throws Exception { // If RFC5746 is supported, renegotiation will always work (and will @@ -143,7 +151,8 @@ public class TestSsl extends TomcatBaseTest { fail("Re-negotiation worked"); } - + + @Test public void testRenegotiateWorks() throws Exception { Tomcat tomcat = getTomcatInstance(); diff --git a/test/org/apache/tomcat/util/scan/TestJarScanner.java b/test/org/apache/tomcat/util/scan/TestJarScanner.java index 90e30600d..e51be51f9 100644 --- a/test/org/apache/tomcat/util/scan/TestJarScanner.java +++ b/test/org/apache/tomcat/util/scan/TestJarScanner.java @@ -19,10 +19,18 @@ package org.apache.tomcat.util.scan; import java.util.StringTokenizer; -import org.apache.catalina.startup.TomcatBaseTest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; -public class TestJarScanner extends TomcatBaseTest { +import org.junit.Test; +import org.apache.catalina.startup.TomcatBaseTestJUnit4; + +public class TestJarScanner extends TomcatBaseTestJUnit4 { + + @Test public void testJarsToSkipFormat() { String jarList = System.getProperty(Constants.SKIP_JARS_PROPERTY);