diff options
Diffstat (limited to 'src/lib/http/tests')
-rw-r--r-- | src/lib/http/tests/client_mt_unittests.cc | 16 | ||||
-rw-r--r-- | src/lib/http/tests/connection_pool_unittests.cc | 4 | ||||
-rw-r--r-- | src/lib/http/tests/server_client_unittests.cc | 76 | ||||
-rw-r--r-- | src/lib/http/tests/test_http_client.h | 16 | ||||
-rw-r--r-- | src/lib/http/tests/tls_client_unittests.cc | 54 | ||||
-rw-r--r-- | src/lib/http/tests/tls_server_unittests.cc | 57 |
6 files changed, 111 insertions, 112 deletions
diff --git a/src/lib/http/tests/client_mt_unittests.cc b/src/lib/http/tests/client_mt_unittests.cc index b68c88572b..bb39f68e14 100644 --- a/src/lib/http/tests/client_mt_unittests.cc +++ b/src/lib/http/tests/client_mt_unittests.cc @@ -196,7 +196,7 @@ public: /// @brief Constructor. MultiThreadingHttpClientTest() - : io_service_(), client_(), listener_(), factory_(), listeners_(), factories_(), + : io_service_(new IOService()), client_(), listener_(), factory_(), listeners_(), factories_(), test_timer_(io_service_), num_threads_(0), num_batches_(0), num_listeners_(0), expected_requests_(0), num_in_progress_(0), num_finished_(0), paused_(false), pause_cnt_(0) { @@ -229,7 +229,7 @@ public: if (fail_on_timeout) { ADD_FAILURE() << "Timeout occurred while running the test!"; } - io_service_.stop(); + io_service_->stop(); } /// @brief Runs the test's IOService until the desired number of requests @@ -237,10 +237,10 @@ public: void runIOService(size_t request_limit) { while (getRRCount() < request_limit) { // Always call reset() before we call run(); - io_service_.restart(); + io_service_->restart(); // Run until a client stops the service. - io_service_.run(); + io_service_->run(); } } @@ -354,7 +354,7 @@ public: num_in_progress_ = 0; test_cv_.notify_all(); // Stop the test's IOService. - io_service_.stop(); + io_service_->stop(); } else { // I'm done but others aren't wait here. bool ret = test_cv_.wait_for(lck, std::chrono::seconds(10), @@ -410,8 +410,8 @@ public: std::unique_lock<std::mutex> lck(test_mutex_); clientRRs_.push_back(clientRR); ++num_finished_; - if ((num_finished_ >= expected_requests_) && !io_service_.stopped()) { - io_service_.stop(); + if ((num_finished_ >= expected_requests_) && !io_service_->stopped()) { + io_service_->stop(); } } @@ -773,7 +773,7 @@ public: } /// @brief IO service used in the tests. - IOService io_service_; + IOServicePtr io_service_; /// @brief Instance of the client used in the tests. HttpClientPtr client_; diff --git a/src/lib/http/tests/connection_pool_unittests.cc b/src/lib/http/tests/connection_pool_unittests.cc index b8337c3d36..d6267a0e14 100644 --- a/src/lib/http/tests/connection_pool_unittests.cc +++ b/src/lib/http/tests/connection_pool_unittests.cc @@ -105,7 +105,7 @@ public: /// @brief Constructor. HttpConnectionPoolTest() - : io_service_(), + : io_service_(new IOService()), acceptor_(new HttpAcceptor(io_service_)), connection_pool_(), response_creator_(new TestHttpResponseCreator()) { @@ -216,7 +216,7 @@ public: ASSERT_EQ(1, pool.hasConnection(conn1)); } - IOService io_service_; ///< IO service. + IOServicePtr io_service_; ///< IO service. HttpAcceptorPtr acceptor_; ///< Test acceptor. HttpConnectionPool connection_pool_; ///< Test connection pool. HttpResponseCreatorPtr response_creator_; ///< Test response creator. diff --git a/src/lib/http/tests/server_client_unittests.cc b/src/lib/http/tests/server_client_unittests.cc index 47a23625db..6572e8381a 100644 --- a/src/lib/http/tests/server_client_unittests.cc +++ b/src/lib/http/tests/server_client_unittests.cc @@ -208,7 +208,7 @@ template<typename HttpConnectionType> class HttpListenerImplCustom : public HttpListenerImpl { public: - HttpListenerImplCustom(IOService& io_service, + HttpListenerImplCustom(const IOServicePtr& io_service, const IOAddress& server_address, const unsigned short server_port, const TlsContextPtr& tls_context, @@ -270,7 +270,7 @@ public: /// /// @throw HttpListenerError when any of the specified parameters is /// invalid. - HttpListenerCustom(IOService& io_service, + HttpListenerCustom(const IOServicePtr& io_service, const IOAddress& server_address, const unsigned short server_port, const TlsContextPtr& tls_context, @@ -308,7 +308,7 @@ public: /// @param request_timeout Configured timeout for a HTTP request. /// @param idle_timeout Timeout after which persistent HTTP connection is /// closed by the server. - HttpConnectionLongWriteBuffer(IOService& io_service, + HttpConnectionLongWriteBuffer(const IOServicePtr& io_service, const HttpAcceptorPtr& acceptor, const TlsContextPtr& tls_context, HttpConnectionPool& connection_pool, @@ -355,7 +355,7 @@ public: /// @param request_timeout Configured timeout for a HTTP request. /// @param idle_timeout Timeout after which persistent HTTP connection is /// closed by the server. - HttpConnectionTransactionChange(IOService& io_service, + HttpConnectionTransactionChange(const IOServicePtr& io_service, const HttpAcceptorPtr& acceptor, const TlsContextPtr& tls_context, HttpConnectionPool& connection_pool, @@ -399,7 +399,7 @@ public: /// /// Starts test timer which detects timeouts. HttpListenerTest() - : io_service_(), factory_(new TestHttpResponseCreatorFactory()), + : io_service_(new IOService()), factory_(new TestHttpResponseCreatorFactory()), test_timer_(io_service_), run_io_service_timer_(io_service_), clients_() { test_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler, this, true), TEST_TIMEOUT, IntervalTimer::ONE_SHOT); @@ -435,7 +435,7 @@ public: if (fail_on_timeout) { ADD_FAILURE() << "Timeout occurred while running the test!"; } - io_service_.stop(); + io_service_->stop(); } /// @brief Runs IO service with optional timeout. @@ -443,16 +443,16 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran. void runIOService(long timeout = 0) { - io_service_.restart(); + io_service_->restart(); if (timeout > 0) { run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler, this, false), timeout, IntervalTimer::ONE_SHOT); } - io_service_.run(); - io_service_.restart(); - io_service_.poll(); + io_service_->run(); + io_service_->restart(); + io_service_->poll(); } /// @brief Returns HTTP OK response expected by unit tests. @@ -554,7 +554,7 @@ public: } /// @brief IO service used in the tests. - IOService io_service_; + IOServicePtr io_service_; /// @brief Pointer to the response creator factory. HttpResponseCreatorFactoryPtr factory_; @@ -593,7 +593,7 @@ TEST_F(HttpListenerTest, listen) { EXPECT_EQ(httpOk(HttpVersion::HTTP_11()), client->getResponse()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } @@ -645,7 +645,7 @@ TEST_F(HttpListenerTest, keepAlive) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that persistent HTTP connection is established by default @@ -694,7 +694,7 @@ TEST_F(HttpListenerTest, persistentConnection) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that "keep-alive" connection is closed by the server after @@ -753,7 +753,7 @@ TEST_F(HttpListenerTest, keepAliveTimeout) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that persistent connection is closed by the server after @@ -810,7 +810,7 @@ TEST_F(HttpListenerTest, persistentConnectionTimeout) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that HTTP/1.1 connection remains open even if there is an @@ -863,7 +863,7 @@ TEST_F(HttpListenerTest, persistentConnectionBadBody) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that the HTTP listener can't be started twice. @@ -938,7 +938,7 @@ TEST_F(HttpListenerTest, invalidIdleTimeout) { // This test verifies that listener can't be bound to the port to which // other server is bound. TEST_F(HttpListenerTest, addressInUse) { - tcp::acceptor acceptor(io_service_.getInternalIOService()); + tcp::acceptor acceptor(io_service_->getInternalIOService()); // Use other port than SERVER_PORT to make sure that this TCP connection // doesn't affect subsequent tests. tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS), @@ -1021,7 +1021,7 @@ public: listener_.stop(); listener2_.stop(); listener3_.stop(); - io_service_.poll(); + io_service_->poll(); MultiThreadingMgr::instance().setMode(false); } @@ -1076,7 +1076,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_FALSE(ec); })); @@ -1090,7 +1090,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_FALSE(ec); })); @@ -1137,7 +1137,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_FALSE(ec); })); @@ -1151,7 +1151,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_FALSE(ec); })); @@ -1193,7 +1193,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -1209,7 +1209,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -1250,7 +1250,7 @@ public: request1, response1, [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); EXPECT_FALSE(ec); })); @@ -1273,7 +1273,7 @@ public: request2, response2, [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); EXPECT_FALSE(ec); })); @@ -1306,7 +1306,7 @@ public: [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); // The server should have returned an IO error. EXPECT_TRUE(ec); })); @@ -1339,7 +1339,7 @@ public: [this](const boost::system::error_code& ec, const HttpResponsePtr& response, const std::string& parsing_error) { - io_service_.stop(); + io_service_->stop(); // There should be no IO error (answer from the server is received). EXPECT_FALSE(ec); // The response object is NULL because it couldn't be finalized. @@ -1380,7 +1380,7 @@ public: const HttpResponsePtr& response, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } // In this particular case we know exactly the type of the // IO error returned, because the client explicitly sets this @@ -1408,7 +1408,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } })); @@ -1439,7 +1439,7 @@ public: const HttpResponsePtr& response, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } // In this particular case we know exactly the type of the // IO error returned, because the client explicitly sets this @@ -1466,7 +1466,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } })); @@ -1560,7 +1560,7 @@ public: [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); // Everything should be ok. EXPECT_TRUE(ec.value() == 0); @@ -1596,7 +1596,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_FALSE(ec); @@ -1616,7 +1616,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_FALSE(ec); }, @@ -1691,7 +1691,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num == 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_EQ(1, monitor.connect_cnt_); // We should have 1 connect. @@ -1751,7 +1751,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num == 1) { - io_service_.stop(); + io_service_->stop(); } EXPECT_EQ(2, monitor.connect_cnt_); // We should have 1 connect. diff --git a/src/lib/http/tests/test_http_client.h b/src/lib/http/tests/test_http_client.h index 3b164756f1..55568a9ad9 100644 --- a/src/lib/http/tests/test_http_client.h +++ b/src/lib/http/tests/test_http_client.h @@ -31,10 +31,10 @@ public: /// @param io_service IO service to be stopped on error or completion. /// @param server_address string containing the IP address of the server. /// @param port port number of the server. - explicit TestHttpClient(IOService& io_service, + explicit TestHttpClient(const IOServicePtr& io_service, const std::string& server_address = "127.0.0.1", uint16_t port = 18123) - : io_service_(io_service.getInternalIOService()), socket_(io_service_), + : io_service_(io_service), socket_(io_service_->getInternalIOService()), buf_(), response_(), server_address_(server_address), server_port_(port), receive_done_(false) { } @@ -65,7 +65,7 @@ public: if (ec.value() != boost::asio::error::in_progress) { ADD_FAILURE() << "error occurred while connecting: " << ec.message(); - io_service_.stop(); + io_service_->stop(); return; } } @@ -100,7 +100,7 @@ public: } else { ADD_FAILURE() << "error occurred while connecting: " << ec.message(); - io_service_.stop(); + io_service_->stop(); return; } } @@ -143,7 +143,7 @@ public: // Error occurred, bail... ADD_FAILURE() << "error occurred while receiving HTTP" " response from the server: " << ec.message(); - io_service_.stop(); + io_service_->stop(); } } @@ -156,7 +156,7 @@ public: // expecting. if (response_.find("\r\n\r\n", 0) != std::string::npos) { receive_done_ = true; - io_service_.stop(); + io_service_->stop(); } else { receivePartialResponse(); } @@ -245,8 +245,8 @@ public: private: - /// @brief Holds reference to the IO service. - boost::asio::io_service& io_service_; + /// @brief Holds pointer to the IO service. + isc::asiolink::IOServicePtr io_service_; /// @brief A socket used for the connection. boost::asio::ip::tcp::socket socket_; diff --git a/src/lib/http/tests/tls_client_unittests.cc b/src/lib/http/tests/tls_client_unittests.cc index 8874214421..4309a87456 100644 --- a/src/lib/http/tests/tls_client_unittests.cc +++ b/src/lib/http/tests/tls_client_unittests.cc @@ -227,7 +227,7 @@ public: /// /// Starts test timer which detects timeouts. HttpListenerTest() - : io_service_(), factory_(new TestHttpResponseCreatorFactory()), + : io_service_(new IOService()), factory_(new TestHttpResponseCreatorFactory()), test_timer_(io_service_), run_io_service_timer_(io_service_) { test_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler, this, true), TEST_TIMEOUT, IntervalTimer::ONE_SHOT); @@ -242,7 +242,7 @@ public: if (fail_on_timeout) { ADD_FAILURE() << "Timeout occurred while running the test!"; } - io_service_.stop(); + io_service_->stop(); } /// @brief Runs IO service with optional timeout. @@ -250,20 +250,20 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran (ms). void runIOService(long timeout = 0) { - io_service_.restart(); + io_service_->restart(); if (timeout > 0) { run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler, this, false), timeout, IntervalTimer::ONE_SHOT); } - io_service_.run(); - io_service_.restart(); - io_service_.poll(); + io_service_->run(); + io_service_->restart(); + io_service_->poll(); } /// @brief IO service used in the tests. - IOService io_service_; + IOServicePtr io_service_; /// @brief Pointer to the response creator factory. HttpResponseCreatorFactoryPtr factory_; @@ -315,7 +315,7 @@ public: listener_->stop(); listener2_->stop(); listener3_->stop(); - io_service_.poll(); + io_service_->poll(); MultiThreadingMgr::instance().setMode(false); HttpRequest::recordSubject_ = false; HttpRequest::recordIssuer_ = false; @@ -372,7 +372,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -388,7 +388,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -437,7 +437,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -453,7 +453,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -501,7 +501,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -517,7 +517,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -562,7 +562,7 @@ public: request1, response1, [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); } @@ -587,7 +587,7 @@ public: request2, response2, [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); } @@ -622,7 +622,7 @@ public: [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); // The server should have returned an IO error. if (!ec) { ADD_FAILURE() << "asyncSendRequest didn't fail"; @@ -657,7 +657,7 @@ public: [this](const boost::system::error_code& ec, const HttpResponsePtr& response, const std::string& parsing_error) { - io_service_.stop(); + io_service_->stop(); // There should be no IO error (answer from the server is received). if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -700,7 +700,7 @@ public: const HttpResponsePtr& response, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } // In this particular case we know exactly the type of the // IO error returned, because the client explicitly sets this @@ -728,7 +728,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } })); @@ -759,7 +759,7 @@ public: const HttpResponsePtr& response, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } // In this particular case we know exactly the type of the // IO error returned, because the client explicitly sets this @@ -786,7 +786,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++cb_num > 1) { - io_service_.stop(); + io_service_->stop(); } })); @@ -880,7 +880,7 @@ public: [this](const boost::system::error_code& ec, const HttpResponsePtr&, const std::string&) { - io_service_.stop(); + io_service_->stop(); // Everything should be ok. if (ec) { @@ -918,7 +918,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { @@ -940,7 +940,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num > 1) { - io_service_.stop(); + io_service_->stop(); } if (ec) { ADD_FAILURE() << "asyncSendRequest failed: " << ec.message(); @@ -1017,7 +1017,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num == 1) { - io_service_.stop(); + io_service_->stop(); } // We should have 1 connect. @@ -1084,7 +1084,7 @@ public: const HttpResponsePtr&, const std::string&) { if (++resp_num == 1) { - io_service_.stop(); + io_service_->stop(); } // We should have 1 connect. diff --git a/src/lib/http/tests/tls_server_unittests.cc b/src/lib/http/tests/tls_server_unittests.cc index f5c592ce6b..db788ce56f 100644 --- a/src/lib/http/tests/tls_server_unittests.cc +++ b/src/lib/http/tests/tls_server_unittests.cc @@ -212,7 +212,7 @@ template<typename HttpConnectionType> class HttpListenerImplCustom : public HttpListenerImpl { public: - HttpListenerImplCustom(IOService& io_service, + HttpListenerImplCustom(const IOServicePtr& io_service, const IOAddress& server_address, const unsigned short server_port, const TlsContextPtr& tls_context, @@ -276,7 +276,7 @@ public: /// /// @throw HttpListenerError when any of the specified parameters is /// invalid. - HttpListenerCustom(IOService& io_service, + HttpListenerCustom(const IOServicePtr& io_service, const IOAddress& server_address, const unsigned short server_port, const TlsContextPtr& tls_context, @@ -314,7 +314,7 @@ public: /// @param request_timeout Configured timeout for a HTTP request. /// @param idle_timeout Timeout after which persistent HTTP connection is /// closed by the server. - HttpConnectionLongWriteBuffer(IOService& io_service, + HttpConnectionLongWriteBuffer(const IOServicePtr& io_service, const HttpAcceptorPtr& acceptor, const TlsContextPtr& tls_context, HttpConnectionPool& connection_pool, @@ -361,7 +361,7 @@ public: /// @param request_timeout Configured timeout for a HTTP request. /// @param idle_timeout Timeout after which persistent HTTP connection is /// closed by the server. - HttpConnectionTransactionChange(IOService& io_service, + HttpConnectionTransactionChange(const IOServicePtr& io_service, const HttpAcceptorPtr& acceptor, const TlsContextPtr& tls_context, HttpConnectionPool& connection_pool, @@ -406,10 +406,9 @@ public: /// /// @param io_service IO service to be stopped on error. /// @param tls_context TLS context. - TestHttpClient(IOService& io_service, TlsContextPtr tls_context) - : io_service_(io_service.getInternalIOService()), - stream_(io_service_, tls_context->getContext()), - buf_(), response_() { + TestHttpClient(const IOServicePtr& io_service, TlsContextPtr tls_context) + : io_service_(io_service), stream_(io_service_->getInternalIOService(), + tls_context->getContext()), buf_(), response_() { } /// @brief Destructor. @@ -438,7 +437,7 @@ public: if (ec.value() != boost::asio::error::in_progress) { ADD_FAILURE() << "error occurred while connecting: " << ec.message(); - io_service_.stop(); + io_service_->stop(); return; } } @@ -447,7 +446,7 @@ public: if (ec) { ADD_FAILURE() << "error occurred during handshake: " << ec.message(); - io_service_.stop(); + io_service_->stop(); return; } sendRequest(request); @@ -483,7 +482,7 @@ public: } else { ADD_FAILURE() << "error occurred while connecting: " << ec.message(); - io_service_.stop(); + io_service_->stop(); return; } } @@ -526,7 +525,7 @@ public: // Error occurred, bail... ADD_FAILURE() << "error occurred while receiving HTTP" " response from the server: " << ec.message(); - io_service_.stop(); + io_service_->stop(); } } @@ -538,7 +537,7 @@ public: // Two consecutive new lines end the part of the response we're // expecting. if (response_.find("\r\n\r\n", 0) != std::string::npos) { - io_service_.stop(); + io_service_->stop(); } else { receivePartialResponse(); @@ -620,8 +619,8 @@ public: private: - /// @brief Holds reference to the IO service. - boost::asio::io_service& io_service_; + /// @brief Holds pointer to the IO service. + isc::asiolink::IOServicePtr io_service_; /// @brief A socket used for the connection. TlsStreamImpl stream_; @@ -644,7 +643,7 @@ public: /// /// Starts test timer which detects timeouts. HttpsListenerTest() - : io_service_(), factory_(new TestHttpResponseCreatorFactory()), + : io_service_(new IOService()), factory_(new TestHttpResponseCreatorFactory()), test_timer_(io_service_), run_io_service_timer_(io_service_), clients_(), server_context_(), client_context_() { configServer(server_context_); @@ -684,7 +683,7 @@ public: if (fail_on_timeout) { ADD_FAILURE() << "Timeout occurred while running the test!"; } - io_service_.stop(); + io_service_->stop(); } /// @brief Runs IO service with optional timeout. @@ -692,16 +691,16 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran. void runIOService(long timeout = 0) { - io_service_.restart(); + io_service_->restart(); if (timeout > 0) { run_io_service_timer_.setup(std::bind(&HttpsListenerTest::timeoutHandler, this, false), timeout, IntervalTimer::ONE_SHOT); } - io_service_.run(); - io_service_.restart(); - io_service_.poll(); + io_service_->run(); + io_service_->restart(); + io_service_->poll(); } /// @brief Returns HTTP OK response expected by unit tests. @@ -803,7 +802,7 @@ public: } /// @brief IO service used in the tests. - IOService io_service_; + IOServicePtr io_service_; /// @brief Pointer to the response creator factory. HttpResponseCreatorFactoryPtr factory_; @@ -848,7 +847,7 @@ TEST_F(HttpsListenerTest, listen) { EXPECT_EQ(httpOk(HttpVersion::HTTP_11()), client->getResponse()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } @@ -900,7 +899,7 @@ TEST_F(HttpsListenerTest, keepAlive) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that persistent HTTP connection is established by default @@ -949,7 +948,7 @@ TEST_F(HttpsListenerTest, persistentConnection) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that "keep-alive" connection is closed by the server after @@ -1008,7 +1007,7 @@ TEST_F(HttpsListenerTest, keepAliveTimeout) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that persistent connection is closed by the server after @@ -1065,7 +1064,7 @@ TEST_F(HttpsListenerTest, persistentConnectionTimeout) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that HTTP/1.1 connection remains open even if there is an @@ -1118,7 +1117,7 @@ TEST_F(HttpsListenerTest, persistentConnectionBadBody) { EXPECT_TRUE(client->isConnectionClosed()); listener.stop(); - io_service_.poll(); + io_service_->poll(); } // This test verifies that the HTTP listener can't be started twice. @@ -1193,7 +1192,7 @@ TEST_F(HttpsListenerTest, invalidIdleTimeout) { // This test verifies that listener can't be bound to the port to which // other server is bound. TEST_F(HttpsListenerTest, addressInUse) { - tcp::acceptor acceptor(io_service_.getInternalIOService()); + tcp::acceptor acceptor(io_service_->getInternalIOService()); // Use other port than SERVER_PORT to make sure that this TCP connection // doesn't affect subsequent tests. tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS), |