| Modifier and Type | Field and Description |
|---|---|
protected static String |
DEFAULT_HOSTNAME
Default host name for the spy server.
|
protected static int |
DEFAULT_SERVICE_THREADS_NUMBER
Default service threads number.
|
| Constructor and Description |
|---|
CamelJettyHttpSpy(int port,
String path)
Creates new instance of spy server running on default host
DEFAULT_HOSTNAME. |
CamelJettyHttpSpy(String hostname,
int port,
String path)
Creates new instance of spy server.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.camel.Processor |
createSpyProcessor()
Creates Camel Processor that will be used to record actual requests and
send responses back.
|
HttpSpy |
expectRequests(RequestExpectationListBuilder builder)
Sets request expectation.
|
String |
getHostname()
Gets host name.
|
String |
getPath()
Gets HTTP path.
|
int |
getPort()
Gets network port.
|
protected int |
getRealJettyThreadsNumber()
Gets real number of threads that is necessary to be configured for Jetty
server.
|
int |
getServiceThreadsNumber()
Gets number of threads that concurrently service incoming requests.
|
void |
reset()
Reset the spy server.
|
void |
setServiceThreadsNumber(int serviceThreadsNumber)
Sets threads number to concurrently service incoming requests.
|
void |
start()
Start the spy server.
|
void |
stop()
Stop the spy server.
|
void |
verify()
Verify that expectations are met.
|
protected static final String DEFAULT_HOSTNAME
protected static final int DEFAULT_SERVICE_THREADS_NUMBER
getServiceThreadsNumber(),
Constant Field Valuespublic CamelJettyHttpSpy(int port,
String path)
DEFAULT_HOSTNAME.port - Network port where server will run.path - HTTP path where server will be available. If null or empty,
then default path / is used. Otherwise normalized path value is
used with leading and trailing slash characters:
/path/to/service/.IllegalArgumentException - port is negative.IllegalArgumentException - path contains illegal characters.public CamelJettyHttpSpy(String hostname, int port, String path)
TODO; Do we need this constructor as far as we run it always on localhost?
hostname - Host name where server will run.port - Network port where server will run.path - HTTP path where server will be available. If null or empty,
then default path / is used. Otherwise normalized path value is
used with leading and trailing slash characters:
/path/to/service/.NullPointerException - hostname is null.IllegalArgumentException - hostname is empty or blank.IllegalArgumentException - port is negative.IllegalArgumentException - path contains illegal characters.protected int getRealJettyThreadsNumber()
Calculate the number of threads to be configured in Jetty server in order
to guarantee that Jetty server provides at least
getServiceThreadsNumber() threads servicing client requests.
This method leverages the secret knowledge about Jetty: no more than 4
threads for acceptors, no more than 4 threads for selectors.
public String getHostname()
HttpSpygetHostname in interface HttpSpypublic int getPort()
HttpSpypublic void setServiceThreadsNumber(int serviceThreadsNumber)
HttpSpyThis method guarantees that at least the specified number of threads will be available to service client requests. Depending on server implementation, the real number of servicing threads may be greater.
setServiceThreadsNumber in interface HttpSpyserviceThreadsNumber - Number of threads that service requests.public int getServiceThreadsNumber()
HttpSpygetServiceThreadsNumber in interface HttpSpypublic HttpSpy expectRequests(RequestExpectationListBuilder builder)
HttpSpyexpectRequests in interface HttpSpybuilder - Builder for the list of request expectations.public void start()
HttpSpyAfter start the spy server services client requests.
protected org.apache.camel.Processor createSpyProcessor()
AssertionError - No response available for an actual requests. This
happens when the number of actual requests is greater, than the number of
expected requests and responses.public void verify()
HttpSpypublic void reset()
HttpSpyThe spy server resets all request expectations along with actual requests received and responses.
public void stop()
HttpSpyThe spy server stops servicing client requests and frees network resources. The spy server also resets itself.
stop in interface HttpSpyHttpSpy.reset()Copyright © 2016. All rights reserved.