Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_2503_Regression / client.cpp
blobffddfc6886ada15234d85ec21964926e8c8c16fc
1 #include "test_i.h"
2 #include "common.h"
3 #include "ace/Get_Opt.h"
5 void parse_args(int argc, ACE_TCHAR * argv[]);
6 void test_remote_calls(CORBA::ORB_ptr orb);
7 void test_colocated_calls(CORBA::ORB_ptr orb);
9 int
10 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
12 try
14 ACE_DEBUG ((LM_DEBUG, "Starting client\n"));
15 CORBA::ORB_var orb = initialize_orb_and_poa(argc, argv);
17 parse_args(argc, argv);
19 ACE_DEBUG ((LM_DEBUG, "Testing remote\n"));
20 test_remote_calls(orb.in());
22 ACE_DEBUG ((LM_DEBUG, "Testing colocated\n"));
23 test_colocated_calls(orb.in());
25 ACE_DEBUG ((LM_DEBUG, "Testing ready\n"));
27 catch(...)
29 report_exception();
30 return 1;
33 return 0;
36 const ACE_TCHAR *ior_argument = ACE_TEXT("file://test.ior");
37 int niterations = 100;
39 void
40 parse_args (int argc, ACE_TCHAR *argv[])
42 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:i:"));
43 int c;
45 while ((c = get_opts ()) != -1)
47 switch (c)
49 case 'k':
50 ior_argument = get_opts.opt_arg ();
51 break;
53 case 'i':
54 niterations = ACE_OS::atoi (get_opts.opt_arg ());
55 break;
57 case '?':
58 default:
59 throw "Usage: [-k ior] [-i iteration_count]";
64 void test_impl(
65 CORBA::ORB_ptr orb,
66 ACE_TCHAR const * ior,
67 bool shutdown)
69 CORBA::Object_var object = orb->string_to_object(ior);
70 Test_var test = Test::_narrow(object.in());
72 if(CORBA::is_nil(test.in()))
74 throw "Nil reference after narrow";
77 for(int i = 0; i != niterations; ++i)
79 test->sendc_the_operation(AMI_TestHandler::_nil());
82 ACE_Time_Value wait_for_responses_interval(1, 0);
83 orb->run(wait_for_responses_interval);
85 if (shutdown)
86 test->shutdown ();
89 void test_remote_calls(CORBA::ORB_ptr orb)
91 test_impl(orb, ior_argument, true);
94 void test_colocated_calls(CORBA::ORB_ptr orb)
96 test_i servant (orb);
97 CORBA::String_var ior =
98 servant.create_and_activate_server();
100 test_impl(orb, ACE_TEXT_CHAR_TO_TCHAR(ior.in()), false);