This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new dbeaddf22c Add test for custom wrapper related classes
dbeaddf22c is described below
commit dbeaddf22c67e1fad0cb33860288b2d686cb12f2
Author: remm <[email protected]>
AuthorDate: Tue Nov 12 16:48:47 2024 +0100
Add test for custom wrapper related classes
---
.../apache/catalina/core/TestStandardContext.java | 46 ++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/test/org/apache/catalina/core/TestStandardContext.java
b/test/org/apache/catalina/core/TestStandardContext.java
index 9070963476..97bb169ceb 100644
--- a/test/org/apache/catalina/core/TestStandardContext.java
+++ b/test/org/apache/catalina/core/TestStandardContext.java
@@ -52,6 +52,8 @@ import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
+import org.apache.catalina.ContainerEvent;
+import org.apache.catalina.ContainerListener;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
@@ -1066,4 +1068,48 @@ public class TestStandardContext extends TomcatBaseTest {
Assert.assertEquals("/engine/hostcontext", result);
}
+
+ @Test
+ public void testWrapperListeners() throws Exception {
+ // Setup Tomcat instance
+ Tomcat tomcat = getTomcatInstance();
+
+ // No file system docBase required
+ Context ctx = tomcat.addContext("/test", null);
+
ctx.setWrapperClass("org.apache.catalina.core.TestStandardContext$MyWrapperClass");
+
ctx.addWrapperLifecycle("org.apache.catalina.core.TestStandardContext$MyWrapperLifecycleListener");
+
ctx.addWrapperListener("org.apache.catalina.core.TestStandardContext$MyWrapperContainerListener");
+ Wrapper w = Tomcat.addServlet(ctx, "something",
"org.apache.catalina.core.TestStandardContext$Bug51376Servlet");
+
+ tomcat.start();
+
+ w.addInitParameter("foo", "bar");
+
+ Assert.assertTrue(customWrapperClassOk);
+ Assert.assertTrue(containerListenerOk);
+ Assert.assertTrue(lifecycleListenerOk);
+ }
+
+ private static boolean customWrapperClassOk = false;
+ public static class MyWrapperClass extends StandardWrapper {
+ @Override
+ protected void startInternal() throws LifecycleException {
+ super.startInternal();
+ customWrapperClassOk = true;
+ }
+ }
+ private static boolean containerListenerOk = false;
+ public static class MyWrapperContainerListener implements
ContainerListener {
+ @Override
+ public void containerEvent(ContainerEvent event) {
+ containerListenerOk = true;
+ }
+ }
+ private static boolean lifecycleListenerOk = false;
+ public static class MyWrapperLifecycleListener implements
LifecycleListener {
+ @Override
+ public void lifecycleEvent(LifecycleEvent event) {
+ lifecycleListenerOk = true;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]