@NotThreadSafe
public interface HttpSpy
This is an interface that defines behavior for implementations.
Concurrency notes. All HTTP Spy methods are expected to be called in
the only thread - typically main thread that executes a test.
However, an implementation has to provide concurrent access to some data
inside, for example the test plan: testPlan(com.github.tashoyan.httpspy.TestPlanBuilder).
| Modifier and Type | Method and Description |
|---|---|
String |
getHostname()
Gets host name.
|
String |
getPath()
Gets HTTP path.
|
int |
getPort()
Gets network port.
|
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.
|
HttpSpy |
testPlan(TestPlanBuilder testPlanBuilder)
Specify test plan.
|
void |
verify()
Verify that expectations are met.
|
String getHostname()
int getPort()
String getPath()
void setServiceThreadsNumber(int serviceThreadsNumber)
This 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.
serviceThreadsNumber - Number of threads that service requests.IllegalArgumentException - serviceThreadsNumber is not positive.IllegalArgumentException - serviceThreadsNumber is greater than
one, but current test plan does not support multiple service threads.IllegalStateException - The spy server has already started.int getServiceThreadsNumber()
HttpSpy testPlan(TestPlanBuilder testPlanBuilder)
testPlanBuilder - Builder that provides the test plan.NullPointerException - testPlanBuilder is null.IllegalStateException - Test plan is already set.IllegalArgumentException - New test plan does not support multiple
service threads, but service threads number is already set greater than
one.void start()
After start the spy server services client requests.
IllegalStateException - Already started.void verify()
This method delegates verification to the test plan.
IllegalStateException - Test plan is not settestPlan(com.github.tashoyan.httpspy.TestPlanBuilder)void reset()
The spy server resets its current test plan.
void stop()
The spy server stops servicing client requests and frees network resources.
Copyright © 2016. All rights reserved.