public abstract class ResponsePattern extends Object
RestCall
.
Response patterns are applied to REST calls through the RestCall.responsePattern(ResponsePattern)
method.
RestCall.getResponseAsString()
or RestCall.getResponse(Class)
.
RestCall.getCapturedResponse()
since this method will not absorb the response for those other methods.
RestCall.successPattern(String)
and RestCall.failurePattern(String)
methods use instances
of this class to throw RestCallExceptions
when success patterns are not found or
failure patterns are found.
ResponsePattern
objects are reusable and thread-safe.
Constructor and Description |
---|
ResponsePattern(String pattern)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getPattern()
Returns the pattern passed in through the constructor.
|
void |
onMatch(RestCall rc,
Matcher m)
Instances can override this method to handle when a regular expression pattern matches on the output.
|
void |
onNoMatch(RestCall rc)
Instances can override this method to handle when a regular expression pattern doesn't match on the output.
|
public ResponsePattern(String pattern)
pattern
- Regular expression pattern.protected String getPattern()
public void onMatch(RestCall rc, Matcher m) throws RestCallException
This method is called once for every pattern match that occurs in the response text.
rc
- The RestCall
that this pattern finder is being used on.m
- The regular expression Matcher
. Can be used to retrieve group matches in the pattern.RestCallException
- Instances can throw an exception if a failure condition is detected.public void onNoMatch(RestCall rc) throws RestCallException
rc
- The RestCall
that this pattern finder is being used on.RestCallException
- Instances can throw an exception if a failure condition is detected.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.