| 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.
|
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.
|
protected void |
sendResponseInExchange(HttpResponse response,
org.apache.camel.Exchange exchange)
Send the response in Camel exchange.
|
void |
setServiceThreadsNumber(int serviceThreadsNumber)
Sets threads number to concurrently service incoming requests.
|
void |
start()
Start the spy server.
|
void |
stop()
Stop the spy server.
|
HttpSpy |
testPlan(TestPlanBuilder testPlanBuilder)
Specify test plan.
|
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 testPlan(TestPlanBuilder testPlanBuilder)
HttpSpypublic void start()
HttpSpyAfter start the spy server services client requests.
protected org.apache.camel.Processor createSpyProcessor()
IllegalStateException - Test plan is not set.protected void sendResponseInExchange(HttpResponse response, org.apache.camel.Exchange exchange) throws InterruptedException
This implementation sends response body in platform default encoding.
If the response has multiple headers with the same name, then this method follows RFC 2616, Section 4.2 Message Headers: combine all values into one string of comma-separated values.
response - The response to send.exchange - Send the response as Out message within this exchange
object. Out message allows to drop all headers came with In message.NullPointerException - response is null, exchange is null.InterruptedException - Interrupted while waiting the delay,
specified for the response.HttpResponse.getDelayMillis()public void verify()
HttpSpyThis method delegates verification to the test plan.
verify in interface HttpSpyHttpSpy.testPlan(com.github.tashoyan.httpspy.TestPlanBuilder)public void reset()
HttpSpyThe spy server resets its current test plan.
reset in interface HttpSpyHttpSpy.testPlan(com.github.tashoyan.httpspy.TestPlanBuilder)Copyright © 2016. All rights reserved.