|
55 | 55 | import javax.net.ssl.SSLException;
|
56 | 56 | import javax.servlet.GenericServlet;
|
57 | 57 | import javax.servlet.ServletContext;
|
| 58 | +import javax.servlet.ServletContextEvent; |
| 59 | +import javax.servlet.ServletContextListener; |
58 | 60 | import javax.servlet.ServletException;
|
59 | 61 | import javax.servlet.ServletRequest;
|
60 | 62 | import javax.servlet.ServletResponse;
|
|
110 | 112 | import static org.hamcrest.CoreMatchers.notNullValue;
|
111 | 113 | import static org.junit.Assert.fail;
|
112 | 114 | import static org.mockito.BDDMockito.given;
|
| 115 | +import static org.mockito.Matchers.any; |
113 | 116 | import static org.mockito.Matchers.anyObject;
|
114 | 117 | import static org.mockito.Mockito.inOrder;
|
115 | 118 | import static org.mockito.Mockito.mock;
|
@@ -1035,6 +1038,26 @@ public void explodedWarFileDocumentRootWhenRunningFromPackagedWar() throws Excep
|
1035 | 1038 | assertThat(documentRoot).isNull();
|
1036 | 1039 | }
|
1037 | 1040 |
|
| 1041 | + @Test |
| 1042 | + public void servletContextListenerContextDestroyedIsCalledWhenContainerIsStopped() |
| 1043 | + throws Exception { |
| 1044 | + final ServletContextListener listener = mock(ServletContextListener.class); |
| 1045 | + AbstractEmbeddedServletContainerFactory factory = getFactory(); |
| 1046 | + this.container = factory |
| 1047 | + .getEmbeddedServletContainer(new ServletContextInitializer() { |
| 1048 | + |
| 1049 | + @Override |
| 1050 | + public void onStartup(ServletContext servletContext) |
| 1051 | + throws ServletException { |
| 1052 | + servletContext.addListener(listener); |
| 1053 | + } |
| 1054 | + |
| 1055 | + }); |
| 1056 | + this.container.start(); |
| 1057 | + this.container.stop(); |
| 1058 | + verify(listener).contextDestroyed(any(ServletContextEvent.class)); |
| 1059 | + } |
| 1060 | + |
1038 | 1061 | protected abstract void addConnector(int port,
|
1039 | 1062 | AbstractEmbeddedServletContainerFactory factory);
|
1040 | 1063 |
|
|
0 commit comments