{
}
+void handle_schedule1(
+ boost::thread::id thread_id,
+ l7vs::protocol_module_base::rs_list_itr_func_type inlist_begin,
+ l7vs::protocol_module_base::rs_list_itr_func_type inlist_end,
+ l7vs::protocol_module_base::rs_list_itr_next_func_type inlist_next,
+ boost::asio::ip::tcp::endpoint& outendpoint ){
+ outendpoint = boost::asio::ip::tcp::endpoint();
+}
+
+void handle_schedule2(
+ boost::thread::id thread_id,
+ l7vs::protocol_module_base::rs_list_itr_func_type inlist_begin,
+ l7vs::protocol_module_base::rs_list_itr_func_type inlist_end,
+ l7vs::protocol_module_base::rs_list_itr_next_func_type inlist_next,
+ boost::asio::ip::tcp::endpoint& outendpoint ){
+ outendpoint = boost::asio::ip::tcp::endpoint( boost::asio::ip::address::from_string( "10.144.169.87" ), 22 );
+}
+
+l7vs::protocol_module_base::realserverlist_type::iterator list_begin( l7vs::protocol_module_base::realserverlist_type* list ){
+ return(list->begin());
+}
+
+l7vs::protocol_module_base::realserverlist_type::iterator list_end( l7vs::protocol_module_base::realserverlist_type* list ){
+ return(list->end());
+}
+
+l7vs::protocol_module_base::realserverlist_type::iterator list_next( l7vs::protocol_module_base::realserverlist_type::iterator itr ){
+ return(++itr);
+}
+
+
//--test class--
class protocol_module_cinsert_test : public protocol_module_cinsert
{
t_send_status_list_itr send_status_itr;
t_edit_data_list_itr edit_data_itr;
-std::cout << "session_thread_data_disp" << std::endl;
+ std::cout << "session_thread_data_disp" << std::endl;
thread_data_itr = session_thread_data_map.begin();
send_status_itr->edit_division = EDIT_DIVISION_NO_EDIT;
}
else
- {
- send_status_itr->status = SEND_END;
- }
- }
-
- send_status_itr++;
-
- }
-
- }
-
- }
-
-}
-
-
-void session_thread_data_erase()
-{
-
- t_session_thread_data_map_itr thread_data_itr;
-
- thread_data_itr = session_thread_data_map.begin();
-
-std::cout << "session_thread_data_erase" << std::endl;
-
-session_thread_data_cinsert* thread_data;
-
-thread_data = new session_thread_data_cinsert;
-
-delete thread_data;
-
- while( thread_data_itr != session_thread_data_map.end() )
- {
- session_thread_data_map.erase(thread_data_itr);
- thread_data_itr = session_thread_data_map.begin();
- }
-
-}
-
-//-------------------------------------------------------------------
-void get_name_test()
-{
- // unit_test[01] get_name( Result = "cinsert" )
- BOOST_CHECK( get_name() == "cinsert" );
-}
-
-void get_name_test_thread( int thread_no, bool* ret )
-{
- // unit_test[02] get_name( Result = "cinsert" / ThreadNo = 1 )
- // unit_test[03] get_name( Result = "cinsert" / ThreadNo = 2 )
- // unit_test[04] get_name( Result = "cinsert" / ThreadNo = 3 )
- // unit_test[05] get_name( Result = "cinsert" / ThreadNo = 4 )
- // unit_test[06] get_name( Result = "cinsert" / ThreadNo = 5 )
- {
- boost::mutex::scoped_lock lk( sync_mutex );
- sync_condition.wait( lk );
- }
- if( get_name() == "cinsert" )
- {
- *ret = true;
- }
- else
- {
- *ret = false;
- }
-}
-//-------------------------------------------------------------------
-void is_tcp_test()
-{
- // unit_test[01] is_tcp( Result = true )
- BOOST_CHECK( is_tcp() == true );
-}
-
-void is_tcp_test_thread( int thread_no, bool* ret )
-{
- // unit_test[02] is_tcp( Result = true / ThreadNo = 1 )
- // unit_test[03] is_tcp( Result = true / ThreadNo = 2 )
- // unit_test[04] is_tcp( Result = true / ThreadNo = 3 )
- // unit_test[05] is_tcp( Result = true / ThreadNo = 4 )
- // unit_test[06] is_tcp( Result = true / ThreadNo = 5 )
- {
- boost::mutex::scoped_lock lk( sync_mutex );
- sync_condition.wait( lk );
- }
- if( is_tcp() == true )
- {
- *ret = true;
- }
- else
- {
- *ret = false;
- }
-}
-//-------------------------------------------------------------------
-void is_udp_test()
-{
- // unit_test[01] is_udp( Result = false )
- BOOST_CHECK( is_udp() == false );
-}
-
-void is_udp_test_thread( int thread_no, bool* ret )
-{
- // unit_test[02] is_udp( Result = false / ThreadNo = 1 )
- // unit_test[03] is_udp( Result = false / ThreadNo = 2 )
- // unit_test[04] is_udp( Result = false / ThreadNo = 3 )
- // unit_test[05] is_udp( Result = false / ThreadNo = 4 )
- // unit_test[06] is_udp( Result = false / ThreadNo = 5 )
- {
- boost::mutex::scoped_lock lk( sync_mutex );
- sync_condition.wait( lk );
- }
- if( is_udp() == false )
- {
- *ret = true;
- }
- else
- {
- *ret = false;
- }
-}
-
-//-------------------------------------------------------------------
-void is_use_sorry_test()
-{
- // unit_test[01] is_use_sorry( Result = true )
- BOOST_CHECK( is_use_sorry() == true );
-}
-
-void is_use_sorry_test_thread( int thread_no, bool* ret )
-{
- // unit_test[02] is_use_sorry( Result = true / ThreadNo = 1 )
- // unit_test[03] is_use_sorry( Result = true / ThreadNo = 2 )
- // unit_test[04] is_use_sorry( Result = true / ThreadNo = 3 )
- // unit_test[05] is_use_sorry( Result = true / ThreadNo = 4 )
- // unit_test[06] is_use_sorry( Result = true / ThreadNo = 5 )
- {
- boost::mutex::scoped_lock lk( sync_mutex );
- sync_condition.wait( lk );
- }
- if( is_use_sorry() == true )
- {
- *ret = true;
- }
- else
- {
- *ret = false;
- }
-}
-//-------------------------------------------------------------------
-void handle_session_initialize_test()
-{
-
- protocol_module_cinsert::EVENT_TAG status;
-
- boost::thread up_thread( &thread_method );
- boost::thread down_thread( &thread_method );
-
- boost::asio::ip::address address;
- boost::asio::ip::tcp::endpoint client_endpoint_tcp( address, 11111 );
- boost::asio::ip::udp::endpoint client_endpoint_udp( address, 22222 );
-
- t_session_thread_data_map_itr up_thread_data_itr;
- t_session_thread_data_map_itr down_thread_data_itr;
- t_recive_data_map_itr recive_data_itr;
-
- status = handle_session_initialize(
- up_thread.get_id(),
- down_thread.get_id(),
- client_endpoint_tcp,
- client_endpoint_udp );
-
- std::cout << "<<< parameter >>>" << std::endl;
- std::cout << "up_thread_id = [" << up_thread.get_id() << "]" << std::endl;
- std::cout << "down_thread_id = [" << down_thread.get_id() << "]" << std::endl;
- std::cout << "client_endpoint_tcp = [" << client_endpoint_tcp << "]" << std::endl;
- std::cout << "client_endpoint_udp = [" << client_endpoint_udp << "]" << std::endl;
- std::cout << std::endl;
-
- up_thread_data_itr = session_thread_data_map.find( up_thread.get_id());
-
- BOOST_CHECK( up_thread_data_itr != session_thread_data_map.end());
-
- if( up_thread_data_itr != session_thread_data_map.end())
- {
- std::cout << "<< up_thread_data >>" << std::endl;
- std::cout << "thread_id = ["
- << up_thread_data_itr->second->thread_id << "]" << std::endl;
- std::cout << "thread_division = ["
- << up_thread_data_itr->second->thread_division << "]" << std::endl;
- std::cout << "pair_thread_id = ["
- << up_thread_data_itr->second->pair_thread_id << "]" << std::endl;
- std::cout << "end_flag = ["
- << up_thread_data_itr->second->end_flag << "]" << std::endl;
- std::cout << "accept_end_flag = ["
- << up_thread_data_itr->second->accept_end_flag << "]" << std::endl;
- std::cout << "sorry_flag = ["
- << up_thread_data_itr->second->sorry_flag << "]" << std::endl;
- std::cout << "sorryserver_switch_flag = ["
- << up_thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
- std::cout << "realserver_switch_flag = ["
- << up_thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
- std::cout << "client_endpoint_tcp = ["
- << up_thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
- std::cout << std::endl;
-
- BOOST_CHECK( up_thread_data_itr->second->thread_id == up_thread.get_id());
- BOOST_CHECK( up_thread_data_itr->second->thread_division == THREAD_DIVISION_UP_STREAM );
- BOOST_CHECK( up_thread_data_itr->second->pair_thread_id == down_thread.get_id());
- BOOST_CHECK( up_thread_data_itr->second->end_flag == END_FLAG_OFF );
- BOOST_CHECK( up_thread_data_itr->second->accept_end_flag == ACCEPT_END_FLAG_OFF );
- BOOST_CHECK( up_thread_data_itr->second->sorry_flag == SORRY_FLAG_OFF );
- BOOST_CHECK( up_thread_data_itr->second->sorryserver_switch_flag == SORRYSERVER_SWITCH_FLAG_OFF );
- BOOST_CHECK( up_thread_data_itr->second->realserver_switch_flag == REALSERVER_SWITCH_FLAG_OFF );
- BOOST_CHECK( up_thread_data_itr->second->client_endpoint_tcp == client_endpoint_tcp);
-
- recive_data_itr = up_thread_data_itr->second->recive_data_map.find( client_endpoint_tcp );
-
- BOOST_CHECK( recive_data_itr != up_thread_data_itr->second->recive_data_map.end());
-
- if( recive_data_itr != up_thread_data_itr->second->recive_data_map.end())
- {
- std::cout << "< recive_data >" << std::endl;
- std::cout << "recive_buffer_max_size = ["
- << recive_data_itr->second.recive_buffer_max_size << "]" << std::endl;
- std::cout << "recive_buffer_rest_size = ["
- << recive_data_itr->second.recive_buffer_rest_size << "]" << std::endl;
- std::cout << "recive_buffer = ["
- << (void*)recive_data_itr->second.recive_buffer << "]" << std::endl;
- std::cout << "recive_buffer_1 = ["
- << (void*)recive_data_itr->second.recive_buffer_1 << "]" << std::endl;
- std::cout << "recive_buffer_2 = ["
- << (void*)recive_data_itr->second.recive_buffer_2 << "]" << std::endl;
- std::cout << std::endl;
-
- BOOST_CHECK( recive_data_itr->second.recive_buffer_max_size == MAX_BUFFER_SIZE );
- BOOST_CHECK( recive_data_itr->second.recive_buffer_rest_size == MAX_BUFFER_SIZE );
- BOOST_CHECK( recive_data_itr->second.recive_buffer == recive_data_itr->second.recive_buffer_1 );
- BOOST_CHECK( recive_data_itr->second.recive_buffer_1 != NULL );
- BOOST_CHECK( recive_data_itr->second.recive_buffer_2 != NULL );
-
- }
-
- }
-
- down_thread_data_itr = session_thread_data_map.find( down_thread.get_id());
-
- BOOST_CHECK( down_thread_data_itr != session_thread_data_map.end());
-
- if( down_thread_data_itr != session_thread_data_map.end())
- {
- std::cout << "<< down_thread_data >>" << std::endl;
- std::cout << "thread_id = ["
- << down_thread_data_itr->second->thread_id << "]" << std::endl;
- std::cout << "thread_division = ["
- << down_thread_data_itr->second->thread_division << "]" << std::endl;
- std::cout << "pair_thread_id = ["
- << down_thread_data_itr->second->pair_thread_id << "]" << std::endl;
- std::cout << "end_flag = ["
- << down_thread_data_itr->second->end_flag << "]" << std::endl;
- std::cout << "accept_end_flag = ["
- << down_thread_data_itr->second->accept_end_flag << "]" << std::endl;
- std::cout << "sorry_flag = ["
- << down_thread_data_itr->second->sorry_flag << "]" << std::endl;
- std::cout << "sorryserver_switch_flag = ["
- << down_thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
- std::cout << "realserver_switch_flag = ["
- << down_thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
- std::cout << "client_endpoint_tcp = ["
- << down_thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
- std::cout << std::endl;
-
- BOOST_CHECK( down_thread_data_itr->second->thread_id == down_thread.get_id());
- BOOST_CHECK( down_thread_data_itr->second->thread_division == THREAD_DIVISION_DOWN_STREAM );
- BOOST_CHECK( down_thread_data_itr->second->pair_thread_id == up_thread.get_id());
- BOOST_CHECK( down_thread_data_itr->second->end_flag == END_FLAG_OFF );
- BOOST_CHECK( down_thread_data_itr->second->accept_end_flag == ACCEPT_END_FLAG_OFF );
- BOOST_CHECK( down_thread_data_itr->second->sorry_flag == SORRY_FLAG_OFF );
- BOOST_CHECK( down_thread_data_itr->second->sorryserver_switch_flag == SORRYSERVER_SWITCH_FLAG_OFF );
- BOOST_CHECK( down_thread_data_itr->second->realserver_switch_flag == REALSERVER_SWITCH_FLAG_OFF );
- BOOST_CHECK( down_thread_data_itr->second->client_endpoint_tcp == client_endpoint_tcp);
-
- BOOST_CHECK( down_thread_data_itr->second->recive_data_map.empty() == true );
-
- }
-
- BOOST_CHECK( status == ACCEPT );
-
-}
-
-void handle_session_initialize_test_thread( int thread_no, bool* ret )
-{
-
- boost::xtime start_time;
- boost::xtime end_time;
-
- protocol_module_cinsert::EVENT_TAG status;
-
- boost::thread up_thread( &thread_method );
- boost::thread down_thread( &thread_method );
-
- boost::asio::ip::address address;
- boost::asio::ip::tcp::endpoint client_endpoint_tcp( address, thread_no * 11111 );
- boost::asio::ip::udp::endpoint client_endpoint_udp( address, 00000 );
-
- t_session_thread_data_map_itr up_thread_data_itr;
- t_session_thread_data_map_itr down_thread_data_itr;
- t_recive_data_map_itr recive_data_itr;
-
- {
- boost::mutex::scoped_lock lk( sync_mutex );
- sync_condition.wait( lk );
- }
-
- boost::xtime_get(&start_time, boost::TIME_UTC);
- status = handle_session_initialize(
- up_thread.get_id(),
- down_thread.get_id(),
- client_endpoint_tcp,
- client_endpoint_udp );
- boost::xtime_get(&end_time, boost::TIME_UTC);
-
- boost::mutex::scoped_lock lk( sync_mutex );
- sync_condition.wait( lk );
-
- *ret = false;
-
- std::cout << "<<<< ThreadNo = [" << thread_no << "] >>>>" << std::endl;
- std::cout << "StartTime = [" << start_time.nsec << "]" << std::endl;
- std::cout << "EndTime = [" << end_time.nsec << "]" << std::endl;
- std::cout << "<<< parameter >>>" << std::endl;
- std::cout << "up_thread_id = [" << up_thread.get_id() << "]" << std::endl;
- std::cout << "down_thread_id = [" << down_thread.get_id() << "]" << std::endl;
- std::cout << "client_endpoint_tcp = [" << client_endpoint_tcp << "]" << std::endl;
- std::cout << "client_endpoint_udp = [" << client_endpoint_udp << "]" << std::endl;
- std::cout << std::endl;
-
- up_thread_data_itr = session_thread_data_map.find( up_thread.get_id());
-
- if( up_thread_data_itr == session_thread_data_map.end()){ return; }
-
- std::cout << "<< up_thread_data >>" << std::endl;
- std::cout << "thread_id = ["
- << up_thread_data_itr->second->thread_id << "]" << std::endl;
- std::cout << "thread_division = ["
- << up_thread_data_itr->second->thread_division << "]" << std::endl;
- std::cout << "pair_thread_id = ["
- << up_thread_data_itr->second->pair_thread_id << "]" << std::endl;
- std::cout << "end_flag = ["
- << up_thread_data_itr->second->end_flag << "]" << std::endl;
- std::cout << "accept_end_flag = ["
- << up_thread_data_itr->second->accept_end_flag << "]" << std::endl;
- std::cout << "sorry_flag = ["
- << up_thread_data_itr->second->sorry_flag << "]" << std::endl;
- std::cout << "sorryserver_switch_flag = ["
- << up_thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
- std::cout << "realserver_switch_flag = ["
- << up_thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
- std::cout << "client_endpoint_tcp = ["
- << up_thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
- std::cout << std::endl;
-
- if( up_thread_data_itr->second->thread_id != up_thread.get_id()){ return; }
- if( up_thread_data_itr->second->thread_division != THREAD_DIVISION_UP_STREAM ){ return; }
- if( up_thread_data_itr->second->pair_thread_id != down_thread.get_id()){ return; }
- if( up_thread_data_itr->second->end_flag != END_FLAG_OFF ){ return; }
- if( up_thread_data_itr->second->accept_end_flag != ACCEPT_END_FLAG_OFF ){ return; }
- if( up_thread_data_itr->second->sorry_flag != SORRY_FLAG_OFF ){ return; }
- if( up_thread_data_itr->second->sorryserver_switch_flag != SORRYSERVER_SWITCH_FLAG_OFF ){ return; }
- if( up_thread_data_itr->second->realserver_switch_flag != REALSERVER_SWITCH_FLAG_OFF ){ return; }
- if( up_thread_data_itr->second->client_endpoint_tcp != client_endpoint_tcp){ return; }
-
- recive_data_itr = up_thread_data_itr->second->recive_data_map.find( client_endpoint_tcp );
-
- if( recive_data_itr == up_thread_data_itr->second->recive_data_map.end()){ return; }
-
- std::cout << "< recive_data >" << std::endl;
- std::cout << "recive_buffer_max_size = ["
- << recive_data_itr->second.recive_buffer_max_size << "]" << std::endl;
- std::cout << "recive_buffer_rest_size = ["
- << recive_data_itr->second.recive_buffer_rest_size << "]" << std::endl;
- std::cout << "recive_buffer = ["
- << (void*)recive_data_itr->second.recive_buffer << "]" << std::endl;
- std::cout << "recive_buffer_1 = ["
- << (void*)recive_data_itr->second.recive_buffer_1 << "]" << std::endl;
- std::cout << "recive_buffer_2 = ["
- << (void*)recive_data_itr->second.recive_buffer_2 << "]" << std::endl;
- std::cout << std::endl;
-
- if( recive_data_itr->second.recive_buffer_max_size != MAX_BUFFER_SIZE ){ return; }
- if( recive_data_itr->second.recive_buffer_rest_size != MAX_BUFFER_SIZE ){ return; }
- if( recive_data_itr->second.recive_buffer != recive_data_itr->second.recive_buffer_1 ){ return; }
- if( recive_data_itr->second.recive_buffer_1 == NULL ){ return; }
- if( recive_data_itr->second.recive_buffer_2 == NULL ){ return; }
-
- down_thread_data_itr = session_thread_data_map.find( down_thread.get_id());
-
- if( down_thread_data_itr == session_thread_data_map.end()){ return; }
-
- std::cout << "<< down_thread_data >>" << std::endl;
- std::cout << "thread_id = ["
- << down_thread_data_itr->second->thread_id << "]" << std::endl;
- std::cout << "thread_division = ["
- << down_thread_data_itr->second->thread_division << "]" << std::endl;
- std::cout << "pair_thread_id = ["
- << down_thread_data_itr->second->pair_thread_id << "]" << std::endl;
- std::cout << "end_flag = ["
- << down_thread_data_itr->second->end_flag << "]" << std::endl;
- std::cout << "accept_end_flag = ["
- << down_thread_data_itr->second->accept_end_flag << "]" << std::endl;
- std::cout << "sorry_flag = ["
- << down_thread_data_itr->second->sorry_flag << "]" << std::endl;
- std::cout << "sorryserver_switch_flag = ["
- << down_thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
- std::cout << "realserver_switch_flag = ["
- << down_thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
- std::cout << "client_endpoint_tcp = ["
- << down_thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
- std::cout << std::endl;
-
- if( down_thread_data_itr->second->thread_id != down_thread.get_id()){ return; }
- if( down_thread_data_itr->second->thread_division != THREAD_DIVISION_DOWN_STREAM ){ return; }
- if( down_thread_data_itr->second->pair_thread_id != up_thread.get_id()){ return; }
- if( down_thread_data_itr->second->end_flag != END_FLAG_OFF ){ return; }
- if( down_thread_data_itr->second->accept_end_flag != ACCEPT_END_FLAG_OFF ){ return; }
- if( down_thread_data_itr->second->sorry_flag != SORRY_FLAG_OFF ){ return; }
- if( down_thread_data_itr->second->sorryserver_switch_flag != SORRYSERVER_SWITCH_FLAG_OFF ){ return; }
- if( down_thread_data_itr->second->realserver_switch_flag != REALSERVER_SWITCH_FLAG_OFF ){ return; }
- if( down_thread_data_itr->second->client_endpoint_tcp != client_endpoint_tcp){ return; }
-
- if( down_thread_data_itr->second->recive_data_map.empty() != true ){ return; }
-
- if( status != ACCEPT ){ return; }
-
- *ret = true;
-
- return;
-
-}
-
-void handle_session_finalize_test()
-{
-
- int i = 0;
- int j = 0;
- size_t recive_data_num = 0;
-
- protocol_module_cinsert::EVENT_TAG status;
-
- boost::thread up_thread_1( &thread_method );
- boost::thread up_thread_2( &thread_method );
-
- boost::thread down_thread_1( &thread_method );
- boost::thread down_thread_2( &thread_method );
-
- boost::asio::ip::address address;
-
- boost::asio::ip::tcp::endpoint client_endpoint_tcp_1( address, 11111 );
- boost::asio::ip::tcp::endpoint client_endpoint_tcp_2( address, 12222 );
- boost::asio::ip::tcp::endpoint client_endpoint_tcp_3( address, 13333 );
-
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_1( address, 21111 );
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_2( address, 22222 );
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_3( address, 23333 );
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_4( address, 24444 );
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_5( address, 25555 );
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_6( address, 26666 );
- boost::asio::ip::tcp::endpoint realserver_endpoint_tcp_7( address, 27777 );
-
- t_session_thread_data_map_itr thread_data_itr;
- t_recive_data_map_itr recive_data_itr;
-
- t_session_thread_data_cinsert up_thread_data_1( new session_thread_data_cinsert );
- t_session_thread_data_cinsert up_thread_data_2( new session_thread_data_cinsert );
- t_session_thread_data_cinsert down_thread_data_1( new session_thread_data_cinsert );
- t_session_thread_data_cinsert down_thread_data_2( new session_thread_data_cinsert );
- recive_data client_recv_data_1;
- recive_data client_recv_data_2;
- recive_data client_recv_data_3;
- recive_data realserver_recv_data_1;
- recive_data realserver_recv_data_2;
- recive_data realserver_recv_data_3;
- recive_data realserver_recv_data_4;
- recive_data realserver_recv_data_5;
- recive_data realserver_recv_data_6;
- recive_data realserver_recv_data_7;
- char* buffer = NULL;
-
- //----------------------------------------------------------------------
-// up_thread_data_1 = new session_thread_data_cinsert;
-
- up_thread_data_1->thread_id = up_thread_1.get_id();
- up_thread_data_1->thread_division = THREAD_DIVISION_UP_STREAM;
- up_thread_data_1->pair_thread_id = down_thread_1.get_id();
- up_thread_data_1->client_endpoint_tcp = client_endpoint_tcp_1;
-
- buffer = (char*)malloc( client_recv_data_1.recive_buffer_max_size );
-
- client_recv_data_1.recive_buffer = buffer;
- client_recv_data_1.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( client_recv_data_1.recive_buffer_max_size );
-
- client_recv_data_1.recive_buffer_2 = buffer;
-
- up_thread_data_1->recive_data_map[ client_endpoint_tcp_1 ] = client_recv_data_1;
-
- buffer = (char*)malloc( client_recv_data_2.recive_buffer_max_size );
-
- client_recv_data_2.recive_buffer = buffer;
- client_recv_data_2.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( client_recv_data_2.recive_buffer_max_size );
-
- client_recv_data_2.recive_buffer_2 = buffer;
-
- up_thread_data_1->recive_data_map[ client_endpoint_tcp_2 ] = client_recv_data_2;
-
- session_thread_data_map[ up_thread_1.get_id() ] = up_thread_data_1;
-
- //----------------------------------------------------------------------
-// up_thread_data_2 = new session_thread_data_cinsert;
-
- up_thread_data_2->thread_id = up_thread_2.get_id();
- up_thread_data_2->thread_division = THREAD_DIVISION_UP_STREAM;
- up_thread_data_2->pair_thread_id = down_thread_2.get_id();
- up_thread_data_2->client_endpoint_tcp = client_endpoint_tcp_3;
-
- buffer = (char*)malloc( client_recv_data_3.recive_buffer_max_size );
-
- client_recv_data_3.recive_buffer = buffer;
- client_recv_data_3.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( client_recv_data_3.recive_buffer_max_size );
-
- client_recv_data_3.recive_buffer_2 = buffer;
-
- up_thread_data_2->recive_data_map[ client_endpoint_tcp_3 ] = client_recv_data_3;
-
- session_thread_data_map[ up_thread_2.get_id() ] = up_thread_data_2;
-
- //----------------------------------------------------------------------
-// down_thread_data_1 = new session_thread_data_cinsert;
-
- down_thread_data_1->thread_id = down_thread_1.get_id();
- down_thread_data_1->thread_division = THREAD_DIVISION_DOWN_STREAM;
- down_thread_data_1->pair_thread_id = up_thread_1.get_id();
- down_thread_data_1->client_endpoint_tcp = client_endpoint_tcp_1;
-
- buffer = (char*)malloc( realserver_recv_data_1.recive_buffer_max_size );
-
- realserver_recv_data_1.recive_buffer = buffer;
- realserver_recv_data_1.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_1.recive_buffer_max_size );
-
- realserver_recv_data_1.recive_buffer_2 = buffer;
-
- down_thread_data_1->recive_data_map[ realserver_endpoint_tcp_1 ] = realserver_recv_data_1;
-
- buffer = (char*)malloc( realserver_recv_data_2.recive_buffer_max_size );
-
- realserver_recv_data_2.recive_buffer = buffer;
- realserver_recv_data_2.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_2.recive_buffer_max_size );
-
- realserver_recv_data_2.recive_buffer_2 = buffer;
-
- down_thread_data_1->recive_data_map[ realserver_endpoint_tcp_2 ] = realserver_recv_data_2;
-
- buffer = (char*)malloc( realserver_recv_data_3.recive_buffer_max_size );
-
- realserver_recv_data_3.recive_buffer = buffer;
- realserver_recv_data_3.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_3.recive_buffer_max_size );
-
- realserver_recv_data_3.recive_buffer_2 = buffer;
-
- down_thread_data_1->recive_data_map[ realserver_endpoint_tcp_3 ] = realserver_recv_data_3;
-
- buffer = (char*)malloc( realserver_recv_data_4.recive_buffer_max_size );
-
- realserver_recv_data_4.recive_buffer = buffer;
- realserver_recv_data_4.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_4.recive_buffer_max_size );
-
- realserver_recv_data_4.recive_buffer_2 = buffer;
-
- down_thread_data_1->recive_data_map[ realserver_endpoint_tcp_4 ] = realserver_recv_data_4;
-
- session_thread_data_map[ down_thread_1.get_id() ] = down_thread_data_1;
-
- //----------------------------------------------------------------------
-// down_thread_data_2 = new session_thread_data_cinsert;
-
- down_thread_data_2->thread_id = down_thread_2.get_id();
- down_thread_data_2->thread_division = THREAD_DIVISION_DOWN_STREAM;
- down_thread_data_2->pair_thread_id = up_thread_2.get_id();
- down_thread_data_2->client_endpoint_tcp = client_endpoint_tcp_3;
-
- buffer = (char*)malloc( realserver_recv_data_5.recive_buffer_max_size );
-
- realserver_recv_data_5.recive_buffer = buffer;
- realserver_recv_data_5.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_5.recive_buffer_max_size );
-
- realserver_recv_data_5.recive_buffer_2 = buffer;
-
- down_thread_data_2->recive_data_map[ realserver_endpoint_tcp_5 ] = realserver_recv_data_5;
-
- buffer = (char*)malloc( realserver_recv_data_6.recive_buffer_max_size );
-
- realserver_recv_data_6.recive_buffer = buffer;
- realserver_recv_data_6.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_6.recive_buffer_max_size );
-
- realserver_recv_data_6.recive_buffer_2 = buffer;
-
- down_thread_data_2->recive_data_map[ realserver_endpoint_tcp_6 ] = realserver_recv_data_6;
-
- buffer = (char*)malloc( realserver_recv_data_7.recive_buffer_max_size );
-
- realserver_recv_data_7.recive_buffer = buffer;
- realserver_recv_data_7.recive_buffer_1 = buffer;
-
- buffer = (char*)malloc( realserver_recv_data_7.recive_buffer_max_size );
-
- realserver_recv_data_7.recive_buffer_2 = buffer;
-
- down_thread_data_2->recive_data_map[ realserver_endpoint_tcp_7 ] = realserver_recv_data_7;
-
- session_thread_data_map[ down_thread_2.get_id() ] = down_thread_data_2;
-
- //----------------------------------------------------------------------
-
- client_recv_data_1.recive_buffer_1 = NULL;
- client_recv_data_1.recive_buffer_2 = NULL;
- client_recv_data_2.recive_buffer_1 = NULL;
- client_recv_data_2.recive_buffer_2 = NULL;
- client_recv_data_3.recive_buffer_1 = NULL;
- client_recv_data_3.recive_buffer_2 = NULL;
- realserver_recv_data_1.recive_buffer_1 = NULL;
- realserver_recv_data_1.recive_buffer_2 = NULL;
- realserver_recv_data_2.recive_buffer_1 = NULL;
- realserver_recv_data_2.recive_buffer_2 = NULL;
- realserver_recv_data_3.recive_buffer_1 = NULL;
- realserver_recv_data_3.recive_buffer_2 = NULL;
- realserver_recv_data_4.recive_buffer_1 = NULL;
- realserver_recv_data_4.recive_buffer_2 = NULL;
- realserver_recv_data_5.recive_buffer_1 = NULL;
- realserver_recv_data_5.recive_buffer_2 = NULL;
- realserver_recv_data_6.recive_buffer_1 = NULL;
- realserver_recv_data_6.recive_buffer_2 = NULL;
- realserver_recv_data_7.recive_buffer_1 = NULL;
- realserver_recv_data_7.recive_buffer_2 = NULL;
-
- std::cout << "<<< handle_session_finalize before >>>" << std::endl;
-
- thread_data_itr = session_thread_data_map.begin();
-
- std::cout << "session_thread_data_map entry = ["
- << session_thread_data_map.size() << "]" << std::endl;
-
- BOOST_CHECK( session_thread_data_map.size() == 4 );
-
- std::cout << std::endl;
-
- i = 0;
-
- while( thread_data_itr != session_thread_data_map.end() )
- {
- i++;
-
- BOOST_CHECK( ( thread_data_itr->first == up_thread_1.get_id()) ||
- ( thread_data_itr->first == up_thread_2.get_id()) ||
- ( thread_data_itr->first == down_thread_1.get_id()) ||
- ( thread_data_itr->first == down_thread_2.get_id()) );
-
- std::cout << "<< thread_data[" << i << "] >>" << std::endl;
- std::cout << "key = ["
- << thread_data_itr->first << "]" << std::endl;
- std::cout << "thread_id = ["
- << thread_data_itr->second->thread_id << "]" << std::endl;
- std::cout << "thread_division = ["
- << thread_data_itr->second->thread_division << "]" << std::endl;
- std::cout << "pair_thread_id = ["
- << thread_data_itr->second->pair_thread_id << "]" << std::endl;
- std::cout << "end_flag = ["
- << thread_data_itr->second->end_flag << "]" << std::endl;
- std::cout << "accept_end_flag = ["
- << thread_data_itr->second->accept_end_flag << "]" << std::endl;
- std::cout << "sorry_flag = ["
- << thread_data_itr->second->sorry_flag << "]" << std::endl;
- std::cout << "sorryserver_switch_flag = ["
- << thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
- std::cout << "realserver_switch_flag = ["
- << thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
- std::cout << "client_endpoint_tcp = ["
- << thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
- std::cout << "recive_data_map entry = ["
- << thread_data_itr->second->recive_data_map.size() << "]" << std::endl;
- std::cout << std::endl;
-
- recive_data_num = 0;
-
- if( thread_data_itr->first == up_thread_1.get_id() )
- {
- recive_data_num = 2;
- }
- else if( thread_data_itr->first == up_thread_2.get_id() )
- {
- recive_data_num = 1;
- }
- else if( thread_data_itr->first == down_thread_1.get_id() )
- {
- recive_data_num = 4;
- }
- else if( thread_data_itr->first == down_thread_2.get_id() )
- {
- recive_data_num = 3;
- }
-
- BOOST_CHECK( thread_data_itr->second->recive_data_map.size() == recive_data_num );
-
- recive_data_itr = thread_data_itr->second->recive_data_map.begin();
-
- j = 0;
-
- while( recive_data_itr != thread_data_itr->second->recive_data_map.end() )
- {
- j++;
-
- std::cout << "< recive_data[" << j << "] >" << std::endl;
- std::cout << "key = ["
- << recive_data_itr->first << "]" << std::endl;
- std::cout << "recive_buffer_max_size = ["
- << recive_data_itr->second.recive_buffer_max_size << "]" << std::endl;
- std::cout << "recive_buffer_rest_size = ["
- << recive_data_itr->second.recive_buffer_rest_size << "]" << std::endl;
- std::cout << "recive_buffer = ["
- << (void*)recive_data_itr->second.recive_buffer << "]" << std::endl;
- std::cout << "recive_buffer_1 = ["
- << (void*)recive_data_itr->second.recive_buffer_1 << "]" << std::endl;
- std::cout << "recive_buffer_2 = ["
- << (void*)recive_data_itr->second.recive_buffer_2 << "]" << std::endl;
- std::cout << std::endl;
-
- recive_data_itr++;
-
- }
-
- thread_data_itr++;
-
- }
-
- std::cout << std::endl;
- std::cout << "<<< handle_session_finalize after >>>" << std::endl;
- std::cout << "finalize up_thread_id = ["
- << up_thread_1.get_id() << "]" << std::endl;
- std::cout << "finalize down_thread_id = ["
- << down_thread_1.get_id() << "]" << std::endl;
- //------------------------------------------------------------------
- status = handle_session_finalize(
- up_thread_1.get_id(),
- down_thread_1.get_id());
- //------------------------------------------------------------------
-
- thread_data_itr = session_thread_data_map.begin();
-
- std::cout << "session_thread_data_map entry = ["
- << session_thread_data_map.size() << "]" << std::endl;
-
- BOOST_CHECK( session_thread_data_map.size() == 2 );
-
- std::cout << std::endl;
-
- i = 0;
-
- while( thread_data_itr != session_thread_data_map.end() )
- {
- i++;
-
- BOOST_CHECK( ( thread_data_itr->first == up_thread_2.get_id()) ||
- ( thread_data_itr->first == down_thread_2.get_id()) );
-
- std::cout << "<< thread_data[" << i << "] >>" << std::endl;
- std::cout << "key = ["
- << thread_data_itr->first << "]" << std::endl;
- std::cout << "thread_id = ["
- << thread_data_itr->second->thread_id << "]" << std::endl;
- std::cout << "thread_division = ["
- << thread_data_itr->second->thread_division << "]" << std::endl;
- std::cout << "pair_thread_id = ["
- << thread_data_itr->second->pair_thread_id << "]" << std::endl;
- std::cout << "end_flag = ["
- << thread_data_itr->second->end_flag << "]" << std::endl;
- std::cout << "accept_end_flag = ["
- << thread_data_itr->second->accept_end_flag << "]" << std::endl;
- std::cout << "sorry_flag = ["
- << thread_data_itr->second->sorry_flag << "]" << std::endl;
- std::cout << "sorryserver_switch_flag = ["
- << thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
- std::cout << "realserver_switch_flag = ["
- << thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
- std::cout << "client_endpoint_tcp = ["
- << thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
- std::cout << "recive_data_map entry = ["
- << thread_data_itr->second->recive_data_map.size() << "]" << std::endl;
- std::cout << std::endl;
-
- recive_data_num = 0;
-
- if( thread_data_itr->first == up_thread_1.get_id() )
- {
- recive_data_num = 2;
- }
- else if( thread_data_itr->first == up_thread_2.get_id() )
- {
- recive_data_num = 1;
- }
- else if( thread_data_itr->first == down_thread_1.get_id() )
- {
- recive_data_num = 4;
- }
- else if( thread_data_itr->first == down_thread_2.get_id() )
- {
- recive_data_num = 3;
- }
-
- BOOST_CHECK( thread_data_itr->second->recive_data_map.size() == recive_data_num );
-
- recive_data_itr = thread_data_itr->second->recive_data_map.begin();
-
- j = 0;
-
- while( recive_data_itr != thread_data_itr->second->recive_data_map.end() )
- {
- j++;
-
- std::cout << "< recive_data[" << j << "] >" << std::endl;
- std::cout << "key = ["
- << recive_data_itr->first << "]" << std::endl;
- std::cout << "recive_buffer_max_size = ["
- << recive_data_itr->second.recive_buffer_max_size << "]" << std::endl;
- std::cout << "recive_buffer_rest_size = ["
- << recive_data_itr->second.recive_buffer_rest_size << "]" << std::endl;
- std::cout << "recive_buffer = ["
- << (void*)recive_data_itr->second.recive_buffer << "]" << std::endl;
- std::cout << "recive_buffer_1 = ["
- << (void*)recive_data_itr->second.recive_buffer_1 << "]" << std::endl;
- std::cout << "recive_buffer_2 = ["
- << (void*)recive_data_itr->second.recive_buffer_2 << "]" << std::endl;
- std::cout << std::endl;
-
- recive_data_itr++;
-
- }
-
- thread_data_itr++;
-
- }
-
-// realserver_recv_data_1.recive_buffer_1[0] = 'a';
-// realserver_recv_data_1.recive_buffer_1[0] = 'a';
-
- std::cout << std::endl;
-
- BOOST_CHECK( status == STOP );
-
-}
-
-void handle_session_finalize_test_thread( int thread_no, bool* ret )
-{
-
-// boost::xtime start_time;
-// boost::xtime end_time;
-//
-// protocol_module_cinsert::EVENT_TAG status;
-//
-// boost::thread up_thread( &thread_method );
-// boost::thread down_thread( &thread_method );
-//
-// boost::asio::ip::address address;
-// boost::asio::ip::tcp::endpoint client_endpoint_tcp( address, thread_no * 11111 );
-// boost::asio::ip::udp::endpoint client_endpoint_udp( address, 00000 );
-//
-// t_session_thread_data_map_itr up_thread_data_itr;
-// t_session_thread_data_map_itr down_thread_data_itr;
-// t_recive_data_map_itr recive_data_itr;
-//
-// {
-// boost::mutex::scoped_lock lk( sync_mutex );
-// sync_condition.wait( lk );
-// }
-//
-// boost::xtime_get(&start_time, boost::TIME_UTC);
-// status = handle_session_initialize(
-// up_thread.get_id(),
-// down_thread.get_id(),
-// client_endpoint_tcp,
-// client_endpoint_udp );
-// boost::xtime_get(&end_time, boost::TIME_UTC);
-//
-// boost::mutex::scoped_lock lk( sync_mutex );
-// sync_condition.wait( lk );
-//
-// *ret = false;
-//
-// std::cout << "<<<< ThreadNo = [" << thread_no << "] >>>>" << std::endl;
-// std::cout << "StartTime = [" << start_time.nsec << "]" << std::endl;
-// std::cout << "EndTime = [" << end_time.nsec << "]" << std::endl;
-// std::cout << "<<< parameter >>>" << std::endl;
-// std::cout << "up_thread_id = [" << up_thread.get_id() << "]" << std::endl;
-// std::cout << "down_thread_id = [" << down_thread.get_id() << "]" << std::endl;
-// std::cout << "client_endpoint_tcp = [" << client_endpoint_tcp << "]" << std::endl;
-// std::cout << "client_endpoint_udp = [" << client_endpoint_udp << "]" << std::endl;
-// std::cout << std::endl;
-//
-// up_thread_data_itr = session_thread_data_map.find( up_thread.get_id());
-//
-// if( up_thread_data_itr == session_thread_data_map.end()){ return; }
-//
-// std::cout << "<< up_thread_data >>" << std::endl;
-// std::cout << "thread_id = ["
-// << up_thread_data_itr->second->thread_id << "]" << std::endl;
-// std::cout << "thread_division = ["
-// << up_thread_data_itr->second->thread_division << "]" << std::endl;
-// std::cout << "pair_thread_id = ["
-// << up_thread_data_itr->second->pair_thread_id << "]" << std::endl;
-// std::cout << "end_flag = ["
-// << up_thread_data_itr->second->end_flag << "]" << std::endl;
-// std::cout << "accept_end_flag = ["
-// << up_thread_data_itr->second->accept_end_flag << "]" << std::endl;
-// std::cout << "sorry_flag = ["
-// << up_thread_data_itr->second->sorry_flag << "]" << std::endl;
-// std::cout << "sorryserver_switch_flag = ["
-// << up_thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
-// std::cout << "realserver_switch_flag = ["
-// << up_thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
-// std::cout << "client_endpoint_tcp = ["
-// << up_thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
-// std::cout << std::endl;
-//
-// if( up_thread_data_itr->second->thread_id != up_thread.get_id()){ return; }
-// if( up_thread_data_itr->second->thread_division != THREAD_DIVISION_UP_STREAM ){ return; }
-// if( up_thread_data_itr->second->pair_thread_id != down_thread.get_id()){ return; }
-// if( up_thread_data_itr->second->end_flag != END_FLAG_OFF ){ return; }
-// if( up_thread_data_itr->second->accept_end_flag != ACCEPT_END_FLAG_OFF ){ return; }
-// if( up_thread_data_itr->second->sorry_flag != SORRY_FLAG_OFF ){ return; }
-// if( up_thread_data_itr->second->sorryserver_switch_flag != SORRYSERVER_SWITCH_FLAG_OFF ){ return; }
-// if( up_thread_data_itr->second->realserver_switch_flag != REALSERVER_SWITCH_FLAG_OFF ){ return; }
-// if( up_thread_data_itr->second->client_endpoint_tcp != client_endpoint_tcp){ return; }
-//
-// recive_data_itr = up_thread_data_itr->second->recive_data_map.find( client_endpoint_tcp );
-//
-// if( recive_data_itr == up_thread_data_itr->second->recive_data_map.end()){ return; }
-//
-// std::cout << "< recive_data >" << std::endl;
-// std::cout << "recive_buffer_max_size = ["
-// << recive_data_itr->second.recive_buffer_max_size << "]" << std::endl;
-// std::cout << "recive_buffer_rest_size = ["
-// << recive_data_itr->second.recive_buffer_rest_size << "]" << std::endl;
-// std::cout << "recive_buffer = ["
-// << (void*)recive_data_itr->second.recive_buffer << "]" << std::endl;
-// std::cout << "recive_buffer_1 = ["
-// << (void*)recive_data_itr->second.recive_buffer_1 << "]" << std::endl;
-// std::cout << "recive_buffer_2 = ["
-// << (void*)recive_data_itr->second.recive_buffer_2 << "]" << std::endl;
-// std::cout << std::endl;
-//
-// if( recive_data_itr->second.recive_buffer_max_size != MAX_BUFFER_SIZE ){ return; }
-// if( recive_data_itr->second.recive_buffer_rest_size != MAX_BUFFER_SIZE ){ return; }
-// if( recive_data_itr->second.recive_buffer != recive_data_itr->second.recive_buffer_1 ){ return; }
-// if( recive_data_itr->second.recive_buffer_1 == NULL ){ return; }
-// if( recive_data_itr->second.recive_buffer_2 == NULL ){ return; }
-//
-// down_thread_data_itr = session_thread_data_map.find( down_thread.get_id());
-//
-// if( down_thread_data_itr == session_thread_data_map.end()){ return; }
-//
-// std::cout << "<< down_thread_data >>" << std::endl;
-// std::cout << "thread_id = ["
-// << down_thread_data_itr->second->thread_id << "]" << std::endl;
-// std::cout << "thread_division = ["
-// << down_thread_data_itr->second->thread_division << "]" << std::endl;
-// std::cout << "pair_thread_id = ["
-// << down_thread_data_itr->second->pair_thread_id << "]" << std::endl;
-// std::cout << "end_flag = ["
-// << down_thread_data_itr->second->end_flag << "]" << std::endl;
-// std::cout << "accept_end_flag = ["
-// << down_thread_data_itr->second->accept_end_flag << "]" << std::endl;
-// std::cout << "sorry_flag = ["
-// << down_thread_data_itr->second->sorry_flag << "]" << std::endl;
-// std::cout << "sorryserver_switch_flag = ["
-// << down_thread_data_itr->second->sorryserver_switch_flag << "]" << std::endl;
-// std::cout << "realserver_switch_flag = ["
-// << down_thread_data_itr->second->realserver_switch_flag << "]" << std::endl;
-// std::cout << "client_endpoint_tcp = ["
-// << down_thread_data_itr->second->client_endpoint_tcp << "]" << std::endl;
-// std::cout << std::endl;
-//
-// if( down_thread_data_itr->second->thread_id != down_thread.get_id()){ return; }
-// if( down_thread_data_itr->second->thread_division != THREAD_DIVISION_DOWN_STREAM ){ return; }
-// if( down_thread_data_itr->second->pair_thread_id != up_thread.get_id()){ return; }
-// if( down_thread_data_itr->second->end_flag != END_FLAG_OFF ){ return; }
-// if( down_thread_data_itr->second->accept_end_flag != ACCEPT_END_FLAG_OFF ){ return; }
-// if( down_thread_data_itr->second->sorry_flag != SORRY_FLAG_OFF ){ return; }
-// if( down_thread_data_itr->second->sorryserver_switch_flag != SORRYSERVER_SWITCH_FLAG_OFF ){ return; }
-// if( down_thread_data_itr->second->realserver_switch_flag != REALSERVER_SWITCH_FLAG_OFF ){ return; }
-// if( down_thread_data_itr->second->client_endpoint_tcp != client_endpoint_tcp){ return; }
-//
-// if( down_thread_data_itr->second->recive_data_map.empty() != true ){ return; }
-//
-// if( status != ACCEPT ){ return; }
-
- *ret = true;
-
- return;
-
-}
-
-void check_parameter_test()
-{
-
- check_message_result check_result;
- std::vector<std::string> args;
-
-//-------------------------------------------------------------
- args.push_back("-C");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-R");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_01>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("--cookie-name");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("--cookie-expire");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("--forwarded-for");
- args.push_back("--reschedule");
- args.push_back("--sorry-uri");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_02>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_03>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("--cookie-name");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("--cookie-expire");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("--forwarded-for");
- args.push_back("--no-reschedule");
- args.push_back("--sorry-uri");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_04>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_05>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-C/--cookie-name'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_06>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-C/--cookie-name' option value 'ABCDEfghij1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678' is too long." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij_1234567890");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_07>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-C/--cookie-name' option value 'ABCDEfghij_1234567890' is not alphanumeric character." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-C");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_08>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-C/--cookie-name'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_09>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot set multiple option '-C/--cookie-name'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("-R");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_10>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-E/--cookie-expire'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("123abc");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_11>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-E/--cookie-expire' option value '123abc' is not numeric character." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("2147483648"); //INT_MAX + 1
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_12>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-E/--cookie-expire' option value '2147483648' is too large." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_13>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-E/--cookie-expire'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_14>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot set multiple option '-E/--cookie-expire'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-R");
- args.push_back("-N");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_15>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to choose either of reschedule or no-reschedule." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-N");
- args.push_back("-R");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_16>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to choose either of reschedule or no-reschedule." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-S");
- args.push_back("-F");
- args.push_back("-N");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_17>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-S/--sorry-uri'." );
-
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F900");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_18>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-S/--sorry-uri' option value '/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F900' is too long." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/~a0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_19>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-S/--sorry-uri' option value '/~a0$-_.+!*'(),%00%0a%0A%A0%Aa%AA' is not a valid URI." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_20>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-S/--sorry-uri'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_21>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot set multiple option '-S/--sorry-uri'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
- args.push_back("-X");
-
- check_result = check_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<check_parameter_22>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Option error." );
-
-}
-
-void set_parameter_test()
-{
-
- check_message_result check_result;
- std::vector<std::string> args;
-
-
-//-------------------------------------------------------------
- args.push_back("-C");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-R");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_01>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-
- BOOST_CHECK( memcmp( cookie_name.data(), "ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", strlen(cookie_name.data())) == 0 );
- BOOST_CHECK( cookie_expire == INT_MAX );
- BOOST_CHECK( forwarded_for == 1 );
- BOOST_CHECK( reschedule == 1 );
- BOOST_CHECK( memcmp( sorry_uri.data(), "/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90", strlen(sorry_uri.data())) == 0 );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("--cookie-name");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("--cookie-expire");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("--forwarded-for");
- args.push_back("--reschedule");
- args.push_back("--sorry-uri");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_02>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-
- BOOST_CHECK( memcmp( cookie_name.data(), "ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", strlen(cookie_name.data())) == 0 );
- BOOST_CHECK( cookie_expire == INT_MAX );
- BOOST_CHECK( forwarded_for == 1 );
- BOOST_CHECK( reschedule == 1 );
- BOOST_CHECK( memcmp( sorry_uri.data(), "/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90", strlen(sorry_uri.data())) == 0 );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_03>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-
- BOOST_CHECK( memcmp( cookie_name.data(), "ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", strlen(cookie_name.data())) == 0 );
- BOOST_CHECK( cookie_expire == INT_MAX );
- BOOST_CHECK( forwarded_for == 1 );
- BOOST_CHECK( reschedule == 0 );
- BOOST_CHECK( memcmp( sorry_uri.data(), "/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90", strlen(sorry_uri.data())) == 0 );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("--cookie-name");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("--cookie-expire");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("--forwarded-for");
- args.push_back("--no-reschedule");
- args.push_back("--sorry-uri");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_04>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-
- BOOST_CHECK( memcmp( cookie_name.data(), "ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", strlen(cookie_name.data())) == 0 );
- BOOST_CHECK( cookie_expire == INT_MAX );
- BOOST_CHECK( forwarded_for == 1 );
- BOOST_CHECK( reschedule == 0 );
- BOOST_CHECK( memcmp( sorry_uri.data(), "/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90", strlen(sorry_uri.data())) == 0 );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_05>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-C/--cookie-name'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_06>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-C/--cookie-name' option value 'ABCDEfghij1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678' is too long." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij_1234567890");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_07>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-C/--cookie-name' option value 'ABCDEfghij_1234567890' is not alphanumeric character." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-C");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_08>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-C/--cookie-name'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_09>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot set multiple option '-C/--cookie-name'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("-R");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_10>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-E/--cookie-expire'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("123abc");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_11>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-E/--cookie-expire' option value '123abc' is not numeric character." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("2147483648"); //INT_MAX + 1
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_12>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-E/--cookie-expire' option value '2147483648' is too large." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_13>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-E/--cookie-expire'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_14>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot set multiple option '-E/--cookie-expire'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-R");
- args.push_back("-N");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_15>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to choose either of reschedule or no-reschedule." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-N");
- args.push_back("-R");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_16>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to choose either of reschedule or no-reschedule." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-S");
- args.push_back("-F");
- args.push_back("-N");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_17>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-S/--sorry-uri'." );
-
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F900");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_18>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-S/--sorry-uri' option value '/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F900' is too long." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/~a0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_19>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "'-S/--sorry-uri' option value '/~a0$-_.+!*'(),%00%0a%0A%A0%Aa%AA' is not a valid URI." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_20>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "You have to set option value '-S/--sorry-uri'." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_21>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot set multiple option '-S/--sorry-uri'." );
-
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- args.push_back("-C");
- args.push_back("ABCDEfghij1234567890");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-N");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA");
- args.push_back("-X");
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_22>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Option error." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- check_result = set_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<set_parameter_23>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-
- BOOST_CHECK( memcmp( cookie_name.data(), "CookieName", strlen(cookie_name.data())) == 0 );
- BOOST_CHECK( cookie_expire == 86400 );
- BOOST_CHECK( forwarded_for == 0 );
- BOOST_CHECK( reschedule == 0 );
- BOOST_CHECK( strlen(sorry_uri.data()) == 0 );
-
-}
-
-void add_parameter_test()
-{
-
- check_message_result check_result;
- std::vector<std::string> args;
-
-
-//-------------------------------------------------------------
- args.push_back("-C");
- args.push_back("ABCDEfghij123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
- args.push_back("-E");
- args.push_back("2147483647"); //INT_MAX
- args.push_back("-F");
- args.push_back("-R");
- args.push_back("-S");
- args.push_back("/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F9%Ff%FF/Aa0$-_.+!*'(),%00%0a%0A%A0%Aa%AA/zZ9$-_.+!*'(),%99%9f%9F%F90");
-
- check_result = add_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<add_parameter_01>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == false );
- BOOST_CHECK( check_result.message == "Cannot add option." );
-//-------------------------------------------------------------
- args.erase( args.begin(), args.end());
-
- check_result = add_parameter(args);
-
- std::cout << std::endl;
- std::cout << "<add_parameter_02>" << std::endl;
- std::cout << "check_result.flag = [" << check_result.flag << "]" << std::endl;
- std::cout << "check_result.message = [" << check_result.message << "]" << std::endl;
-
- BOOST_CHECK( check_result.flag == true );
- BOOST_CHECK( check_result.message == "" );
-}
-
-void handle_client_recv_test()
-{
-
- boost::array< char, MAX_BUFFER_SIZE > recvbuffer;
- size_t recvlen;
-
- t_session_thread_data_map_itr thread_data_itr;
-
- protocol_module_cinsert::EVENT_TAG status;
-
- std::string data;
-
- data = "PUT /abc/def/ HTTP/1.0\r\n";
- data += "Cookie: 10.10.10.10:11111;\r\n";
- data += "X-Forwarded-For: 20.20.20.20\r\n";
- data += "CONTENT-LENGTH:100\r\n\r\n";
- data += "abcdefghij1234567890abcdefghij1234567890abcdefghij";
- data += "1234567890abcdefghij1234567890abcdefghij1234567890";
-
- data += "GET /abc/def/ HTTP/1.0\r\n";
- data += "Cookie: 20.20.20.20:22222;\r\n";
- data += "X-Forwarded-For: 20.20.20.20\r\n\r\n";
-
- data += "HEAD /abc/def/ HTTP/1.0\r\n";
- data += "Cookie: 20.20.20.20:22222;\r\n";
- data += "X-Forwarded-For: 20.20.20.20\r\n";
- data += "CONTENT-LENGTH:200\r\n\r\n";
- data += "abcdefghij1234567890abcdefghij1234567890abcdefghij";
- data += "1234567890abcdefghij1234567890abcdefghij1234567890";
- data += "abcdefghij1234567890abcdefghij1234567890abcdefghij";
-
- recvbuffer.assign('\0');
- memcpy( recvbuffer.data(), data.c_str(), strlen(data.c_str()));
-
- recvlen = strlen(recvbuffer.data());
+ {
+ send_status_itr->status = SEND_END;
+ }
+ }
- session_thread_data_set();
+ send_status_itr++;
- thread_data_itr = session_thread_data_map.begin();
+ }
- while( thread_data_itr != session_thread_data_map.end())
- {
- if( thread_data_itr->second->thread_division == THREAD_DIVISION_UP_STREAM )
- {
- break;
}
- thread_data_itr++;
+
}
- status = handle_client_recv( thread_data_itr->second->thread_id, recvbuffer, recvlen );
+}
- session_thread_data_disp();
- session_thread_data_send( thread_data_itr->second->thread_id,
- thread_data_itr->second->client_endpoint_tcp );
+void session_thread_data_erase()
+{
- session_thread_data_disp();
+ t_session_thread_data_map_itr thread_data_itr;
- data = "abcdefghij1234567890abcdefghij1234567890abcdefghij";
+ thread_data_itr = session_thread_data_map.begin();
- data += "PUT /abc/def/ HTTP/1.0\r\n";
- data += "Cookie: 10.10.10.10:11111;\r\n";
- data += "X-Forwarded-For: 20.20.20.20\r\n";
- data += "CONTENT-LENGTH:50\r\n\r\n";
- data += "abcdefghij1234567890";
+ std::cout << "session_thread_data_erase" << std::endl;
- recvbuffer.assign('\0');
- memcpy( recvbuffer.data(), data.c_str(), strlen(data.c_str()));
+ session_thread_data_cinsert* thread_data;
- recvlen = strlen(recvbuffer.data());
+ thread_data = new session_thread_data_cinsert;
- status = handle_client_recv( thread_data_itr->second->thread_id, recvbuffer, recvlen );
+ delete thread_data;
- session_thread_data_disp();
+ while( thread_data_itr != session_thread_data_map.end() )
+ {
+ session_thread_data_map.erase(thread_data_itr);
+ thread_data_itr = session_thread_data_map.begin();
+ }
}
+
void handle_client_send_test()
{
// session_thread_data_disp();
}
-};
+void handle_realserver_select_test()
+{
+ t_session_thread_data_map_itr thread_data_itr;
+ protocol_module_cinsert::EVENT_TAG status;
+ boost::asio::ip::tcp::endpoint default_endpoint;
+ boost::asio::ip::tcp::endpoint rs_endpoint = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "10.144.169.86" ), 21 ) ;
+ boost::asio::ip::tcp::endpoint rs_endpoint2 = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "10.144.169.87" ), 22 ) ;
+ boost::asio::ip::tcp::endpoint tcp_endpoint;
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//--test functions--
-//-------------------------------------------------------------------
-void get_name_test_thread(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1,
- int thread_no,
- bool* ret )
-{
- for( int i = 0; i < THREAD_LOOP_NUM; i++ )
- {
- protocol_module_cinsert_test_1->get_name_test_thread( thread_no, ret );
- }
-}
+ session_thread_data_set();
-void get_name_test()
-{
- bool thread_1;
- bool thread_2;
- bool thread_3;
- bool thread_4;
- bool thread_5;
+ // unit_test[x4_43] handle_realserver_selectのテスト(存在しないID STOP)
+ boost::thread::id thread_id;
+ status = handle_realserver_select( thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ // unit_test[x4_44] handle_realserver_selectのテスト(send_status無し CLIENT_STOP)
+ thread_data_itr = session_thread_data_map.begin();
- BOOST_MESSAGE( "----- get_name test start -----" );
- protocol_module_cinsert_test_1.get_name_test();
- BOOST_MESSAGE( "----- get_name test end -----" );
-
- BOOST_MESSAGE( "----- get_name test multi thread start -----" );
- boost::thread t1( boost::bind( &get_name_test_thread,
- &protocol_module_cinsert_test_1, 1, &thread_1));
- boost::thread t2( boost::bind( &get_name_test_thread,
- &protocol_module_cinsert_test_1, 2, &thread_2));
- boost::thread t3( boost::bind( &get_name_test_thread,
- &protocol_module_cinsert_test_1, 3, &thread_3));
- boost::thread t4( boost::bind( &get_name_test_thread,
- &protocol_module_cinsert_test_1, 4, &thread_4));
- boost::thread t5( boost::bind( &get_name_test_thread,
- &protocol_module_cinsert_test_1, 5, &thread_5));
-
- sleep(1);
-
- protocol_module_cinsert_test_1.sync_condition.notify_all();
-
- t1.join();
- t2.join();
- t3.join();
- t4.join();
- t5.join();
-
- BOOST_CHECK( thread_1 == true );
- BOOST_CHECK( thread_2 == true );
- BOOST_CHECK( thread_3 == true );
- BOOST_CHECK( thread_4 == true );
- BOOST_CHECK( thread_5 == true );
-
- BOOST_MESSAGE( "----- get_name test multi thread end -----" );
-}
-//-------------------------------------------------------------------
-void is_tcp_test_thread(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1,
- int thread_no,
- bool* ret )
-{
- for( int i = 0; i < THREAD_LOOP_NUM; i++ )
+ while( thread_data_itr != session_thread_data_map.end())
{
- protocol_module_cinsert_test_1->is_tcp_test_thread( thread_no, ret );
+ if( thread_data_itr->second->thread_division == THREAD_DIVISION_UP_STREAM )
+ {
+ break;
+ }
+ thread_data_itr++;
}
-}
-void is_tcp_test()
-{
- bool thread_1;
- bool thread_2;
- bool thread_3;
- bool thread_4;
- bool thread_5;
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ // unit_test[x4_45] handle_realserver_selectのテスト(endpoint有り REALSERVER_CONNECT)
+ t_recive_data_map_itr recive_data_itr;
+ send_status send_status_add;
- BOOST_MESSAGE( "----- is_tcp test start -----" );
- protocol_module_cinsert_test_1.is_tcp_test();
- BOOST_MESSAGE( "----- is_tcp test end -----" );
-
- BOOST_MESSAGE( "----- is_tcp test multi thread start -----" );
- boost::thread t1( boost::bind( &is_tcp_test_thread,
- &protocol_module_cinsert_test_1, 1, &thread_1));
- boost::thread t2( boost::bind( &is_tcp_test_thread,
- &protocol_module_cinsert_test_1, 2, &thread_2));
- boost::thread t3( boost::bind( &is_tcp_test_thread,
- &protocol_module_cinsert_test_1, 3, &thread_3));
- boost::thread t4( boost::bind( &is_tcp_test_thread,
- &protocol_module_cinsert_test_1, 4, &thread_4));
- boost::thread t5( boost::bind( &is_tcp_test_thread,
- &protocol_module_cinsert_test_1, 5, &thread_5));
-
- sleep(1);
-
- protocol_module_cinsert_test_1.sync_condition.notify_all();
-
- t1.join();
- t2.join();
- t3.join();
- t4.join();
- t5.join();
-
- BOOST_CHECK( thread_1 == true );
- BOOST_CHECK( thread_2 == true );
- BOOST_CHECK( thread_3 == true );
- BOOST_CHECK( thread_4 == true );
- BOOST_CHECK( thread_5 == true );
-
- BOOST_MESSAGE( "----- is_tcp test multi thread end -----" );
-}
-//-------------------------------------------------------------------
-void is_udp_test_thread(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1,
- int thread_no,
- bool* ret )
-{
- for( int i = 0; i < THREAD_LOOP_NUM; i++ )
- {
- protocol_module_cinsert_test_1->is_udp_test_thread( thread_no, ret );
- }
-}
+ send_status_add.status = SEND_NG;
+ send_status_add.send_end_size = 0;
+ send_status_add.send_rest_size = 0;
+ send_status_add.send_possible_size = 0;
+ send_status_add.unsend_size = 0;
+ send_status_add.edit_division = 0;
+ send_status_add.send_offset = 0;
-void is_udp_test()
-{
- bool thread_1;
- bool thread_2;
- bool thread_3;
- bool thread_4;
- bool thread_5;
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ thread_data_itr->second->sorry_flag = SORRY_FLAG_OFF;
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ recive_data_itr = thread_data_itr->second->recive_data_map.begin();
- BOOST_MESSAGE( "----- is_udp test start -----" );
- protocol_module_cinsert_test_1.is_udp_test();
- BOOST_MESSAGE( "----- is_udp test end -----" );
-
- BOOST_MESSAGE( "----- is_udp test multi thread start -----" );
- boost::thread t1( boost::bind( &is_udp_test_thread,
- &protocol_module_cinsert_test_1, 1, &thread_1));
- boost::thread t2( boost::bind( &is_udp_test_thread,
- &protocol_module_cinsert_test_1, 2, &thread_2));
- boost::thread t3( boost::bind( &is_udp_test_thread,
- &protocol_module_cinsert_test_1, 3, &thread_3));
- boost::thread t4( boost::bind( &is_udp_test_thread,
- &protocol_module_cinsert_test_1, 4, &thread_4));
- boost::thread t5( boost::bind( &is_udp_test_thread,
- &protocol_module_cinsert_test_1, 5, &thread_5));
-
- sleep(1);
-
- protocol_module_cinsert_test_1.sync_condition.notify_all();
-
- t1.join();
- t2.join();
- t3.join();
- t4.join();
- t5.join();
-
- BOOST_CHECK( thread_1 == true );
- BOOST_CHECK( thread_2 == true );
- BOOST_CHECK( thread_3 == true );
- BOOST_CHECK( thread_4 == true );
- BOOST_CHECK( thread_5 == true );
-
- BOOST_MESSAGE( "----- is_udp test multi thread end -----" );
-}
-//-------------------------------------------------------------------
-void is_use_sorry_test_thread(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1,
- int thread_no,
- bool* ret )
-{
- for( int i = 0; i < THREAD_LOOP_NUM; i++ )
+ if( recive_data_itr != thread_data_itr->second->recive_data_map.end() )
{
- protocol_module_cinsert_test_1->is_use_sorry_test_thread( thread_no, ret );
+ thread_data_itr->second->last_endpoint_tcp = recive_data_itr->first;
+//std::cout << thread_data_itr->second->last_endpoint_tcp.address() << ":" << thread_data_itr->second->last_endpoint_tcp.port() << "\n";
+
+ send_status_add.status = SEND_OK;
+ send_status_add.send_endpoint = rs_endpoint;
+ recive_data_itr->second.send_status_list.push_back( send_status_add );
+
+ BOOST_CHECK_EQUAL( recive_data_itr->second.send_status_list.size(), ( size_t )1 );
}
-}
-void is_use_sorry_test()
-{
- bool thread_1;
- bool thread_2;
- bool thread_3;
- bool thread_4;
- bool thread_5;
+ t_send_status_list_itr send_status_itr = recive_data_itr->second.send_status_list.begin();
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_CONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, rs_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- BOOST_MESSAGE( "----- is_use_sorry test start -----" );
- protocol_module_cinsert_test_1.is_use_sorry_test();
- BOOST_MESSAGE( "----- is_use_sorry test end -----" );
-
- BOOST_MESSAGE( "----- is_use_sorry test multi thread start -----" );
- boost::thread t1( boost::bind( &is_use_sorry_test_thread,
- &protocol_module_cinsert_test_1, 1, &thread_1));
- boost::thread t2( boost::bind( &is_use_sorry_test_thread,
- &protocol_module_cinsert_test_1, 2, &thread_2));
- boost::thread t3( boost::bind( &is_use_sorry_test_thread,
- &protocol_module_cinsert_test_1, 3, &thread_3));
- boost::thread t4( boost::bind( &is_use_sorry_test_thread,
- &protocol_module_cinsert_test_1, 4, &thread_4));
- boost::thread t5( boost::bind( &is_use_sorry_test_thread,
- &protocol_module_cinsert_test_1, 5, &thread_5));
-
- sleep(1);
-
- protocol_module_cinsert_test_1.sync_condition.notify_all();
-
- t1.join();
- t2.join();
- t3.join();
- t4.join();
- t5.join();
-
- BOOST_CHECK( thread_1 == true );
- BOOST_CHECK( thread_2 == true );
- BOOST_CHECK( thread_3 == true );
- BOOST_CHECK( thread_4 == true );
- BOOST_CHECK( thread_5 == true );
-
- BOOST_MESSAGE( "----- is_use_sorry test multi thread end -----" );
-}
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-void session_thread_data_map_lock(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1 )
-{
- protocol_module_cinsert_test_1->session_thread_data_map_lock();
-}
+ // unit_test[x4_46] handle_realserver_selectのテスト(SEND_OK無し=SEND_NG STOP)
+ send_status_itr->status = SEND_NG;
-void handle_session_initialize_test_thread(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1,
- int thread_no,
- bool* ret )
-{
- for( int i = 0; i < THREAD_LOOP_NUM; i++ )
- {
- protocol_module_cinsert_test_1->handle_session_initialize_test_thread( thread_no, ret );
- }
-}
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_NG );
-void handle_session_initialize_test()
-{
+ // unit_test[x4_47] handle_realserver_selectのテスト(SEND_OK無し=SEND_CONTINUE STOP)
+ send_status_itr->status = SEND_CONTINUE;
- bool thread_1;
- bool thread_2;
- bool thread_3;
- bool thread_4;
- bool thread_5;
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_CONTINUE );
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ // unit_test[x4_48] handle_realserver_selectのテスト(SEND_OK無し=SEND_END STOP)
+ send_status_itr->status = SEND_END;
- BOOST_MESSAGE( "----- handle_session_initialize test start -----" );
- protocol_module_cinsert_test_1.handle_session_initialize_test();
- BOOST_MESSAGE( "----- handle_session_initialize test end -----" );
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_END );
- BOOST_MESSAGE( "----- handle_session_initialize test multi thread start -----" );
- boost::thread t0( boost::bind( &session_thread_data_map_lock,
- &protocol_module_cinsert_test_1));
+ // unit_test[x4_49] handle_realserver_selectのテスト(endpoint無しCookie無しschedule結果無し REALSERVER_DISCONNECT)
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule1;
+ send_status_itr->send_endpoint = default_endpoint;
- sleep(1);
+ send_status_itr->status = SEND_OK;
- boost::thread t1( boost::bind( &handle_session_initialize_test_thread,
- &protocol_module_cinsert_test_1, 1, &thread_1));
- boost::thread t2( boost::bind( &handle_session_initialize_test_thread,
- &protocol_module_cinsert_test_1, 2, &thread_2));
- boost::thread t3( boost::bind( &handle_session_initialize_test_thread,
- &protocol_module_cinsert_test_1, 3, &thread_3));
- boost::thread t4( boost::bind( &handle_session_initialize_test_thread,
- &protocol_module_cinsert_test_1, 4, &thread_4));
- boost::thread t5( boost::bind( &handle_session_initialize_test_thread,
- &protocol_module_cinsert_test_1, 5, &thread_5));
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_DISCONNECT );
+ BOOST_CHECK( thread_data_itr->second->end_flag == END_FLAG_ON );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- sleep(1);
+ // unit_test[x4_50] handle_realserver_selectのテスト(endpoint無しCookie無しschedule結果有り REALSERVER_CONNECT)
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule2;
+ send_status_itr->send_endpoint = default_endpoint;
- protocol_module_cinsert_test_1.sync_condition.notify_all();
+ send_status_itr->status = SEND_OK;
- sleep(1);
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_CONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, rs_endpoint2 );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- protocol_module_cinsert_test_1.session_thread_data_map_condition.notify_all();
+ // unit_test[x4_51] handle_realserver_selectのテスト(endpoint無しCookie有り該当結果有りrealserver_list無し STOP)
+ std::string data;
- sleep(1);
+ data = "HTTP/1.0 100 abcd\r\n";
+ data += "Cookie: CookieName=10.10.10.10:11111;\r\n";
+ data += "X-Forwarded-For: 20.20.20.20\r\n";
+ data += "CONTENT-LENGTH:100\r\n\r\n";
+ data += "abcdefghij1234567890abcdefghij1234567890abcdefghij";
+ data += "1234567890abcdefghij1234567890abcdefghij1234567890";
- protocol_module_cinsert_test_1.sync_condition.notify_all();
+ strcpy( recive_data_itr->second.recive_buffer, data.c_str() );
+ recive_data_itr->second.recive_buffer_rest_size -= data.size();
+ send_status_itr->send_possible_size = data.size();
+ memcpy( cookie_name.data(), "CookieName", sizeof( "CookieName" ) );
- t1.join();
- t2.join();
- t3.join();
- t4.join();
- t5.join();
- BOOST_CHECK( thread_1 == true );
- BOOST_CHECK( thread_2 == true );
- BOOST_CHECK( thread_3 == true );
- BOOST_CHECK( thread_4 == true );
- BOOST_CHECK( thread_5 == true );
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule1;
+ send_status_itr->send_endpoint = default_endpoint;
- BOOST_MESSAGE( "----- handle_session_initialize test multi thread end -----" );
-}
-//-------------------------------------------------------------------
-void handle_session_finalize_test_thread(
- protocol_module_cinsert_test* protocol_module_cinsert_test_1,
- int thread_no,
- bool* ret )
-{
- for( int i = 0; i < THREAD_LOOP_NUM; i++ )
- {
- protocol_module_cinsert_test_1->handle_session_finalize_test_thread( thread_no, ret );
- }
-}
+ send_status_itr->status = SEND_OK;
-void handle_session_finalize_test()
-{
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- bool thread_1;
- bool thread_2;
- bool thread_3;
- bool thread_4;
- bool thread_5;
+ // unit_test[x4_52] handle_realserver_selectのテスト(endpoint無しCookie有り該当結果有りrealserver無し REALSERVER_DISCONNECT)
+ l7vs::protocol_module_base::realserverlist_type rs_list;
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ rs_list_begin = boost::bind( &list_begin, &rs_list );
+ rs_list_end = boost::bind( &list_end, &rs_list );
+ rs_list_next = boost::bind( &list_next, _1 );
- BOOST_MESSAGE( "----- handle_session_finalize test start -----" );
- protocol_module_cinsert_test_1.handle_session_finalize_test();
- BOOST_MESSAGE( "----- handle_session_initialize test end -----" );
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule1;
+ send_status_itr->send_endpoint = default_endpoint;
- BOOST_MESSAGE( "----- handle_session_finalize test multi thread start -----" );
- boost::thread t0( boost::bind( &session_thread_data_map_lock,
- &protocol_module_cinsert_test_1));
+ send_status_itr->status = SEND_OK;
- sleep(1);
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_DISCONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- boost::thread t1( boost::bind( &handle_session_finalize_test_thread,
- &protocol_module_cinsert_test_1, 1, &thread_1));
- boost::thread t2( boost::bind( &handle_session_finalize_test_thread,
- &protocol_module_cinsert_test_1, 2, &thread_2));
- boost::thread t3( boost::bind( &handle_session_finalize_test_thread,
- &protocol_module_cinsert_test_1, 3, &thread_3));
- boost::thread t4( boost::bind( &handle_session_finalize_test_thread,
- &protocol_module_cinsert_test_1, 4, &thread_4));
- boost::thread t5( boost::bind( &handle_session_finalize_test_thread,
- &protocol_module_cinsert_test_1, 5, &thread_5));
+ // unit_test[x4_53] handle_realserver_selectのテスト(endpoint無しCookie有り該当結果有りrealserver無し強制再設定schedule結果有り REALSERVER_CONNECT)
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule2;
+ send_status_itr->send_endpoint = default_endpoint;
+ reschedule = 1;
- sleep(1);
+ send_status_itr->status = SEND_OK;
- protocol_module_cinsert_test_1.sync_condition.notify_all();
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_CONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, rs_endpoint2 );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- sleep(1);
+ // unit_test[x4_54] handle_realserver_selectのテスト(endpoint無しCookie有り該当結果有りrealserver無し強制再設定schedule結果無し REALSERVER_DISCONNECT)
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule1;
+ send_status_itr->send_endpoint = default_endpoint;
+ reschedule = 1;
- protocol_module_cinsert_test_1.session_thread_data_map_condition.notify_all();
+ send_status_itr->status = SEND_OK;
- sleep(1);
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_DISCONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
- protocol_module_cinsert_test_1.sync_condition.notify_all();
+ // unit_test[x4_55] handle_realserver_selectのテスト(endpoint無しCookie有り該当結果有りrealserver有り REALSERVER_CONNECT)
+ reschedule = 0;
+ l7vs::realserver server1, server2, server3, server4;
+
+// l7vs::protocol_module_base::rs_list_itr_func_type rslist_begin;
+// l7vs::protocol_module_base::rs_list_itr_func_type rslist_end;
+// l7vs::protocol_module_base::rs_list_itr_next_func_type rslist_next;
+
+ server1.tcp_endpoint = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "10.10.10.10" ), 11111 ) ;
+ server1.weight = 1;
+ rs_list.push_back( server1 );
+ server2.tcp_endpoint = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "20.20.20.20" ), 22222 ) ;
+ server2.weight = 2;
+ rs_list.push_back( server2 );
+ server3.tcp_endpoint = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "30.30.30.30" ), 33333 ) ;
+ server3.weight = 3;
+ rs_list.push_back( server3 );
+ server4.tcp_endpoint = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "40.40.40.40" ), 44444 ) ;
+ server4.weight = 4;
+ rs_list.push_back( server4 );
- t1.join();
- t2.join();
- t3.join();
- t4.join();
- t5.join();
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule1;
+ send_status_itr->send_endpoint = default_endpoint;
- BOOST_CHECK( thread_1 == true );
- BOOST_CHECK( thread_2 == true );
- BOOST_CHECK( thread_3 == true );
- BOOST_CHECK( thread_4 == true );
- BOOST_CHECK( thread_5 == true );
+ send_status_itr->status = SEND_OK;
- BOOST_MESSAGE( "----- handle_session_finalize test multi thread end -----" );
-}
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_CONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, server1.tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
-// void session_thread_data_set_test()
-// {
-//
-// protocol_module_cinsert_test protocol_module_cinsert_test_1;
-//
-// protocol_module_cinsert_test_1.session_thread_data_set();
-//
-// protocol_module_cinsert_test_1.session_thread_data_disp();
-//
-// protocol_module_cinsert_test_1.session_thread_data_erase();
-//
-// }
-
-void check_parameter_test()
-{
+ // unit_test[x4_56] handle_realserver_selectのテスト(endpoint無しCookie有り該当結果有りrealserver有り強制再設定無視 REALSERVER_CONNECT)
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ schedule_tcp.clear();
+ schedule_tcp = handle_schedule2;
+ send_status_itr->send_endpoint = default_endpoint;
+ reschedule = 1;
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ send_status_itr->status = SEND_OK;
- BOOST_MESSAGE( "----- check_parameter test start -----" );
- protocol_module_cinsert_test_1.check_parameter_test();
- BOOST_MESSAGE( "----- check_parameter test end -----" );
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, REALSERVER_CONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, server1.tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
-}
-void set_parameter_test()
-{
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
- BOOST_MESSAGE( "----- set_parameter test start -----" );
- protocol_module_cinsert_test_1.set_parameter_test();
- BOOST_MESSAGE( "----- set_parameter test end -----" );
-}
-void add_parameter_test()
-{
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
- BOOST_MESSAGE( "----- add_parameter test start -----" );
- protocol_module_cinsert_test_1.add_parameter_test();
- BOOST_MESSAGE( "----- add_parameter test end -----" );
+ // unit_test[x4_57] handle_realserver_selectのテスト(receive_data無し あり得ないけどやられたらSTOP)
+ thread_data_itr->second->recive_data_map.clear();
+ BOOST_CHECK_EQUAL( thread_data_itr->second->recive_data_map.size(), ( size_t )0 );
+
+ status = handle_realserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+// session_thread_data_disp();
}
-void handle_client_recv_test()
+void handle_sorryserver_select_test()
{
- protocol_module_cinsert_test protocol_module_cinsert_test_1;
+ t_session_thread_data_map_itr thread_data_itr;
+
+ protocol_module_cinsert::EVENT_TAG status;
+ boost::asio::ip::tcp::endpoint tcp_endpoint = boost::asio::ip::tcp::endpoint ( boost::asio::ip::address::from_string( "10.144.169.86" ), 21 ) ;
+
+ session_thread_data_set();
+
+ // unit_test[x4_58] handle_sorryserver_selectのテスト(存在しないID STOP)
+ boost::thread::id thread_id;
+ status = handle_sorryserver_select( thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+
+ // unit_test[x4_59] handle_sorryserver_selectのテスト(send_status無し STOP)
+ thread_data_itr = session_thread_data_map.begin();
+
+ while( thread_data_itr != session_thread_data_map.end())
+ {
+ if( thread_data_itr->second->thread_division == THREAD_DIVISION_UP_STREAM )
+ {
+ break;
+ }
+ thread_data_itr++;
+ }
+
+ status = handle_sorryserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+
+// thread_data_itr->second->sorry_flag = SORRY_FLAG_ON;
+
+ // unit_test[x4_60] handle_sorryserver_selectのテスト(SORRYSERVER_CONNECT)
+ t_recive_data_map_itr recive_data_itr;
+ send_status send_status_add;
+
+ send_status_add.status = SEND_NG;
+ send_status_add.send_end_size = 0;
+ send_status_add.send_rest_size = 0;
+ send_status_add.send_possible_size = 0;
+ send_status_add.unsend_size = 0;
+ send_status_add.edit_division = 0;
+ send_status_add.send_offset = 0;
+
+ thread_data_itr->second->end_flag = END_FLAG_OFF;
+ thread_data_itr->second->sorry_flag = SORRY_FLAG_OFF;
+
+ recive_data_itr = thread_data_itr->second->recive_data_map.begin();
+
+ if( recive_data_itr != thread_data_itr->second->recive_data_map.end() )
+ {
+ thread_data_itr->second->last_endpoint_tcp = recive_data_itr->first;
+//std::cout << thread_data_itr->second->last_endpoint_tcp.address() << ":" << thread_data_itr->second->last_endpoint_tcp.port() << "\n";
+
+ send_status_add.status = SEND_OK;
+ recive_data_itr->second.send_status_list.push_back( send_status_add );
+
+ BOOST_CHECK_EQUAL( recive_data_itr->second.send_status_list.size(), ( size_t )1 );
+ }
+
+ t_send_status_list_itr send_status_itr = recive_data_itr->second.send_status_list.begin();
+
+ status = handle_sorryserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, SORRYSERVER_CONNECT );
+ BOOST_CHECK_EQUAL( send_status_itr->send_endpoint, tcp_endpoint );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_OK );
+
+ // unit_test[x4_61] handle_sorryserver_selectのテスト(SEND_OK無し=SEND_NG STOP)
+ send_status_itr->status = SEND_NG;
+
+ status = handle_sorryserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_NG );
+
+ // unit_test[x4_62] handle_sorryserver_selectのテスト(SEND_OK無し=SEND_CONTINUE STOP)
+ send_status_itr->status = SEND_CONTINUE;
+
+ status = handle_sorryserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_CONTINUE );
+
+ // unit_test[x4_63] handle_sorryserver_selectのテスト(SEND_OK無し=SEND_END STOP)
+ send_status_itr->status = SEND_END;
+
+ status = handle_sorryserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+ BOOST_CHECK_EQUAL( send_status_itr->status, SEND_END );
+
+ // unit_test[x4_64] handle_sorryserver_selectのテスト(receive_data無し あり得ないけどやられたらSTOP)
+ thread_data_itr->second->recive_data_map.clear();
+ BOOST_CHECK_EQUAL( thread_data_itr->second->recive_data_map.size(), ( size_t )0 );
- BOOST_MESSAGE( "----- handle_client_recv test start -----" );
- protocol_module_cinsert_test_1.handle_client_recv_test();
- BOOST_MESSAGE( "----- handle_client_recv test end -----" );
+ status = handle_sorryserver_select( thread_data_itr->second->thread_id, tcp_endpoint );
+ BOOST_CHECK_EQUAL( status, STOP );
+// session_thread_data_disp();
}
+};
+
+
+
+//-------------------------------------------------------------------
+//-------------------------------------------------------------------
+//-------------------------------------------------------------------
+//-------------------------------------------------------------------
+//--test functions--
+//-------------------------------------------------------------------
void handle_client_send_test()
{
}
+
+void handle_realserver_select_test()
+{
+
+ protocol_module_cinsert_test protocol_module_cinsert_test_1;
+
+ // unit_test[x4_]
+ BOOST_MESSAGE( "----- handle_realserver_select test start -----" );
+ protocol_module_cinsert_test_1.handle_realserver_select_test();
+ BOOST_MESSAGE( "----- handle_realserver_select test end -----" );
+
+}
+
+void handle_sorryserver_select_test()
+{
+
+ protocol_module_cinsert_test protocol_module_cinsert_test_1;
+
+ // unit_test[x4_]
+ BOOST_MESSAGE( "----- handle_sorryserver_select test start -----" );
+ protocol_module_cinsert_test_1.handle_sorryserver_select_test();
+ BOOST_MESSAGE( "----- handle_sorryserver_select test end -----" );
+
+}
+
+
//-------------------------------------------------------------------
//-------------------------------------------------------------------
test_suite* init_unit_test_suite( int argc, char* argv[] ){
ts->add( BOOST_TEST_CASE( &handle_realserver_send_test ) );
ts->add( BOOST_TEST_CASE( &handle_sorryserver_send_test ) );
+ ts->add( BOOST_TEST_CASE( &handle_realserver_select_test ) );
+// ts->add( BOOST_TEST_CASE( &handle_sorryserver_select_test ) );
+
framework::master_test_suite().add( ts );
return 0;