public class JadlerRule extends org.junit.rules.ExternalResource implements JadlerConfiguration
Constructor and Description |
---|
JadlerRule()
Instructs Jadler to use a default stub server
JettyStubHttpServer
serving the http protocol listening on any free port. |
JadlerRule(int port)
Instructs Jadler to use a default stub server
JettyStubHttpServer
serving the http protocol listening on the given port. |
JadlerRule(StubHttpServer server)
Instructs Jadler to use use the given stub server instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |
JadlerRule |
withDefaultResponseContentType(String defaultContentType)
Defines a default content type of every stub http response.
|
JadlerRule |
withDefaultResponseEncoding(Charset defaultEncoding)
Defines a default encoding of every stub http response.
|
JadlerRule |
withDefaultResponseHeader(String name,
String value)
Defines a response header that will be sent in every http stub response.
|
JadlerRule |
withDefaultResponseStatus(int defaultStatus)
Sets the default http response status.
|
JadlerRule |
withRequestsRecordingDisabled()
Disables incoming http requests recording.
|
public JadlerRule()
JettyStubHttpServer
serving the http protocol listening on any free port.
See also Jadler.initJadler()
public JadlerRule(int port)
JettyStubHttpServer
serving the http protocol listening on the given port.
See also Jadler.initJadlerListeningOn(int)
port
- port the stub server should be listening on (must be bigger than 0)public JadlerRule(StubHttpServer server)
Jadler.initJadlerUsing(net.jadler.stubbing.server.StubHttpServer)
server
- stub server to useprotected void before()
before
in class org.junit.rules.ExternalResource
protected void after()
after
in class org.junit.rules.ExternalResource
public JadlerRule withDefaultResponseContentType(String defaultContentType)
ResponseStubbing#withContentType(java.lang.String)
)withDefaultResponseContentType
in interface JadlerConfiguration
defaultContentType
- default Content-Type
header of every http stub responsepublic JadlerRule withDefaultResponseEncoding(Charset defaultEncoding)
ResponseStubbing#withEncoding(java.nio.charset.Charset)
)withDefaultResponseEncoding
in interface JadlerConfiguration
defaultEncoding
- default stub response encodingpublic JadlerRule withDefaultResponseHeader(String name, String value)
withDefaultResponseHeader
in interface JadlerConfiguration
name
- name of the headervalue
- header valuepublic JadlerRule withDefaultResponseStatus(int defaultStatus)
ResponseStubbing#withStatus(int)
)withDefaultResponseStatus
in interface JadlerConfiguration
defaultStatus
- default http response statuspublic JadlerRule withRequestsRecordingDisabled()
Disables incoming http requests recording.
Jadler mocking (verification) capabilities are implemented by storing all incoming requests (including their
bodies). This could cause troubles in some very specific testing scenarios, for further explanation jump
straight to JadlerMocker.setRecordRequests(boolean)
.
Please note this method should be used very rarely and definitely should not be treated as a default.
withRequestsRecordingDisabled
in interface JadlerConfiguration
JadlerMocker.setRecordRequests(boolean)
Copyright © 2016. All Rights Reserved.