More tests update
[ACE_TAO.git] / TAO / tests / MProfile_Forwarding / client.cpp
blob336242aaf5d5f7ab6d0d20655d0bd04f2140c9d3
1 #include "ace/SString.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "testC.h"
6 const ACE_TCHAR *ior_input_file = 0;
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'o':
18 ior_input_file = get_opts.opt_arg ();
19 break;
20 case '?':
21 default:
22 ACE_ERROR_RETURN ((LM_ERROR,
23 "usage: %s "
24 "-o <iorfile>"
25 "\n",
26 argv [0]),
27 -1);
29 // Indicates successful parsing of the command line
30 return 0;
33 void
34 run_test (Simple_Server_ptr server);
36 int
37 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
40 try
42 CORBA::ORB_var orb =
43 CORBA::ORB_init (argc, argv);
45 if (parse_args (argc, argv) == -1)
46 return -1;
48 CORBA::Object_var objref =
49 orb->string_to_object (ior_input_file);
51 if (objref.in () == 0)
53 //FUZZ: disable check_for_NULL
54 ACE_ERROR_RETURN ((LM_ERROR,
55 "The received objref is NULL\n"),
56 -1);
57 //FUZZ: enable check_for_NULL
60 Simple_Server_var server =
61 Simple_Server::_narrow (objref.in ());
63 if (CORBA::is_nil (server.in ()))
65 ACE_ERROR_RETURN ((LM_ERROR,
66 "Object reference is nil\n"),
67 -1);
70 run_test (server.in ());
72 catch (const CORBA::Exception& ex)
74 ex._tao_print_exception ("Caught an exception\n");
75 return -1;
77 return 0;
80 void run_test (Simple_Server_ptr server)
82 for (int loop = 0; loop < 10; loop++)
84 try
86 ACE_DEBUG ((LM_DEBUG,
87 "About to make remote call\n"));
88 ACE_OS::sleep (2);
90 // Make a remote call
91 server->remote_call ();
93 /*ACE_DEBUG ((LM_DEBUG,
94 "Kill the primary . . . "));
95 ACE_OS::sleep (25);
96 ACE_DEBUG ((LM_DEBUG, " hope you did\n")); */
97 ACE_DEBUG ((LM_DEBUG,
98 "I am going to shutdown\n"));
99 server->shutdown ();
100 ACE_OS::sleep (23);
102 catch (const CORBA::UserException& x)
104 x._tao_print_exception ("Caught an ");
106 catch (const CORBA::TRANSIENT& t)
108 t._tao_print_exception ("Caught Exception");
110 catch (const CORBA::COMM_FAILURE& f)
112 f._tao_print_exception ("A (sort of) expected COMM_FAILURE");
113 ACE_DEBUG ((LM_DEBUG,
114 "Automagically re-issuing request on COMM_FAILURE\n"));
116 catch (const CORBA::Exception& ex)
118 ex._tao_print_exception ("Unexpected exception");
119 throw;