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