Commit 0e7824ce authored by Johnny Lim's avatar Johnny Lim Committed by Andy Wilkinson

Polish TomcatReactiveWebServerFactoryTests

See gh-17336
parent e1394d4b
......@@ -40,7 +40,6 @@ import org.mockito.InOrder;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests;
import org.springframework.boot.web.server.PortInUseException;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.util.SocketUtils;
......@@ -217,7 +216,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
}
@Test
protected void portClashOfPrimaryConnectorResultsInPortInUseException() throws IOException {
void portClashOfPrimaryConnectorResultsInPortInUseException() throws IOException {
doWithBlockedPort((port) -> {
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
AbstractReactiveWebServerFactory factory = getFactory();
......@@ -228,8 +227,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
});
}
protected final void doWithBlockedPort(AbstractServletWebServerFactoryTests.BlockedPortAction action)
throws IOException {
private void doWithBlockedPort(BlockedPortAction action) throws IOException {
int port = SocketUtils.findAvailableTcpPort(40000);
ServerSocket serverSocket = new ServerSocket();
for (int i = 0; i < 10; i++) {
......@@ -248,9 +246,15 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
}
}
protected void handleExceptionCausedByBlockedPortOnPrimaryConnector(RuntimeException ex, int blockedPort) {
private void handleExceptionCausedByBlockedPortOnPrimaryConnector(RuntimeException ex, int blockedPort) {
assertThat(ex).isInstanceOf(PortInUseException.class);
assertThat(((PortInUseException) ex).getPort()).isEqualTo(blockedPort);
}
public interface BlockedPortAction {
void run(int port);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment