|
|
@ -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,8 +61,17 @@ 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",
|
|
|
|
|
|
|
|
EmbeddedServerPortFileWriterTests::servletEventParameter);
|
|
|
|
|
|
|
|
parameters.put("Reactive",
|
|
|
|
|
|
|
|
EmbeddedServerPortFileWriterTests::reactiveEventParameter);
|
|
|
|
|
|
|
|
return parameters.entrySet().stream()
|
|
|
|
|
|
|
|
.map((e) -> new Object[] { e.getKey(), e.getValue() }).toArray();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static WebServerInitializedEvent servletEventParameter(String name,
|
|
|
|
|
|
|
|
Integer port) {
|
|
|
|
ServletWebServerApplicationContext applicationContext = mock(
|
|
|
|
ServletWebServerApplicationContext applicationContext = mock(
|
|
|
|
ServletWebServerApplicationContext.class);
|
|
|
|
ServletWebServerApplicationContext.class);
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
@ -69,18 +80,16 @@ public class EmbeddedServerPortFileWriterTests {
|
|
|
|
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
|
|
|
|
ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(
|
|
|
|
source, applicationContext);
|
|
|
|
source, applicationContext);
|
|
|
|
return event;
|
|
|
|
return event;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
BiFunction<String, Integer, ? extends WebServerInitializedEvent> reactiveEvent = (
|
|
|
|
|
|
|
|
String name, Integer port) -> {
|
|
|
|
private static WebServerInitializedEvent reactiveEventParameter(String name,
|
|
|
|
|
|
|
|
Integer port) {
|
|
|
|
ReactiveWebServerApplicationContext applicationContext = mock(
|
|
|
|
ReactiveWebServerApplicationContext applicationContext = mock(
|
|
|
|
ReactiveWebServerApplicationContext.class);
|
|
|
|
ReactiveWebServerApplicationContext.class);
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
given(applicationContext.getNamespace()).willReturn(name);
|
|
|
|
WebServer source = mock(WebServer.class);
|
|
|
|
WebServer source = mock(WebServer.class);
|
|
|
|
given(source.getPort()).willReturn(port);
|
|
|
|
given(source.getPort()).willReturn(port);
|
|
|
|
return new ReactiveWebServerInitializedEvent(source, applicationContext);
|
|
|
|
return new ReactiveWebServerInitializedEvent(source, applicationContext);
|
|
|
|
};
|
|
|
|
|
|
|
|
return new Object[] { new Object[] { "Servlet", servletEvent },
|
|
|
|
|
|
|
|
new Object[] { "Reactive", reactiveEvent } };
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory;
|
|
|
|
private final BiFunction<String, Integer, ? extends WebServerInitializedEvent> eventFactory;
|
|
|
|