[java] Making UrlCheckerTest run longer, but stable by warming up NettyServer
private URL url;
@Before
- public void buildServer() throws MalformedURLException {
- NettyAppServer server = new NettyAppServer(req -> new HttpResponse()
+ public void buildServer() throws MalformedURLException, UrlChecker.TimeoutException {
+ // Warming NettyServer up
+ final NettyAppServer server = createServer();
+ executorService.submit(() -> {
+ server.start();
+ return null;
+ });
+ urlChecker.waitUntilAvailable(10, TimeUnit.SECONDS, new URL(server.whereIs("/")));
+ server.stop();
+
+ this.server = createServer();
+ this.url = new URL(this.server.whereIs("/"));
+ }
+
+ private NettyAppServer createServer() {
+ return new NettyAppServer(req -> new HttpResponse()
.setStatus(200)
.setContent(utf8String("<h1>Working</h1>")));
- this.server = server;
-
- this.url = new URL(server.whereIs("/"));
}
@Test
