tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1150855 - in /tomcat/trunk/test/org/apache/catalina: core/ filters/
Date Mon, 25 Jul 2011 19:25:25 GMT
Author: kkolinko
Date: Mon Jul 25 19:25:22 2011
New Revision: 1150855

URL: http://svn.apache.org/viewvc?rev=1150855&view=rev
Log:
Converted the tests to JUnit 4.

Modified:
    tomcat/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java
    tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
    tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java
    tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java
    tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
    tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
    tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
    tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java
    tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java
    tomcat/trunk/test/org/apache/catalina/filters/TestExpiresFilter.java
    tomcat/trunk/test/org/apache/catalina/filters/TestRemoteIpFilter.java

Modified: tomcat/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestAsyncContextImpl.java Mon Jul 25 19:25:22
2011
@@ -34,16 +34,23 @@ 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.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.startup.Tomcat;
-import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.startup.TomcatBaseTestJUnit4;
 import org.apache.catalina.valves.TesterAccessLogValve;
 import org.apache.catalina.valves.TesterAccessLogValve.Entry;
 import org.apache.tomcat.util.buf.ByteChunk;
 
-public class TestAsyncContextImpl extends TomcatBaseTest {
+public class TestAsyncContextImpl extends TomcatBaseTestJUnit4 {
 
     // Time for a request to process (need to allow for threads to start etc.)
     private static final long REQUEST_TIME = 1000;
@@ -54,6 +61,7 @@ public class TestAsyncContextImpl extend
     // Default timeout for these tests
     private static final long TIMEOUT = 3000;
 
+    @Test
     public void testBug49528() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -90,7 +98,8 @@ public class TestAsyncContextImpl extend
         validateAccessLog(alv, 1, 200, Bug49528Servlet.THREAD_SLEEP_TIME,
                 Bug49528Servlet.THREAD_SLEEP_TIME + REQUEST_TIME);
     }
-    
+
+    @Test
     public void testBug49567() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -127,7 +136,8 @@ public class TestAsyncContextImpl extend
         validateAccessLog(alv, 1, 200, Bug49567Servlet.THREAD_SLEEP_TIME,
                 Bug49567Servlet.THREAD_SLEEP_TIME + REQUEST_TIME);
     }
-    
+
+    @Test
     public void testAsyncStartNoComplete() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -168,7 +178,8 @@ public class TestAsyncContextImpl extend
                 AsyncStartNoCompleteServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
                         REQUEST_TIME);
     }
-    
+
+    @Test
     public void testAsyncStartWithComplete() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -365,21 +376,25 @@ public class TestAsyncContextImpl extend
         }
     }
 
+    @Test
     public void testTimeoutListenerCompleteNoDispatch() throws Exception {
         // Should work
         doTestTimeout(true, null);
     }
-    
+
+    @Test
     public void testTimeoutListenerNoCompleteNoDispatch() throws Exception {
         // Should trigger an error - must do one or other
         doTestTimeout(false, null);
     }
 
+    @Test
     public void testTimeoutListenerCompleteDispatch() throws Exception {
         // Should trigger an error - can't do both
         doTestTimeout(true, "/nonasync");
     }
 
+    @Test
     public void testTimeoutListenerNoCompleteDispatch() throws Exception {
         // Should work
         doTestTimeout(false, "/nonasync");
@@ -491,26 +506,32 @@ public class TestAsyncContextImpl extend
         }
     }
 
+    @Test
     public void testDispatchSingle() throws Exception {
         doTestDispatch(1, false);
     }
-    
+
+    @Test
     public void testDispatchDouble() throws Exception {
         doTestDispatch(2, false);
     }
-    
+
+    @Test
     public void testDispatchMultiple() throws Exception {
         doTestDispatch(5, false);
     }
-    
+
+    @Test
     public void testDispatchWithThreadSingle() throws Exception {
         doTestDispatch(1, true);
     }
-    
+
+    @Test
     public void testDispatchWithThreadDouble() throws Exception {
         doTestDispatch(2, true);
     }
-    
+
+    @Test
     public void testDispatchWithThreadMultiple() throws Exception {
         doTestDispatch(5, true);
     }
@@ -620,7 +641,8 @@ public class TestAsyncContextImpl extend
             resp.flushBuffer();
         }
     }
-    
+
+    @Test
     public void testListeners() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -779,52 +801,64 @@ public class TestAsyncContextImpl extend
         }
     }
 
