webflux-form sample uses Tomcat

Work around gh-4923
This commit is contained in:
Rob Winch
2017-12-20 15:08:38 -06:00
parent 268a1dc06e
commit 67bb91bb76
3 changed files with 37 additions and 15 deletions

View File

@@ -28,17 +28,20 @@ import org.springframework.test.context.junit4.SpringRunner;
import sample.webdriver.IndexPage;
import sample.webdriver.LoginPage;
import java.io.IOException;
import java.net.ServerSocket;
/**
* @author Rob Winch
* @since 5.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = WebfluxFormApplication.class)
@TestPropertySource(properties = "server.port=0")
@TestPropertySource(properties = "server.port=#{T(sample.WebfluxFormApplicationTests).availablePort()}")
public class WebfluxFormApplicationTests {
WebDriver driver;
@Value("#{@nettyContext.address().getPort()}")
@Value("#{@tomcat.server.port}")
int port;
@Before
@@ -76,4 +79,12 @@ public class WebfluxFormApplicationTests {
.assertAt()
.assertLogout();
}
public static final int availablePort() {
try(ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
} catch(IOException e) {
throw new RuntimeException(e);
}
}
}