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
ConstructorDescriptionTestServer
(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
.void
Stops 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. UseTestPortUtil
to find a random free port.timeout
- the idle timeout when receiving new messages on a connection in milliseconds.servletHolder
- aServletHolder
which holds theServlet
content will be served from.
-
-
Method Details
-
startServer
Starts the server and returns aCompletableFuture
. TheCompletableFuture
gets completed as soon as the server is ready to accept connections.- Returns:
- a
CompletableFuture
which completes as soon as the server is ready to accept connections.
-
stopServer
public void stopServer()Stops the server.
-