+    @Test
     public void testDispatchErrorSingle() throws Exception {
         doTestDispatchError(1, false, false);
     }
-    
+
+    @Test
     public void testDispatchErrorDouble() throws Exception {
         doTestDispatchError(2, false, false);
     }
-    
+
+    @Test
     public void testDispatchErrorMultiple() throws Exception {
         doTestDispatchError(5, false, false);
     }
-    
+
+    @Test
     public void testDispatchErrorWithThreadSingle() throws Exception {
         doTestDispatchError(1, true, false);
     }
-    
+
+    @Test
     public void testDispatchErrorWithThreadDouble() throws Exception {
         doTestDispatchError(2, true, false);
     }
-    
+
+    @Test
     public void testDispatchErrorWithThreadMultiple() throws Exception {
         doTestDispatchError(5, true, false);
     }
-    
+
+    @Test
     public void testDispatchErrorSingleThenComplete() throws Exception {
         doTestDispatchError(1, false, true);
     }
-    
+
+    @Test
     public void testDispatchErrorDoubleThenComplete() throws Exception {
         doTestDispatchError(2, false, true);
     }
-    
+
+    @Test
     public void testDispatchErrorMultipleThenComplete() throws Exception {
         doTestDispatchError(5, false, true);
     }
-    
+
+    @Test
     public void testDispatchErrorWithThreadSingleThenComplete()
             throws Exception {
         doTestDispatchError(1, true, true);
     }
-    
+
+    @Test
     public void testDispatchErrorWithThreadDoubleThenComplete()
             throws Exception {
         doTestDispatchError(2, true, true);
     }
-    
+
+    @Test
     public void testDispatchErrorWithThreadMultipleThenComplete()
             throws Exception {
         doTestDispatchError(5, true, true);
@@ -904,7 +938,8 @@ public class TestAsyncContextImpl extend
             throw new ServletException("Opps.");
         }
     }
-    
+
+    @Test
     public void testBug50352() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -965,7 +1000,8 @@ public class TestAsyncContextImpl extend
             });
         }
     }
-    
+
+    @Test
     public void testBug50753() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -1031,6 +1067,7 @@ public class TestAsyncContextImpl extend
         }
     }
 
+    @Test
     public void testErrorHandling() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -1086,7 +1123,8 @@ public class TestAsyncContextImpl extend
                     entry.getTime() < maxTime + ERROR_MARGIN);
         }
     }
-    
+
+    @Test
     public void testCommitOnComplete() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -1146,8 +1184,8 @@ public class TestAsyncContextImpl extend
             actxt.complete();
         }
     }
-    
 
+    @Test
     public void testBug51197() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();

Modified: tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java Mon Jul 25 19:25:22
2011
@@ -22,12 +22,16 @@ import javax.naming.NamingException;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.deploy.ContextEnvironment;
 import org.apache.catalina.startup.Tomcat;
-import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.startup.TomcatBaseTestJUnit4;
 
