|
|
@ -19,6 +19,8 @@ package org.springframework.boot.system;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.FileReader;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.function.BiFunction;
|
|
|
|
import java.util.function.BiFunction;
|
|
|
|
|
|
|
|
|
|
|
@ -59,28 +61,35 @@ public class EmbeddedServerPortFileWriterTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Parameters(name = "{0}")
|
|
|
|
@Parameters(name = "{0}")
|
|
|
|
public static Object[] parameters() {
|
|
|
|
public static Object[] parameters() {
|
|
|
|
BiFunction<String, Integer, ? extends WebServerInitializedEvent> servletEvent = (
|
|
|
|
Map<String, BiFunction<String, Integer, WebServerInitializedEvent>> parameters = new LinkedHashMap<>();
|
|
|
|
String name, Integer port) -> {
|
|
|
|
parameters.put("Servlet",
|
|
|
|
ServletWebServerApplicationContext applicationContext = mock(
|
|
|
|
EmbeddedServerPortFileWriterTests::servletEventParameter);
|
|
|
|
ServletWebServerApplicationContext.class);
|
|
|
|
parameters.put("Reactive",
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
EmbeddedServerPortFileWriterTests::reactiveEventParameter);
|
|
|
|
WebServer source = mock(WebServer.class);
|
|
|
|
return parameters.entrySet().stream()
|
|
|
|
given(source.getPort()).willReturn(port);
|
|
|
|
.map((e) -> new Object[] { e.getKey(), e.getValue() }).toArray();
|
|
|
|
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
|
|
|
|
}
|
|
|
|
source, applicationContext);
|
|
|
|
|
|
|
|
return event;
|
|
|
|
private static WebServerInitializedEvent servletEventParameter(String name,
|
|
|
|
};
|
|
|
|
Integer port) {
|
|
|
|
BiFunction<String, Integer, ? extends WebServerInitializedEvent> reactiveEvent = (
|
|
|
|
ServletWebServerApplicationContext applicationContext = mock(
|
|
|
|
String name, Integer port) -> {
|
|
|
|
ServletWebServerApplicationContext.class);
|
|
|
|
ReactiveWebServerApplicationContext applicationContext = mock(
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
ReactiveWebServerApplicationContext.class);
|
|
|
|
WebServer source = mock(WebServer.class);
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
given(source.getPort()).willReturn(port);
|
|
|
|
WebServer source = mock(WebServer.class);
|
|
|
|
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
|
|
|
|
given(source.getPort()).willReturn(port);
|
|
|
|
source, applicationContext);
|
|
|
|
return new ReactiveWebServerInitializedEvent(source, applicationContext);
|
|
|
|
return event;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return new Object[] { new Object[] { "Servlet", servletEvent },
|
|
|
|
|
|
|
|
new Object[] { "Reactive", reactiveEvent } };
|
|
|
|
private static WebServerInitializedEvent reactiveEventParameter(String name,
|
|
|
|
|
|
|
|
Integer port) {
|
|
|
|
|
|
|
|
ReactiveWebServerApplicationContext applicationContext = mock(
|
|
|
|
|
|
|
|
ReactiveWebServerApplicationContext.class);
|
|
|
|
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
|
|
|
|
WebServer source = mock(WebServer.class);
|
|
|
|
|
|
|
|
given(source.getPort()).willReturn(port);
|
|
|
|
|
|
|
|
return new ReactiveWebServerInitializedEvent(source, applicationContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory;
|
|
|
|
private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory;
|
|
|
|