public final class EmbeddedServerRunner extends Object implements TestRunner
| Constructor and Description |
|---|
EmbeddedServerRunner()
Create rule with default embedded server.
|
EmbeddedServerRunner(AbstractConfiguration configuration)
Create rule with embedded server configuration.
|
EmbeddedServerRunner(EmbeddedServer<?> server)
Create rule with an embedded server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterAll()
Run the AFTER step of the lifecycle test.
|
void |
afterEach(Object target)
Method called after running unit test.
|
void |
beforeAll()
Run the BEFORE step of the lifecycle test.
|
void |
beforeEach(Object target)
Method called before running unit test.
|
HttpClient |
getClient()
Returns HTTP client that can be used against
server. |
HttpClient |
getClient(HttpClientConfiguration configuration)
Returns HTTP client that can be used against
server. |
HttpClient |
getClient(HttpClientStrategy strategy)
Returns HTTP client that can be used against
server. |
HttpClient |
getClient(HttpClientStrategy strategy,
HttpClientConfiguration configuration)
Returns HTTP client that can be used against
server. |
String |
getHost()
Get embedded server scheme (should be
"localhost"). |
String |
getPath()
Get path defined on embedded server.
|
int |
getPort()
Get port used by embedded server.
|
String |
getScheme()
Get embedded server scheme (a.k.a
"http" or "https"). |
EmbeddedServer<?> |
getServer()
Get embedded server.
|
String |
getUrl()
Get url used to query embedded server.
|
boolean |
isStarted()
Check if embedded server is started.
|
void |
restart()
Restart embedded server.
|
void |
start()
Start embedded server.
|
void |
stop()
Stop embedded server.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitafterEach, beforeEachpublic EmbeddedServerRunner()
Embedded server implementation is chosen using classpath detection: jetty or tomcat will be instantiate if implementation is available on classpath (it means if sub-module is imported, it should be enough to instantiate embedded server).
The server will automatically use the default configuration,
to specify a custom configuration, use EmbeddedServerRunner(AbstractConfiguration) constructor.
public EmbeddedServerRunner(AbstractConfiguration configuration)
Embedded server implementation is chosen using classpath detection: jetty or tomcat will be instantiate if implementation is available on classpath (it means if sub-module is imported, it should be enough to instantiate embedded server !).
configuration - Server configuration.public EmbeddedServerRunner(EmbeddedServer<?> server)
server - Embedded server, not null.NullPointerException - If server is null.public void beforeAll()
beforeAll in interface TestRunnerpublic void afterAll()
afterAll in interface TestRunnerpublic void start()
EmbeddedServer.start()public void stop()
EmbeddedServer.stop()public void restart()
EmbeddedServer.restart()public boolean isStarted()
true if embedded server is started, false otherwise.EmbeddedServer.isStarted()public String getScheme()
"http" or "https").EmbeddedServer.getScheme()public String getHost()
"localhost").EmbeddedServer.getHost()public int getPort()
Note that:
EmbeddedServer.getPort()public String getPath()
EmbeddedServer.getPath()public String getUrl()
EmbeddedServer.getUrl()public EmbeddedServer<?> getServer()
public HttpClient getClient()
server.UnsupportedOperationException - If the client cannot be returned because of missing implementation.public HttpClient getClient(HttpClientConfiguration configuration)
server.configuration - The client configuration.UnsupportedOperationException - If the client cannot be returned because of missing implementation.public HttpClient getClient(HttpClientStrategy strategy)
server.strategy - The strategy to use.UnsupportedOperationException - If the client cannot be returned because of missing implementation.public HttpClient getClient(HttpClientStrategy strategy, HttpClientConfiguration configuration)
server.strategy - The strategy to use.configuration - The client configuration.UnsupportedOperationException - If the client cannot be returned because of missing implementation.public void beforeEach(Object target)
TestRunnerbeforeEach in interface TestRunnertarget - The test class instance.public void afterEach(Object target)
TestRunnerafterEach in interface TestRunnertarget - The test class instance.Copyright © 2019. All rights reserved.