-public class TestNamingContextListener extends TomcatBaseTest {
+public class TestNamingContextListener extends TomcatBaseTestJUnit4 {
 
     private static final String JNDI_NAME = "TestName";
     private static final String JNDI_VALUE= "Test Value";
@@ -35,6 +39,7 @@ public class TestNamingContextListener e
     /** 
      * Test JNDI is available to ServletContextListeners.
      */
+    @Test
     public void testBug49132() throws Exception {
         Tomcat tomcat = getTomcatInstance();
         

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java Mon Jul 25 19:25:22
2011
@@ -41,6 +41,14 @@ 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.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.authenticator.BasicAuthenticator;
@@ -50,10 +58,10 @@ import org.apache.catalina.deploy.LoginC
 import org.apache.catalina.startup.SimpleHttpClient;
 import org.apache.catalina.startup.TestTomcat.MapRealm;
 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 TestStandardContext extends TomcatBaseTest {
+public class TestStandardContext extends TomcatBaseTestJUnit4 {
 
     private static final String REQUEST =
         "GET / HTTP/1.1\r\n" +
@@ -61,6 +69,7 @@ public class TestStandardContext extends
         "Connection: close\r\n" +
         "\r\n";
 
+    @Test
     public void testBug46243() throws Exception {
         
         // Set up a container
@@ -129,7 +138,7 @@ public class TestStandardContext extends
         
     }
 
-
+    @Test
     public void testBug49922() throws Exception {
         
         // Set up a container
@@ -251,7 +260,8 @@ public class TestStandardContext extends
         }
         
     }
-    
+
+    @Test
     public void testBug50015() throws Exception {
         // Set up a container
         Tomcat tomcat = getTomcatInstance();
@@ -321,10 +331,12 @@ public class TestStandardContext extends
         
     }
 
+    @Test
     public void testBug51376a() throws Exception {
         doTestBug51376(false);
     }
 
+    @Test
     public void testBug51376b() throws Exception {
         doTestBug51376(true);
     }
@@ -427,6 +439,7 @@ public class TestStandardContext extends
      * Test case for bug 49711: HttpServletRequest.getParts does not work
      * in a filter.
      */
+    @Test
     public void testBug49711() {
         Bug49711Client client = new Bug49711Client();
         client.setPort(getPort());

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java Mon Jul 25
19:25:22 2011
@@ -28,12 +28,17 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import static org.junit.Assert.assertTrue;
+
+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;
 
-public class TestStandardContextAliases extends TomcatBaseTest {
+public class TestStandardContextAliases extends TomcatBaseTestJUnit4 {
 
+    @Test
     public void testDirContextAliases() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java Mon Jul 25
19:25:22 2011
@@ -29,6 +29,11 @@ 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.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
@@ -36,10 +41,10 @@ import org.apache.catalina.deploy.WebXml
 import org.apache.catalina.startup.Constants;
 import org.apache.catalina.startup.ContextConfig;
 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 TestStandardContextResources extends TomcatBaseTest {
+public class TestStandardContextResources extends TomcatBaseTestJUnit4 {
 
     @Override
     public void setUp() throws Exception {
@@ -55,6 +60,7 @@ public class TestStandardContextResource
                 new JreMemoryLeakPreventionListener());
     }
 
+    @Test
     public void testResources() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
@@ -78,6 +84,7 @@ public class TestStandardContextResource
                 "<p>resourceG.jsp in WEB-INF/classes</p>", 404);
     }
 
+    @Test
     public void testResourcesWebInfClasses() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
@@ -105,6 +112,7 @@ public class TestStandardContextResource
                 "<p>resourceG.jsp in WEB-INF/classes</p>");
     }
 
+    @Test
     public void testResourcesAbsoluteOrdering() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
@@ -166,7 +174,8 @@ public class TestStandardContextResource
         "<p>resourceB.jsp in resources2.jar</p>");
  
     }
-    
+
+    @Test
     public void testResources2() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java Mon Jul 25 19:25:22
2011
@@ -43,45 +43,60 @@ 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.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.authenticator.BasicAuthenticator;
 import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.startup.TestTomcat.MapRealm;
 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 TestStandardWrapper extends TomcatBaseTest {
+public class TestStandardWrapper extends TomcatBaseTestJUnit4 {
 
+    @Test
     public void testSecurityAnnotationsSimple() throws Exception {
         doTest(DenyAllServlet.class.getName(), false, false, false);
     }
 
+    @Test
     public void testSecurityAnnotationsSubclass1() throws Exception {
         doTest(SubclassDenyAllServlet.class.getName(), false, false, false);
     }
 
+    @Test
     public void testSecurityAnnotationsSubclass2() throws Exception {
         doTest(SubclassAllowAllServlet.class.getName(), false, false, true);
     }
 
+    @Test
     public void testSecurityAnnotationsMethods1() throws Exception {
         doTest(MethodConstraintServlet.class.getName(), false, false, false);
     }
 
+    @Test
     public void testSecurityAnnotationsMethods2() throws Exception {
         doTest(MethodConstraintServlet.class.getName(), true, false, true);
     }
 
+    @Test
     public void testSecurityAnnotationsRole1() throws Exception {
         doTest(RoleAllowServlet.class.getName(), false, true, true);
     }
 
+    @Test
     public void testSecurityAnnotationsRole2() throws Exception {
         doTest(RoleDenyServlet.class.getName(), false, true, false);
     }
 
+    @Test
     public void testSecurityAnnotationsWebXmlPriority() throws Exception {
 
         // Setup Tomcat instance
@@ -102,6 +117,7 @@ public class TestStandardWrapper extends
         assertEquals(403, rc);
     }
 
+    @Test
     public void testSecurityAnnotationsMetaDataPriority() throws Exception {
 
         // Setup Tomcat instance
@@ -122,14 +138,17 @@ public class TestStandardWrapper extends
         assertEquals(200, rc);
     }
 
+    @Test
     public void testSecurityAnnotationsAddServlet1() throws Exception {
         doTestSecurityAnnotationsAddServlet(false);
     }
-    
+
+    @Test
     public void testSecurityAnnotationsAddServlet2() throws Exception {
         doTestSecurityAnnotationsAddServlet(true);
     }
-    
+
+    @Test
     public void testSecurityAnnotationsNoWebXmlConstraints() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -148,6 +167,7 @@ public class TestStandardWrapper extends
         assertEquals(403, rc);
     }
 
+    @Test
     public void testSecurityAnnotationsNoWebXmlLoginConfig() throws Exception {
         // Setup Tomcat instance
         Tomcat tomcat = getTomcatInstance();
@@ -338,6 +358,7 @@ public class TestStandardWrapper extends
     public static CountDownLatch latch = null;
     public static AtomicInteger counter = new AtomicInteger(0);
 
+    @Test
     public void testBug51445AddServlet() throws Exception {
 
         latch = new CountDownLatch(BUG51445_THREAD_COUNT);
@@ -381,6 +402,7 @@ public class TestStandardWrapper extends
         }
     }
 
+    @Test
     public void testBug51445AddChild() throws Exception {
         
         latch = new CountDownLatch(BUG51445_THREAD_COUNT);

Modified: tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java Mon Jul 25 19:25:22
2011
@@ -29,15 +29,20 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.Part;
 
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.startup.SimpleHttpClient;
 import org.apache.catalina.startup.Tomcat;
-import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.startup.TomcatBaseTestJUnit4;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
-public class TestSwallowAbortedUploads extends TomcatBaseTest {
+public class TestSwallowAbortedUploads extends TomcatBaseTestJUnit4 {
 
     private static Log log = LogFactory.getLog(TestSwallowAbortedUploads.class);
 
@@ -79,6 +84,7 @@ public class TestSwallowAbortedUploads e
         return ex;
     }
 
+    @Test
     public void testAbortedUploadUnlimitedSwallow() {
         log.info("Unlimited, swallow enabled");
         AbortedUploadClient client = new AbortedUploadClient();
@@ -90,6 +96,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedUploadUnlimitedNoSwallow() {
         log.info("Unlimited, swallow disabled");
         AbortedUploadClient client = new AbortedUploadClient();
@@ -101,6 +108,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedUploadLimitedSwallow() {
         log.info("Limited, swallow enabled");
         AbortedUploadClient client = new AbortedUploadClient();
@@ -112,6 +120,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedUploadLimitedNoSwallow() {
         log.info("Limited, swallow disabled");
         AbortedUploadClient client = new AbortedUploadClient();
@@ -121,6 +130,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedPOSTOKSwallow() {
         log.info("Aborted (OK), swallow enabled");
         AbortedPOSTClient client = new AbortedPOSTClient();
@@ -132,6 +142,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedPOSTOKNoSwallow() {
         log.info("Aborted (OK), swallow disabled");
         AbortedPOSTClient client = new AbortedPOSTClient();
@@ -143,6 +154,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedPOST413Swallow() {
         log.info("Aborted (413), swallow enabled");
         AbortedPOSTClient client = new AbortedPOSTClient();
@@ -154,6 +166,7 @@ public class TestSwallowAbortedUploads e
         client.reset();
     }
 
+    @Test
     public void testAbortedPOST413NoSwallow() {
         log.info("Aborted (413), swallow disabled");
         AbortedPOSTClient client = new AbortedPOSTClient();

Modified: tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java Mon Jul 25 19:25:22
2011
@@ -28,43 +28,55 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.deploy.FilterDef;
 import org.apache.catalina.deploy.FilterMap;
 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 TestAddCharSetFilter extends TomcatBaseTest {
+public class TestAddCharSetFilter extends TomcatBaseTestJUnit4 {
 
+    @Test
     public void testNoneSpecifiedMode1() throws Exception {
         doTest(null, "ISO-8859-1");
     }
 
+    @Test
     public void testNoneSpecifiedMode2() throws Exception {
         doTest(null, "ISO-8859-2", 2);
     }
 
+    @Test
     public void testNoneSpecifiedMode3() throws Exception {
         doTest(null, "ISO-8859-3", 3);
     }
 
+    @Test
     public void testDefault() throws Exception {
         doTest("default", "ISO-8859-1");
     }
 
+    @Test
     public void testDefaultMixedCase() throws Exception {
         doTest("dEfAuLt", "ISO-8859-1");
     }
 
+    @Test
     public void testSystem() throws Exception {
         doTest("system", Charset.defaultCharset().name());
     }
 
+    @Test
     public void testSystemMixedCase() throws Exception {
         doTest("SyStEm", Charset.defaultCharset().name());
     }
 
+    @Test
     public void testUTF8() throws Exception {
         doTest("utf-8", "utf-8");
     }

Modified: tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java Mon Jul 25
19:25:22 2011
@@ -24,10 +24,16 @@ import java.io.ObjectOutputStream;
 
 import javax.servlet.http.HttpServletResponse;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
 import org.apache.catalina.filters.CsrfPreventionFilter.LruCache;
-import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.startup.TomcatBaseTestJUnit4;
 
-public class TestCsrfPreventionFilter extends TomcatBaseTest {
+public class TestCsrfPreventionFilter extends TomcatBaseTestJUnit4 {
 
     private static final String RESULT_NONCE =
         Constants.CSRF_NONCE_SESSION_ATTR_NAME + "=TESTNONCE";
@@ -36,26 +42,31 @@ public class TestCsrfPreventionFilter ex
         new CsrfPreventionFilter.CsrfResponseWrapper(
                 new NonEncodingResponse(), "TESTNONCE");
 
+    @Test
     public void testAddNonceNoQueryNoAnchor() throws Exception {
         assertEquals("/test?" + RESULT_NONCE ,
                 wrapper.encodeRedirectURL("/test"));
     }
-    
+
+    @Test
     public void testAddNonceQueryNoAnchor() throws Exception {
         assertEquals("/test?a=b&" + RESULT_NONCE ,
                 wrapper.encodeRedirectURL("/test?a=b"));
     }
-    
+
+    @Test
     public void testAddNonceNoQueryAnchor() throws Exception {
         assertEquals("/test?" + RESULT_NONCE + "#c",
                 wrapper.encodeRedirectURL("/test#c"));
     }
-    
+
+    @Test
     public void testAddNonceQueryAnchor() throws Exception {
         assertEquals("/test?a=b&" + RESULT_NONCE + "#c",
                 wrapper.encodeRedirectURL("/test?a=b#c"));
     }
-    
+
+    @Test
     public void testLruCacheSerializable() throws Exception {
         LruCache<String> cache = new LruCache<String>(5);
         cache.add("key1");
@@ -85,6 +96,7 @@ public class TestCsrfPreventionFilter ex
         assertTrue(cache2.contains("key7"));
     }
 
+    @Test
     public void testLruCacheSerializablePerformance() throws Exception {
         for (int i = 0; i < 10000; i++) {
             testLruCacheSerializable();

Modified: tomcat/trunk/test/org/apache/catalina/filters/TestExpiresFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestExpiresFilter.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestExpiresFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestExpiresFilter.java Mon Jul 25 19:25:22
2011
@@ -33,6 +33,8 @@ import javax.servlet.http.HttpServletRes
 
 import junit.framework.Assert;
 
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.deploy.FilterDef;
 import org.apache.catalina.deploy.FilterMap;
@@ -41,11 +43,12 @@ import org.apache.catalina.filters.Expir
 import org.apache.catalina.filters.ExpiresFilter.ExpiresConfiguration;
 import org.apache.catalina.filters.ExpiresFilter.StartingPoint;
 import org.apache.catalina.startup.Tomcat;
-import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.startup.TomcatBaseTestJUnit4;
 
-public class TestExpiresFilter extends TomcatBaseTest {
+public class TestExpiresFilter extends TomcatBaseTestJUnit4 {
     public static final String TEMP_DIR = System.getProperty("java.io.tmpdir");
 
+    @Test
     public void testConfiguration() throws Exception {
 
         Tomcat tomcat = getTomcatInstance();
@@ -181,7 +184,7 @@ public class TestExpiresFilter extends T
     /**
      * Test that a resource with empty content is also processed
      */
-
+    @Test
     public void testEmptyContent() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -198,6 +201,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(7 * 60));
     }
 
+    @Test
     public void testParseExpiresConfigurationCombinedDuration() {
         ExpiresFilter expiresFilter = new ExpiresFilter();
         ExpiresConfiguration actualConfiguration = expiresFilter.parseExpiresConfiguration("access
plus 1 month 15 days 2 hours");
@@ -209,6 +213,7 @@ public class TestExpiresFilter extends T
 
     }
 
+    @Test
     public void testParseExpiresConfigurationMonoDuration() {
         ExpiresFilter expiresFilter = new ExpiresFilter();
         ExpiresConfiguration actualConfiguration = expiresFilter.parseExpiresConfiguration("access
plus 2 hours");
@@ -224,6 +229,7 @@ public class TestExpiresFilter extends T
 
     }
 
+    @Test
     public void testSkipBecauseCacheControlMaxAgeIsDefined() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -241,6 +247,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(232));
     }
 
+    @Test
     public void testExcludedResponseStatusCode() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -258,6 +265,7 @@ public class TestExpiresFilter extends T
         validate(servlet, null, HttpServletResponse.SC_NOT_MODIFIED);
     }
 
+    @Test
     public void testNullContentType() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -273,6 +281,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(1 * 60));
     }
 
+    @Test
     public void testSkipBecauseExpiresIsDefined() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -290,6 +299,7 @@ public class TestExpiresFilter extends T
         validate(servlet, null);
     }
 
+    @Test
     public void testUseContentTypeExpiresConfiguration() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -306,6 +316,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(3 * 60));
     }
 
+    @Test
     public void testUseContentTypeWithoutCharsetExpiresConfiguration()
             throws Exception {
         HttpServlet servlet = new HttpServlet() {
@@ -323,6 +334,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(5 * 60));
     }
 
+    @Test
     public void testUseDefaultConfiguration1() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -339,6 +351,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(1 * 60));
     }
 
+    @Test
     public void testUseDefaultConfiguration2() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -357,6 +370,7 @@ public class TestExpiresFilter extends T
         validate(servlet, Integer.valueOf(1 * 60));
     }
 
+    @Test
     public void testUseMajorTypeExpiresConfiguration() throws Exception {
         HttpServlet servlet = new HttpServlet() {
             private static final long serialVersionUID = 1L;
@@ -482,6 +496,7 @@ public class TestExpiresFilter extends T
         }
     }
 
+    @Test
     public void testIntsToCommaDelimitedString() {
         String actual = ExpiresFilter.intsToCommaDelimitedString(new int[] {
                 500, 503 });

Modified: tomcat/trunk/test/org/apache/catalina/filters/TestRemoteIpFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestRemoteIpFilter.java?rev=1150855&r1=1150854&r2=1150855&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestRemoteIpFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestRemoteIpFilter.java Mon Jul 25 19:25:22
2011
@@ -39,6 +39,12 @@ import javax.servlet.http.HttpServletRes
 
 import junit.framework.Assert;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.connector.Connector;
@@ -47,9 +53,9 @@ import org.apache.catalina.connector.Res
 import org.apache.catalina.deploy.FilterDef;
 import org.apache.catalina.deploy.FilterMap;
 import org.apache.catalina.startup.Tomcat;
-import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.startup.TomcatBaseTestJUnit4;
 
-public class TestRemoteIpFilter extends TomcatBaseTest {
+public class TestRemoteIpFilter extends TomcatBaseTestJUnit4 {
 
     /**
      * Mock {@link FilterChain} to keep a handle on the passed
@@ -127,23 +133,27 @@ public class TestRemoteIpFilter extends 
 
     public static final String TEMP_DIR = System.getProperty("java.io.tmpdir");
 
+    @Test
     public void testCommaDelimitedListToStringArray() {
         List<String> elements = Arrays.asList("element1", "element2", "element3");
         String actual = RemoteIpFilter.listToCommaDelimitedString(elements);
         assertEquals("element1, element2, element3", actual);
     }
 
+    @Test
     public void testCommaDelimitedListToStringArrayEmptyList() {
         List<String> elements = new ArrayList<String>();
         String actual = RemoteIpFilter.listToCommaDelimitedString(elements);
         assertEquals("", actual);
     }
 
+    @Test
     public void testCommaDelimitedListToStringArrayNullList() {
         String actual = RemoteIpFilter.listToCommaDelimitedString(null);
         assertEquals("", actual);
     }
 
+    @Test
     public void testHeaderNamesCaseInsensitivity() {
         RemoteIpFilter.XForwardedRequest request = new RemoteIpFilter.XForwardedRequest(new
MockHttpServletRequest());
         request.setHeader("myheader", "lower Case");
@@ -153,6 +163,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("Camel Case", request.getHeader("myheader"));
     }
 
+    @Test
     public void testIncomingRequestIsSecuredButProtocolHeaderSaysItIsNotWithCustomValues()
throws Exception {
         // PREPARE
         FilterDef filterDef = new FilterDef();
@@ -172,7 +183,7 @@ public class TestRemoteIpFilter extends 
 
         // VERIFY
         boolean actualSecure = actualRequest.isSecure();
-        assertEquals("request must be unsecured as header x-forwarded-proto said it is http",
false, actualSecure);
+        assertFalse("request must be unsecured as header x-forwarded-proto said it is http",
actualSecure);
 
         String actualScheme = actualRequest.getScheme();
         assertEquals("scheme must be http as header x-forwarded-proto said it is http", "http",
actualScheme);
@@ -187,6 +198,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
     }
 
+    @Test
     public void testIncomingRequestIsSecuredButProtocolHeaderSaysItIsNotWithDefaultValues()
throws Exception {
         // PREPARE
         FilterDef filterDef = new FilterDef();
@@ -204,7 +216,7 @@ public class TestRemoteIpFilter extends 
 
         // VERIFY
         boolean actualSecure = actualRequest.isSecure();
-        assertEquals("request must be unsecured as header x-forwarded-proto said it is http",
false, actualSecure);
+        assertFalse("request must be unsecured as header x-forwarded-proto said it is http",
actualSecure);
 
         String actualScheme = actualRequest.getScheme();
         assertEquals("scheme must be http as header x-forwarded-proto said it is http", "http",
actualScheme);
@@ -217,6 +229,7 @@ public class TestRemoteIpFilter extends 
 
     }
 
+    @Test
     public void testInvokeAllowedRemoteAddrWithNullRemoteIpHeader() throws Exception {
         // PREPARE
         FilterDef filterDef = new FilterDef();
@@ -247,6 +260,7 @@ public class TestRemoteIpFilter extends 
 
     }
 
+    @Test
     public void testInvokeAllProxiesAreInternal() throws Exception {
 
         // PREPARE
@@ -278,6 +292,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
     }
 
+    @Test
     public void testInvokeAllProxiesAreTrusted() throws Exception {
 
         // PREPARE
@@ -312,6 +327,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
     }
 
+    @Test
     public void testInvokeAllProxiesAreTrustedAndRemoteAddrMatchRegexp() throws Exception
{
 
         // PREPARE
@@ -345,6 +361,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
     }
 
+    @Test
     public void testInvokeAllProxiesAreTrustedOrInternal() throws Exception {
 
         // PREPARE
@@ -377,6 +394,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
     }
 
+    @Test
     public void testInvokeNotAllowedRemoteAddr() throws Exception {
         // PREPARE
         FilterDef filterDef = new FilterDef();
@@ -408,6 +426,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "not-allowed-internal-proxy-host", actualRemoteHost);
     }
 
+    @Test
     public void testInvokeUntrustedProxyInTheChain() throws Exception {
         // PREPARE
         FilterDef filterDef = new FilterDef();
@@ -439,6 +458,7 @@ public class TestRemoteIpFilter extends 
         assertEquals("remoteHost", "untrusted-proxy", actualRemoteHost);
     }
 
+    @Test
     public void testListToCommaDelimitedString() {
         String[] actual = RemoteIpFilter.commaDelimitedListToStringArray("element1, element2,
element3");
         String[] expected = new String[] { "element1", "element2", "element3" };
@@ -448,6 +468,7 @@ public class TestRemoteIpFilter extends 
         }
     }
 
+    @Test
     public void testListToCommaDelimitedStringMixedSpaceChars() {
         String[] actual = RemoteIpFilter.commaDelimitedListToStringArray("element1  , element2,\t
element3");
         String[] expected = new String[] { "element1", "element2", "element3" };
@@ -485,6 +506,7 @@ public class TestRemoteIpFilter extends 
     /**
      * Test {@link RemoteIpFilter} in Tomcat standalone server
      */
+    @Test
     public void testWithTomcatServer() throws Exception {
 
         // mostly default configuration : enable "x-forwarded-proto"



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message