@Test public void testInit_Default_Config() throws Exception { when(serverOptions.getHost()).thenReturn("0.0.0.0"); when(serverOptions.getPort()).thenReturn(80); jerseyServer.start(); verifyExecuteBlocking(); verifyResults(80, "0.0.0.0"); }
@Test public void testInit_Listen_Result() throws Exception { jerseyServer.start(doneHandler); verifyExecuteBlocking(); verify(httpServer).listen(handlerCaptor.capture()); Handler<AsyncResult<HttpServer>> handler = handlerCaptor.getValue(); when(asyncResult.succeeded()).thenReturn(true).thenReturn(false); handler.handle(asyncResult); // verify(logger).info(anyString()); // verify(logger, times(0)).error(anyString()); handler.handle(asyncResult); // verify(logger).info(anyString()); // verify(logger).error(anyString(), any(Throwable.class)); verify(doneHandler, times(2)).handle(eq(asyncResult)); }
@Test public void testInit_With_Config() throws Exception { String host = "test.englishtown.com"; int port = 8888; int bufferSize = 1024; boolean ssl = true; boolean compressionSupported = true; when(serverOptions.getHost()).thenReturn(host); when(serverOptions.getPort()).thenReturn(port); when(serverOptions.getReceiveBufferSize()).thenReturn(bufferSize); when(serverOptions.isSsl()).thenReturn(ssl); when(serverOptions.isCompressionSupported()).thenReturn(compressionSupported); jerseyServer.start(); verifyExecuteBlocking(); verifyResults(port, host); verify(vertx).createHttpServer(optionsCaptor.capture()); HttpServerOptions options = optionsCaptor.getValue(); assertEquals(host, options.getHost()); assertEquals(port, options.getPort()); assertEquals(bufferSize, options.getReceiveBufferSize()); assertEquals(ssl, options.isSsl()); assertEquals(compressionSupported, options.isCompressionSupported()); }