public class MockHttpServer extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
MockHttpServer.ExpectationHandler |
| Modifier and Type | Field and Description |
|---|---|
static String |
DELETE |
static String |
GET |
static String |
POST |
static String |
PUT |
| Constructor and Description |
|---|
MockHttpServer(int port,
HttpResponseProvider responseProvider)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getPort()
Return the port used by the server.
|
void |
setExceptionResponseCode(int code)
Allows to set a custom response code to be returned when an unexpected exception happens.
|
void |
setNoMatchFoundResponseCode(int code)
Allows you to set a custom response code to be returned when no matching response is found.
|
int |
start()
Starts the server.
|
void |
stop()
Closes the server.
|
void |
verify()
Verify if we got all requests as expected.
|
public static final String GET
public static final String POST
public static final String PUT
public static final String DELETE
public MockHttpServer(int port,
HttpResponseProvider responseProvider)
port - Port on which mock server should operate. If you provide 0 as port number a free port will be choosen for you. You can get the port through getPort()responseProvider - HttpResponseProvider. Should not be null.public int start()
throws IOException
IOException - In case starting fails.public int getPort()
public void stop()
throws IOException
IOException - In case closing fails.public void verify()
throws UnsatisfiedExpectationException
UnsatisfiedExpectationException - In case we got unexpected requests or we did not get all requests we expected.public void setNoMatchFoundResponseCode(int code)
code - HTTP response code to return when no matching response is found.public void setExceptionResponseCode(int code)
code - HTTP response code to return when an unexpected exception happens.Copyright © 2014. All Rights Reserved.