Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / UNKNOWN_Exception / client.cpp
blobf7884f6c77ebc79158d1e803216e70d9f66b2362
1 #include "ace/Get_Opt.h"
2 #include "testC.h"
4 static const ACE_TCHAR *ior = ACE_TEXT("file://ior");
5 static int shutdown_server = 1;
7 static int
8 parse_args (int argc, ACE_TCHAR **argv)
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x:"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'k':
17 ior = get_opts.opt_arg ();
18 break;
20 case 'x':
21 shutdown_server = ACE_OS::atoi (get_opts.opt_arg ());
22 break;
24 case '?':
25 default:
26 ACE_ERROR_RETURN ((LM_ERROR,
27 "\nusage %s:\n"
28 "\t-k <ior> [defaults to %s]\n"
29 "\t-x <shutdown server> [defaults to %d]\n"
30 "\n",
31 argv [0],
32 ior,
33 shutdown_server),
34 -1);
37 return 0;
40 int
41 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
43 try
45 CORBA::ORB_var orb =
46 CORBA::ORB_init (argc, argv);
48 int const result = parse_args (argc, argv);
50 if (result != 0)
51 return result;
53 CORBA::Object_var object =
54 orb->string_to_object (ior);
56 test_factory_var test_factory =
57 test_factory::_narrow (object.in ());
59 test_var test =
60 test_factory->create_test ();
62 test->normal_method ();
64 int unknown_exception_raised = 0;
66 try
68 test->unknown_exception_in_method ();
70 catch (const CORBA::UNKNOWN&)
72 unknown_exception_raised = 1;
74 ACE_DEBUG ((LM_DEBUG,
75 "\nCORBA::UNKNOWN was thrown by the server during test::unknown_exception_in_method()\n"
76 "\tThis is expected behavior\n\n"));
79 if (unknown_exception_raised != 1)
81 ACE_ERROR_RETURN ((LM_ERROR,
82 "Failure: unknown excep not raised\n"),
83 -1);
86 unknown_exception_raised = 0;
88 test->unknown_exception_during_deactivation ();
90 if (shutdown_server)
91 test_factory->shutdown ();
93 orb->destroy ();
95 catch (...)
97 ACE_ERROR_RETURN ((LM_ERROR,
98 "Failure: Unexpected exception caught\n"),
99 -1);
102 return 0;