@NotThreadSafe public class SequencePlan extends Object implements TestPlan
This test plan expects the system under test to send requests in a predefined sequence. If the system under test sends actual requests in a different sequence, then verification step indicates a failure.
Method getResponse(com.github.tashoyan.httpspy.HttpRequest) returns responses in the sequence defined during
the test plan build. The system under test may send more actual requests,
than the plan expects. In this case, method getResponse(com.github.tashoyan.httpspy.HttpRequest) returns a
special response with Internal server error status code for all extra
actual requests. Method createMissingResponse(com.github.tashoyan.httpspy.HttpRequest) can be overridden to
change this behavior. Finally, verification reports a failure.
Sequence check makes sense only when all requests are serviced by a single
thread in HTTP Spy. Therefore, SequencePlan can be used only with the
number of servicing threads set to 1.
Concurrency notes. As far as SequencePlan can be used only
with one servicing thread, it is not thread safe.
| Constructor and Description |
|---|
SequencePlan(List<RequestExpectation> requestExpectations,
List<HttpResponse> responses)
Creates new instance of the test plan.
|
| Modifier and Type | Method and Description |
|---|---|
protected HttpResponse |
createMissingResponse(HttpRequest actualRequest)
Creates a special response when the number of actual requests exceeds the
number of request expectations.
|
HttpResponse |
getResponse(HttpRequest actualRequest)
Gets a response for an actual request.
|
boolean |
isMultithreaded()
Checks if this test plan supports multiple service threads.
|
void |
verify()
Verifies actual requests against request expectations.
|
public SequencePlan(List<RequestExpectation> requestExpectations, List<HttpResponse> responses)
requestExpectations - The list of request expectations.responses - The list of responses on actual requests.NullPointerException - requestExpectations is null, responses is
null.IllegalArgumentException - requestExpectations is empty, responses
is empty, requestExpectations.size != responses.size.public HttpResponse getResponse(HttpRequest actualRequest)
TestPlangetResponse in interface TestPlanactualRequest - A request that has been received from the system
under test.protected HttpResponse createMissingResponse(HttpRequest actualRequest)
This implementation responds with Internal server error status
code.
actualRequest - Actual request.NullPointerException - actualRequest is null.public void verify()
TestPlanpublic final boolean isMultithreaded()
TestPlanisMultithreaded in interface TestPlantrue if multiple service threads can work with this test
plan.Copyright © 2016. All rights reserved.