Skip to content

Commit efd97fd

Browse files
committed
Adapting Server Constructor Test
This change gets the test building against the new server APIs. Next up, getting it linked.
1 parent a9a3c80 commit efd97fd

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

libs/network/test/http/server_constructor_test.cpp

+26-28
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace util = boost::network::utils;
1414

1515
struct dummy_sync_handler;
1616
struct dummy_async_handler;
17-
typedef http::server<dummy_sync_handler> sync_server;
17+
typedef http::sync_server<dummy_sync_handler> sync_server;
1818
typedef http::async_server<dummy_async_handler> async_server;
1919

2020
struct dummy_sync_handler {
@@ -38,47 +38,45 @@ BOOST_AUTO_TEST_CASE(minimal_constructor) {
3838
dummy_sync_handler sync_handler;
3939
dummy_async_handler async_handler;
4040
util::thread_pool pool;
41+
http::server_options options;
42+
options.address("127.0.0.1")
43+
.port("80");
4144

42-
BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler) );
43-
BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool) );
45+
BOOST_CHECK_NO_THROW(sync_server sync_instance(options, sync_handler) );
46+
BOOST_CHECK_NO_THROW(async_server async_instance(options, async_handler, pool) );
4447
}
4548

4649
BOOST_AUTO_TEST_CASE(with_io_service_parameter) {
4750
dummy_sync_handler sync_handler;
4851
dummy_async_handler async_handler;
4952
util::thread_pool pool;
5053
boost::asio::io_service io_service;
54+
http::server_options options;
55+
options.address("127.0.0.1")
56+
.port("80")
57+
.io_service(&io_service);
5158

52-
BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler, io_service));
53-
BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool, io_service));
59+
BOOST_CHECK_NO_THROW(sync_server sync_instance(options, sync_handler));
60+
BOOST_CHECK_NO_THROW(async_server async_instance(options, async_handler, pool));
5461
}
5562

5663
BOOST_AUTO_TEST_CASE(with_socket_options_parameter) {
5764
dummy_sync_handler sync_handler;
5865
dummy_async_handler async_handler;
5966
util::thread_pool pool;
67+
http::server_options options;
68+
options.address("127.0.0.1")
69+
.port("80")
70+
.reuse_address(true)
71+
.report_aborted(true)
72+
.receive_buffer_size(4096)
73+
.send_buffer_size(4096)
74+
.receive_low_watermark(1024)
75+
.send_low_watermark(1024)
76+
.non_blocking_io(true)
77+
.linger(true)
78+
.linger_timeout(0);
6079

61-
BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler,
62-
http::_reuse_address=true,
63-
http::_report_aborted=true,
64-
http::_receive_buffer_size=4096,
65-
http::_send_buffer_size=4096,
66-
http::_receive_low_watermark=1024,
67-
http::_send_low_watermark=1024,
68-
http::_non_blocking_io=true,
69-
http::_linger=true,
70-
http::_linger_timeout=0
71-
));
72-
BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool,
73-
http::_reuse_address=true,
74-
http::_report_aborted=true,
75-
http::_receive_buffer_size=4096,
76-
http::_send_buffer_size=4096,
77-
http::_receive_low_watermark=1024,
78-
http::_send_low_watermark=1024,
79-
http::_non_blocking_io=true,
80-
http::_linger=true,
81-
http::_linger_timeout=0
82-
));
83-
80+
BOOST_CHECK_NO_THROW(sync_server sync_instance(options, sync_handler));
81+
BOOST_CHECK_NO_THROW(async_server async_instance(options, async_handler, pool));
8482
}

0 commit comments

Comments
 (0)