1 #include <boost/test/unit_test.hpp>
3 #include "utilities/osc_server.hpp"
4 #include "nova-tt/semaphore.hpp"
9 struct osc_test_responder
:
12 osc_test_responder(void):
16 void run(osc::ReceivedMessageArgumentIterator begin
,
17 osc::ReceivedMessageArgumentIterator
const & end
)
28 BOOST_AUTO_TEST_CASE( network_thread_test
)
30 network_thread thread
;
33 BOOST_AUTO_TEST_CASE( osc_server_test_1
)
35 osc_server
server(12321);
38 BOOST_AUTO_TEST_CASE( osc_server_test_2
)
40 osc_server
server(12321);
41 std::unique_ptr
<osc_test_responder
> resp (new osc_test_responder());
42 server
.add_responder("/foo", resp
.get());
43 server
.remove_responder("/foo", resp
.get());
46 BOOST_AUTO_TEST_CASE( osc_server_test_3
)
48 std::unique_ptr
<osc_test_responder
> resp (new osc_test_responder());
50 osc_server
server(12321);
52 server
.add_responder("/foo", resp
.get());
55 using namespace boost::asio::ip
;
57 boost::asio::io_service io_service
;
59 udp::resolver
resolver(io_service
);
60 udp::resolver::query
query(udp::v4(), "localhost", "12321");
61 udp::endpoint receiver_endpoint
= *resolver
.resolve(query
);
63 udp::socket
socket(io_service
);
64 socket
.open(udp::v4());
65 socket
.send_to(boost::asio::buffer("/foo\0\0\0", 8), receiver_endpoint
);
70 server
.remove_responder("/foo", resp
.get());
73 BOOST_REQUIRE_EQUAL(resp
->i
, 1);