Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Native_Exceptions / client.cpp
blob63b684827459a14373273d881af78282bd2c46f5
1 #include "ace/Get_Opt.h"
2 #include "testC.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
5 int niterations = 100;
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:i:"));
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 'i':
21 niterations = ACE_OS::atoi (get_opts.opt_arg ());
22 break;
24 case '?':
25 default:
26 ACE_ERROR_RETURN ((LM_ERROR,
27 "usage: %s "
28 "-k <ior> "
29 "-i <niterations> "
30 "\n",
31 argv [0]),
32 -1);
34 // Indicates successful parsing of the command line
35 return 0;
38 int
39 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
41 try
43 CORBA::ORB_var orb =
44 CORBA::ORB_init (argc, argv);
46 if (parse_args (argc, argv) != 0)
47 return 1;
49 CORBA::Object_var object =
50 orb->string_to_object (ior);
52 Simple_Server_var server =
53 Simple_Server::_narrow (object.in ());
55 if (CORBA::is_nil (server.in ()))
57 ACE_ERROR_RETURN ((LM_ERROR,
58 "Object reference <%s> is nil.\n",
59 ior),
60 1);
63 for (int i = 0; i != niterations; ++i)
65 if (server->test_method (i) != i)
67 ACE_ERROR ((LM_ERROR,
68 "Unexpected result from test_method\n"));
71 try
73 server->test_raise (i);
74 ACE_ERROR ((LM_ERROR,
75 "The test_raise call didn't raise\n"));
77 catch (Simple_Server::Failure &fail)
79 ACE_UNUSED_ARG (fail);
80 // Do nothing, this is the normal behavior...
84 server->shutdown ();
86 catch (const CORBA::SystemException &ex)
88 ex._tao_print_exception ("Caught exception:");
89 return 1;
92 return 0;