public final class EmbeddedServerTestLifeCycleAdapter extends Object implements TestLifeCycleAdapter
| Constructor and Description |
|---|
EmbeddedServerTestLifeCycleAdapter()
Create rule with default embedded server.
|
EmbeddedServerTestLifeCycleAdapter(AbstractConfiguration configuration)
Create rule with embedded server configuration.
|
EmbeddedServerTestLifeCycleAdapter(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(HttpClientStrategy strategy)
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterEach, beforeEachpublic EmbeddedServerTestLifeCycleAdapter()
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 EmbeddedServerTestLifeCycleAdapter(AbstractConfiguration) constructor.
public EmbeddedServerTestLifeCycleAdapter(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 EmbeddedServerTestLifeCycleAdapter(EmbeddedServer<?> server)
server - Embedded server, not null.NullPointerException - If server is null.public void beforeAll()
beforeAll in interface TestLifeCycleAdapterpublic void afterAll()
afterAll in interface TestLifeCycleAdapterpublic 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(HttpClientStrategy strategy)
server.UnsupportedOperationException - If the client cannot be returned because of missing implementation.public void beforeEach(Object target)
TestLifeCycleAdapterbeforeEach in interface TestLifeCycleAdaptertarget - The test class instance.public void afterEach(Object target)
TestLifeCycleAdapterafterEach in interface TestLifeCycleAdaptertarget - The test class instance.Copyright © 2018. All rights reserved.