|
|
|
@ -121,9 +121,7 @@ public class TomcatServletWebServerFactoryTests
|
|
|
|
|
public void tomcatListeners() {
|
|
|
|
|
TomcatServletWebServerFactory factory = getFactory();
|
|
|
|
|
LifecycleListener[] listeners = new LifecycleListener[4];
|
|
|
|
|
for (int i = 0; i < listeners.length; i++) {
|
|
|
|
|
listeners[i] = mock(LifecycleListener.class);
|
|
|
|
|
}
|
|
|
|
|
Arrays.setAll(listeners, i -> mock(LifecycleListener.class));
|
|
|
|
|
factory.setContextLifecycleListeners(Arrays.asList(listeners[0], listeners[1]));
|
|
|
|
|
factory.addContextLifecycleListeners(listeners[2], listeners[3]);
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
@ -137,9 +135,7 @@ public class TomcatServletWebServerFactoryTests
|
|
|
|
|
public void tomcatCustomizers() {
|
|
|
|
|
TomcatServletWebServerFactory factory = getFactory();
|
|
|
|
|
TomcatContextCustomizer[] listeners = new TomcatContextCustomizer[4];
|
|
|
|
|
for (int i = 0; i < listeners.length; i++) {
|
|
|
|
|
listeners[i] = mock(TomcatContextCustomizer.class);
|
|
|
|
|
}
|
|
|
|
|
Arrays.setAll(listeners, i -> mock(TomcatContextCustomizer.class));
|
|
|
|
|
factory.setTomcatContextCustomizers(Arrays.asList(listeners[0], listeners[1]));
|
|
|
|
|
factory.addContextCustomizers(listeners[2], listeners[3]);
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
@ -164,9 +160,7 @@ public class TomcatServletWebServerFactoryTests
|
|
|
|
|
public void tomcatConnectorCustomizers() {
|
|
|
|
|
TomcatServletWebServerFactory factory = getFactory();
|
|
|
|
|
TomcatConnectorCustomizer[] listeners = new TomcatConnectorCustomizer[4];
|
|
|
|
|
for (int i = 0; i < listeners.length; i++) {
|
|
|
|
|
listeners[i] = mock(TomcatConnectorCustomizer.class);
|
|
|
|
|
}
|
|
|
|
|
Arrays.setAll(listeners, i -> mock(TomcatConnectorCustomizer.class));
|
|
|
|
|
factory.setTomcatConnectorCustomizers(Arrays.asList(listeners[0], listeners[1]));
|
|
|
|
|
factory.addConnectorCustomizers(listeners[2], listeners[3]);
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
@ -180,11 +174,7 @@ public class TomcatServletWebServerFactoryTests
|
|
|
|
|
public void tomcatAdditionalConnectors() {
|
|
|
|
|
TomcatServletWebServerFactory factory = getFactory();
|
|
|
|
|
Connector[] listeners = new Connector[4];
|
|
|
|
|
for (int i = 0; i < listeners.length; i++) {
|
|
|
|
|
Connector connector = mock(Connector.class);
|
|
|
|
|
given(connector.getState()).willReturn(LifecycleState.STOPPED);
|
|
|
|
|
listeners[i] = connector;
|
|
|
|
|
}
|
|
|
|
|
Arrays.setAll(listeners, i -> stoppedConnector());
|
|
|
|
|
factory.addAdditionalTomcatConnectors(listeners);
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
|
Map<Service, Connector[]> connectors = ((TomcatWebServer) this.webServer)
|
|
|
|
@ -193,6 +183,12 @@ public class TomcatServletWebServerFactoryTests
|
|
|
|
|
.isEqualTo(listeners.length + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Connector stoppedConnector() {
|
|
|
|
|
Connector connector = mock(Connector.class);
|
|
|
|
|
given(connector.getState()).willReturn(LifecycleState.STOPPED);
|
|
|
|
|
return connector;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void addNullAdditionalConnectorThrows() {
|
|
|
|
|
TomcatServletWebServerFactory factory = getFactory();
|
|
|
|
|