Package org.openhab.core.test
Class TestServer
java.lang.Object
org.openhab.core.test.TestServer
Embedded jetty server used in the tests.
- Author:
- Velin Yordanov - Initial contribution, Henning Treu - provide in base test bundle
-
Constructor Summary
ConstructorsConstructorDescriptionTestServer(String host, int port, int timeout, org.eclipse.jetty.servlet.ServletHolder servletHolder) Creates a newTestServer. -
Method Summary
Modifier and TypeMethodDescriptionStarts the server and returns aCompletableFuture.voidStops the server.
-
Constructor Details
-
TestServer
public TestServer(String host, int port, int timeout, org.eclipse.jetty.servlet.ServletHolder servletHolder) Creates a newTestServer. The server is started bystartServer()and stopped bystopServer(), preferably in the tests setup and tearDown methods.- Parameters:
host- the host this server runs on.port- the port this server runs on. UseTestPortUtilto find a random free port.timeout- the idle timeout when receiving new messages on a connection in milliseconds.servletHolder- aServletHolderwhich holds theServletcontent will be served from.
-
-
Method Details
-
startServer
Starts the server and returns aCompletableFuture. TheCompletableFuturegets completed as soon as the server is ready to accept connections.- Returns:
- a
CompletableFuturewhich completes as soon as the server is ready to accept connections.
-
stopServer
public void stopServer()Stops the server.
-