// Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) // Copyright (c) 2005-2007 Hartmut Kaiser (hartmut.kaiser@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include "test_saga.hpp" namespace test_stream { /////////////////////////////////////////////////////////////////////////// void test_get_url() { saga::session s; // reload adaptors with new environment settings std::string url_1; std::string url_2; std::string url_3; std::string url_4; saga::task t_1; saga::task t_2; saga::task t_3; { saga::stream s1 ("tcp://localhost:1234/", s); saga::stream s2 ("tcp://localhost:2345/", s); saga::stream s3 ("tcp://localhost:3456/", s); saga::stream s4 ("tcp://localhost:4567/", s); url_1 = s1.get_url ( ); t_1 = s2.get_url (url_2); t_2 = s3.get_url (url_3); t_3 = s4.get_url (url_4); } t_3.run (); t_2.wait (); t_3.wait (); BOOST_CHECK_EQUAL(url_1, "tcp://localhost:1234/"); BOOST_CHECK_EQUAL(url_2, "tcp://localhost:2345/"); BOOST_CHECK_EQUAL(url_3, "tcp://localhost:3456/"); BOOST_CHECK_EQUAL(url_4, "tcp://localhost:4567/"); } void get_url() { // test with both (sync/async) adaptor supplied implementations available prep_environment env1("SAGA_RUN_SYNC", "1"); prep_environment env2("SAGA_RUN_ASYNC", "1"); test_get_url(); } void sync_get_url() { // test with sync adaptor supplied implementations available prep_environment env("SAGA_RUN_SYNC", "1"); test_get_url(); } void async_get_url() { // test with async adaptor supplied implementations available test_get_url(); } /////////////////////////////////////////////////////////////////////////// void test_status() { saga::session s; // reload adaptors with new environment settings saga::stream::state state1; saga::stream::state state2; saga::stream::state state3; saga::stream::state state4; saga::task t_1; saga::task t_2; saga::task t_3; { saga::stream s1 ("tcp://localhost:1234/", s); saga::stream s2 ("tcp://localhost:2345/", s); saga::stream s3 ("tcp://localhost:3456/", s); saga::stream s4 ("tcp://localhost:4567/", s); state1 = s1.status ( ); t_1 = s2.status (state2); t_2 = s3.status (state3); t_3 = s4.status (state4); } t_3.run (); t_2.wait (); t_3.wait (); BOOST_CHECK_EQUAL(state1, saga::stream_base::NotConnected); BOOST_CHECK_EQUAL(state2, saga::stream_base::NotConnected); BOOST_CHECK_EQUAL(state3, saga::stream_base::NotConnected); BOOST_CHECK_EQUAL(state4, saga::stream_base::NotConnected); } void status() { // test with both (sync/async) adaptor supplied implementations available prep_environment env1("SAGA_RUN_SYNC", "1"); prep_environment env2("SAGA_RUN_ASYNC", "1"); test_status(); } void sync_status() { // test with sync adaptor supplied implementations available prep_environment env("SAGA_RUN_SYNC", "1"); test_status(); } void async_status() { // test with async adaptor supplied implementations available prep_environment env2("SAGA_RUN_ASYNC", "1"); test_status(); } /////////////////////////////////////////////////////////////////////////// class suite : public test_suite { public: suite () : test_suite ("stream test suite") { ///////////////////////////////////////////////////////////////////// // get_url add (BOOST_TEST_CASE (&get_url)); add (BOOST_TEST_CASE (&sync_get_url)); add (BOOST_TEST_CASE (&async_get_url)); ///////////////////////////////////////////////////////////////////// // get_url add (BOOST_TEST_CASE (&status)); add (BOOST_TEST_CASE (&sync_status)); add (BOOST_TEST_CASE (&async_status)); } }; }