Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / MProfile_Forwarding / client.cpp
blobf664cef6d66f24823fa441a63372e85b93cb41bb
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[])
39 try
41 CORBA::ORB_var orb =
42 CORBA::ORB_init (argc, argv);
44 if (parse_args (argc, argv) == -1)
45 return -1;
47 CORBA::Object_var objref =
48 orb->string_to_object (ior_input_file);
50 if (objref.in () == 0)
52 //FUZZ: disable check_for_NULL
53 ACE_ERROR_RETURN ((LM_ERROR,
54 "The received objref is NULL\n"),
55 -1);
56 //FUZZ: enable check_for_NULL
59 Simple_Server_var server =
60 Simple_Server::_narrow (objref.in ());
62 if (CORBA::is_nil (server.in ()))
64 ACE_ERROR_RETURN ((LM_ERROR,
65 "Object reference is nil\n"),
66 -1);
69 run_test (server.in ());
71 catch (const CORBA::Exception& ex)
73 ex._tao_print_exception ("Caught an exception\n");
74 return -1;
76 return 0;
79 void run_test (Simple_Server_ptr server)
81 for (int loop = 0; loop < 10; loop++)
83 try
85 ACE_DEBUG ((LM_DEBUG,
86 "About to make remote call\n"));
87 ACE_OS::sleep (2);
89 // Make a remote call
90 server->remote_call ();
92 /*ACE_DEBUG ((LM_DEBUG,
93 "Kill the primary . . . "));
94 ACE_OS::sleep (25);
95 ACE_DEBUG ((LM_DEBUG, " hope you did\n")); */
96 ACE_DEBUG ((LM_DEBUG,
97 "I am going to shutdown\n"));
98 server->shutdown ();
99 ACE_OS::sleep (23);
101 catch (const CORBA::UserException& x)
103 x._tao_print_exception ("Caught an ");
105 catch (const CORBA::TRANSIENT& t)
107 t._tao_print_exception ("Caught Exception");
109 catch (const CORBA::COMM_FAILURE& f)
111 f._tao_print_exception ("A (sort of) expected COMM_FAILURE");
112 ACE_DEBUG ((LM_DEBUG,
113 "Automagically re-issuing request on COMM_FAILURE\n"));
115 catch (const CORBA::Exception& ex)
117 ex._tao_print_exception ("Unexpected exception");
118 throw;