public class EmbeddedWebservice extends Object
An webservice meant to be used in tests to simulate a HTTP Server. You can feed it with prepared responses which will then be sent on each request.
| Constructor and Description |
|---|
EmbeddedWebservice()
Creates a webservice responding to a random free port on root context.
|
EmbeddedWebservice(String context)
Creates a webservice responding to a random free port on specified context.
|
EmbeddedWebservice(String context,
int port)
Creates a webservice responding to given port on specified context.
|
| Modifier and Type | Method and Description |
|---|---|
URI |
getClientUri()
Get the URI which where to send requests to, to reach this service.
|
PreparedResponsesHttpHandler |
getHttpHandler()
Get handler to control response flow.
|
void |
start()
Start the webservice.
|
void |
stop()
Stop the webservice.
|
String |
toString() |
public EmbeddedWebservice()
throws IOException
Creates a webservice responding to a random free port on root context.
IOException - on failurepublic EmbeddedWebservice(@Nonnull String context) throws IOException
Creates a webservice responding to a random free port on specified context.
context - context, for example /lorem for lorem-contextIOException - on failurepublic EmbeddedWebservice(@Nonnull String context, int port) throws IOException
Creates a webservice responding to given port on specified context.
context - context, for example /lorem for lorem-contextport - port to bind the service toIOException - on failure@Nonnull public URI getClientUri()
Get the URI which where to send requests to, to reach this service.
public void start()
public void stop()
@Nonnull public PreparedResponsesHttpHandler getHttpHandler()
Get handler to control response flow.
Copyright © 2011-2013 CoreMedia AG. All Rights Reserved.