From c16b5d277e04943b677c8bdd3a0e85951587365f Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 29 Nov 2013 17:06:08 +0000 Subject: [PATCH] Add test for Valve added --- .../TomcatEmbeddedServletContainerFactoryTests.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java index 350f358337..984a26a65f 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit; import org.apache.catalina.Context; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; +import org.apache.catalina.Valve; import org.apache.catalina.connector.Connector; import org.apache.catalina.startup.Tomcat; import org.junit.Test; @@ -30,9 +31,11 @@ import org.springframework.boot.context.embedded.AbstractEmbeddedServletContaine import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; /** * Tests for {@link TomcatEmbeddedServletContainerFactory} and @@ -111,6 +114,15 @@ public class TomcatEmbeddedServletContainerFactoryTests extends assertTimeout(factory, 60); } + @Test + public void valve() throws Exception { + TomcatEmbeddedServletContainerFactory factory = getFactory(); + Valve valve = mock(Valve.class); + factory.addContextValves(valve); + this.container = factory.getEmbeddedServletContainer(); + verify(valve).setNext(any(Valve.class)); + } + private void assertTimeout(TomcatEmbeddedServletContainerFactory factory, int expected) { this.container = factory.getEmbeddedServletContainer(); Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat(); @@ -118,5 +130,4 @@ public class TomcatEmbeddedServletContainerFactoryTests extends assertThat(context.getSessionTimeout(), equalTo(expected)); } - // FIXME test valve }