You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2013/01/07 07:53:58 UTC

svn commit: r1429687 - /tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java

Author: kkolinko
Date: Mon Jan  7 06:53:58 2013
New Revision: 1429687

URL: http://svn.apache.org/viewvc?rev=1429687&view=rev
Log:
Add comments and a pair of additional checks. Correct a typo.

Modified:
    tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java

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=1429687&r1=1429686&r2=1429687&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java Mon Jan  7 06:53:58 2013
@@ -49,6 +49,7 @@ import static org.junit.Assert.fail;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.authenticator.BasicAuthenticator;
 import org.apache.catalina.deploy.FilterDef;
@@ -70,6 +71,8 @@ public class TestStandardContext extends
 
     @Test
     public void testBug46243() throws Exception {
+        // This tests that if a Filter init() fails then the web application
+        // is not put into service.
 
         // Set up a container
         Tomcat tomcat = getTomcatInstance();
@@ -107,6 +110,10 @@ public class TestStandardContext extends
         client.connect();
         client.processRequest();
         assertTrue(client.isResponse404());
+
+        // Context failed to start. This checks that automatic transition
+        // from FAILED to STOPPED state was successful.
+        assertEquals(LifecycleState.STOPPED, root.getState());
     }
 
     private static final class Bug46243Client extends SimpleHttpClient {
@@ -145,6 +152,9 @@ public class TestStandardContext extends
 
     @Test
     public void testBug49922() throws Exception {
+        // Test that filter mapping works. Test that the same filter is
+        // called only once, even if is selected by several mapping
+        // url-patterns or by both a url-pattern and a servlet-name.
 
         // Set up a container
         Tomcat tomcat = getTomcatInstance();
@@ -269,6 +279,9 @@ public class TestStandardContext extends
 
     @Test
     public void testBug50015() throws Exception {
+        // Test that configuring servlet security constraints programmatically
+        // does work.
+
         // Set up a container
         Tomcat tomcat = getTomcatInstance();
 
@@ -348,6 +361,9 @@ public class TestStandardContext extends
     }
 
     private void doTestBug51376(boolean loadOnStartUp) throws Exception {
+        // Test that for a servlet that was added programmatically its
+        // loadOnStartup property is honored and its init() and destroy()
+        // methods are called.
 
         // Set up a container
         Tomcat tomcat = getTomcatInstance();
@@ -368,6 +384,7 @@ public class TestStandardContext extends
 
         // Make sure that init() and destroy() were called correctly
         assertTrue(sci.getServlet().isOk());
+        assertTrue(loadOnStartUp == sci.getServlet().isInitCalled());
     }
 
     public static final class Bug51376SCI
@@ -402,11 +419,11 @@ public class TestStandardContext extends
         private static final long serialVersionUID = 1L;
 
         private Boolean initOk = null;
-        private Boolean destoryOk = null;
+        private Boolean destroyOk = null;
 
         @Override
         public void init() {
-            if (initOk == null && destoryOk == null) {
+            if (initOk == null && destroyOk == null) {
                 initOk = Boolean.TRUE;
             } else {
                 initOk = Boolean.FALSE;
@@ -415,10 +432,10 @@ public class TestStandardContext extends
 
         @Override
         public void destroy() {
-            if (initOk.booleanValue() && destoryOk == null) {
-                destoryOk = Boolean.TRUE;
+            if (initOk.booleanValue() && destroyOk == null) {
+                destroyOk = Boolean.TRUE;
             } else {
-                destoryOk = Boolean.FALSE;
+                destroyOk = Boolean.FALSE;
             }
         }
 
@@ -430,15 +447,19 @@ public class TestStandardContext extends
         }
 
         protected boolean isOk() {
-            if (initOk != null && initOk.booleanValue() && destoryOk != null &&
-                    destoryOk.booleanValue()) {
+            if (initOk != null && initOk.booleanValue() && destroyOk != null &&
+                    destroyOk.booleanValue()) {
                 return true;
-            } else if (initOk == null && destoryOk == null) {
+            } else if (initOk == null && destroyOk == null) {
                 return true;
             } else {
                 return false;
             }
         }
+
+        protected boolean isInitCalled() {
+            return initOk != null && initOk.booleanValue();
+        }
     }
 
     /**
@@ -499,6 +520,7 @@ public class TestStandardContext extends
             resp.setContentType("text/plain");
             resp.setCharacterEncoding("UTF-8");
 
+            @SuppressWarnings("resource") // No need to close this writer
             PrintWriter out = resp.getWriter();
 
             out.println("parts=" + (null == req.getParts()



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