1 #include <boost/test/unit_test.hpp>
3 #include "utilities/osc_server.hpp"
4 #include "nova-tt/semaphore.hpp"
10 struct osc_test_responder
:
13 osc_test_responder(void):
17 void run(osc::ReceivedMessageArgumentIterator begin
,
18 osc::ReceivedMessageArgumentIterator
const & end
)
29 BOOST_AUTO_TEST_CASE( network_thread_test
)
31 network_thread thread
;
34 BOOST_AUTO_TEST_CASE( osc_server_test_1
)
36 osc_server
server(12321);
39 BOOST_AUTO_TEST_CASE( osc_server_test_2
)
41 osc_server
server(12321);
42 std::auto_ptr
<osc_test_responder
> resp (new osc_test_responder());
43 server
.add_responder("/foo", resp
.get());
44 server
.remove_responder("/foo", resp
.get());
47 BOOST_AUTO_TEST_CASE( osc_server_test_3
)
49 std::auto_ptr
<osc_test_responder
> resp (new osc_test_responder());
51 osc_server
server(12321);
53 server
.add_responder("/foo", resp
.get());
56 using namespace boost::asio::ip
;
58 boost::asio::io_service io_service
;
60 udp::resolver
resolver(io_service
);
61 udp::resolver::query
query(udp::v4(), "localhost", "12321");
62 udp::endpoint receiver_endpoint
= *resolver
.resolve(query
);
64 udp::socket
socket(io_service
);
65 socket
.open(udp::v4());
66 socket
.send_to(boost::asio::buffer("/foo\0\0\0", 8), receiver_endpoint
);
71 server
.remove_responder("/foo", resp
.get());
74 BOOST_REQUIRE_EQUAL(resp
->i
, 1);