namespace {
/// @brief Test fixture class for @ref PostHttpRequest.
-typedef HttpRequestTestBase<PostHttpRequest> PostHttpRequestTest;
+class PostHttpRequestTest : public HttpRequestTestBase<PostHttpRequest> {
+public:
+
+ /// @brief Constructor.
+ PostHttpRequestTest()
+ : HttpRequestTestBase<PostHttpRequest>(),
+ json_body_("{ \"service\": \"dhcp4\", \"param1\": \"foo\" }") {
+ }
+
+ /// @brief Default value of the JSON body.
+ std::string json_body_;
+};
// This test verifies that PostHttpRequest class only accepts POST
// messages.
TEST_F(PostHttpRequestTest, requirePost) {
// Use a GET method that is not supported.
- setContextBasics("GET", "/isc/org", std::make_pair(1, 0));
+ setContextBasics("GET", "/isc/org", HttpVersion(1, 0));
addHeaderToContext("Content-Length", json_body_.length());
addHeaderToContext("Content-Type", "application/json");
ASSERT_THROW(request_.create(), HttpRequestError);
// Now use POST. It should be accepted.
- setContextBasics("POST", "/isc/org", std::make_pair(1, 0));
+ setContextBasics("POST", "/isc/org", HttpVersion(1, 0));
addHeaderToContext("Content-Length", json_body_.length());
addHeaderToContext("Content-Type", "application/json");
// header.
TEST_F(PostHttpRequestTest, requireContentType) {
// No "Content-Type". It should fail.
- setContextBasics("POST", "/isc/org", std::make_pair(1, 0));
+ setContextBasics("POST", "/isc/org", HttpVersion(1, 0));
addHeaderToContext("Content-Length", json_body_.length());
ASSERT_THROW(request_.create(), HttpRequestError);
// There is "Content-Type". It should pass.
- setContextBasics("POST", "/isc/org", std::make_pair(1, 0));
+ setContextBasics("POST", "/isc/org", HttpVersion(1, 0));
addHeaderToContext("Content-Length", json_body_.length());
addHeaderToContext("Content-Type", "text/html");
// header.
TEST_F(PostHttpRequestTest, requireContentLength) {
// No "Content-Length". It should fail.
- setContextBasics("POST", "/isc/org", std::make_pair(1, 0));
+ setContextBasics("POST", "/isc/org", HttpVersion(1, 0));
addHeaderToContext("Content-Type", "text/html");
ASSERT_THROW(request_.create(), HttpRequestError);
// There is "Content-Length". It should pass.
- setContextBasics("POST", "/isc/org", std::make_pair(1, 0));
+ setContextBasics("POST", "/isc/org", HttpVersion(1, 0));
addHeaderToContext("Content-Length", json_body_.length());
addHeaderToContext("Content-Type", "application/json");
}