Request MethodΒΆ
The following assertions can be performed on request
variable offered by the Touchstone Rules-Engine.
They would validate the request method. These assertions would make sense in Peer-to-Peer testing.
assertRequestMethodEquals(expectedValue)
Asserts that the method of the request matches the provided expectedValue
Example:
request.assertRequestMethodEquals("GET")
Equivalent to these:
assertRequestMethodEquals("GET", request)
// expected method and operator can be passed as parameters from test script. assertRequestMethod("GET", "equals", request)
assert request.getMethod()=="GET": "The actual value \""+request.getMethod()+"\" did not match the expected value \"GET\" for HTTP method in request"
assert equals("GET", request.getMethod()): "The actual value \""+request.getMethod()+"\" did not match the expected value \"GET\" for HTTP method in request"
assertRequestMethodNotEquals(expectedValue)
Asserts that the method of the request does not match the provided expectedValue
Example:
request.assertRequestMethodNotEquals("PUT")
Equivalent to these:
assertRequestMethodNotEquals("PUT", request)
// expected method and operator can be passed as parameters from test script. assertRequestMethod("PUT", "notEquals", request)
assert request.getMethod()!="PUT": "The actual value \""+request.getMethod()+"\" matched the expected value \"PUT\" for HTTP method with operator 'notEquals' in request"
assert notEquals("PUT", request.getMethod()): "The actual value \""+request.getMethod() +"\" matched the expected value \"PUT\" for HTTP method with operator 'notEquals' in request"
assertRequestMethodIn(expectedValues)
Asserts that the method of the request is one of the provided expectedValues where each value is separated by a comma.
Example:
request.assertRequestMethodIn("POST, PUT")
Equivalent to these:
assertRequestMethodIn("POST, PUT", request)
// expected method and operator can be passed as parameters from test script. assertRequestMethod("POST, PUT", "in", request)
assert request.getMethod() in ["GET, PUT"]: "Expected one of the values in [GET, PUT] for HTTP method but encountered \""+request.getMethod()+"\" in request"
assert isIn("GET, PUT", request.getMethod()): "Expected one of the values in [GET, PUT] for HTTP method but encountered \""+request.getMethod()+"\" in request"
assertRequestMethodNotIn(expectedValues)
Asserts that the method of the request is none of the provided expectedValues where each value is separated by a comma.
Example:
request.assertRequestMethodNotIn("POST, PUT")
Equivalent to these:
assertRequestMethodNotIn("POST, PUT", request)
// expected method and operator can be passed as parameters from test script. assertRequestMethod("POST, PUT", "notIn", request)
assert !(request.getMethod() in ["POST", "PUT"]): "Expected none of the values in [POST, PUT] for HTTP method but encountered \""+request.getMethod()+"\" with operator 'notIn' in request"
assert isNotIn("POST, PUT", request.getMethod()): "Expected none of the values in [POST, PUT] for HTTP method but encountered \""+request.getMethod()+"\" with operator 'notIn' in request"