28#define BOOST_TEST_MODULE transport_asio_timers
29#include <boost/test/unit_test.hpp>
50#include <boost/asio.hpp>
54 using boost::asio::ip::tcp;
57 boost::asio::io_service io_service;
58 tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v6(), port));
59 tcp::socket socket(io_service);
61 acceptor.accept(socket);
64 boost::system::error_code ec;
65 socket.read_some(boost::asio::buffer(data), ec);
66 if (ec == boost::asio::error::eof) {
73 }
catch (std::exception & e) {
74 std::cout << e.what() << std::endl;
75 }
catch (boost::system::error_code & ec) {
76 std::cout << ec.message() << std::endl;
82 boost::asio::io_service ios;
83 boost::asio::deadline_timer t(ios,boost::posix_time::milliseconds(
value));
84 boost::system::error_code ec;
86 BOOST_FAIL(
"Test timed out" );
109typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context>
context_ptr;
111 return context_ptr(
new boost::asio::ssl::context(boost::asio::ssl::context::sslv23));
122 websocketpp::lib::placeholders::_1));
129 BOOST_CHECK_EQUAL( ec, make_error_code(tls_handshake_timeout) );
131 base::cancel_socket();
151 BOOST_CHECK( uri->get_valid() );
152 BOOST_CHECK_EQUAL(
base::init(
m_con), websocketpp::lib::error_code() );
157 websocketpp::lib::bind(
161 websocketpp::lib::placeholders::_1
178 websocketpp::lib::thread dummy_server(websocketpp::lib::bind(&
run_dummy_server,9005));
179 websocketpp::lib::thread timer(websocketpp::lib::bind(&
run_test_timer,5000));
180 dummy_server.detach();
185 endpoint.
connect(
"wss://localhost:9005");
static const long timeout_socket_shutdown
websocketpp::http::parser::response response_type
static const long timeout_connect
static const long timeout_socket_post_init
websocketpp::log::stub alog_type
websocketpp::log::stub elog_type
static const long timeout_proxy
static const long timeout_dns_resolve
websocketpp::concurrency::none concurrency_type
static const long timeout_socket_pre_init
static const bool enable_multithreading
websocketpp::transport::asio::tls_socket::endpoint socket_type
Stub concurrency policy that implements the interface using no-ops.
Stores, parses, and manipulates HTTP requests.
Stores, parses, and manipulates HTTP responses.
Stub logger that ignores all input.
Asio based connection transport component.
void init(init_handler callback)
Initialize transport for reading.
Asio based endpoint transport component.
void async_connect(transport_con_ptr tcon, uri_ptr u, connect_handler cb)
Initiate a new connection.
void init_asio()
Initialize asio transport with internal io_service.
void init_logging(alog_type *a, elog_type *e)
Initialize logging.
std::size_t run()
wraps the run method of the internal io_service object
lib::error_code init(transport_con_ptr tcon)
Initialize a connection.
TLS enabled Asio endpoint socket component.
websocketpp::lib::shared_ptr< boost::asio::ssl::context > context_ptr
@ tls_handshake_timeout
TLS Handshake Timeout.
lib::error_code make_error_code(error::value e)
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
mock_con(bool a, config::alog_type &b, config::elog_type &c)
void handle_start(const websocketpp::lib::error_code &ec)
websocketpp::transport::asio::connection< config > base
void handle_connect(connection_ptr con, websocketpp::lib::error_code const &ec)
void connect(std::string u)
websocketpp::transport::asio::endpoint< config > base
static level const all
Special aggregate value representing "all levels".
void run_test_timer(long value)
context_ptr on_tls_init(websocketpp::connection_hdl)
BOOST_AUTO_TEST_CASE(tls_handshake_timeout)
websocketpp::lib::shared_ptr< boost::asio::ssl::context > context_ptr
void run_dummy_server(int port)
websocketpp::lib::shared_ptr< mock_con > connection_ptr
websocketpp::transport::asio::connection< config > con_type