Use nullptr
[ACE_TAO.git] / TAO / tests / Bug_2174_Regression / client.cpp
blob7503bf4a7190555bf21c0e3e9ae12f7bca26e827
1 #include "testC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
5 int min_timeout = 0;
6 int max_timeout = 20;
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:l:h:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'k':
18 ior = get_opts.opt_arg ();
19 break;
21 case '?':
22 default:
23 ACE_ERROR_RETURN ((LM_ERROR,
24 "usage: %s "
25 "-k <ior> "
26 "\n",
27 argv [0]),
28 -1);
30 // Indicates successful parsing of the command line
31 return 0;
34 int result = 1;
35 // 1 : fault in test
36 // 2 : _non_existent() returned false
37 // 3 : _non_existent() returned true
38 // 4 : CORBA::OBJECT_NOT_EXIST exception
39 // 5 : CORBA::TRANSIENT exception
41 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
43 try
45 CORBA::ORB_var orb =
46 CORBA::ORB_init (argc, argv);
48 if (parse_args (argc, argv) != 0)
49 return 1;
51 CORBA::Object_var object =
52 orb->string_to_object (ior);
54 Simple_Server_var server =
55 Simple_Server::_narrow (object.in ());
57 if (CORBA::is_nil (server.in ()))
59 ACE_ERROR_RETURN ((LM_ERROR,
60 "Object reference <%s> is nil.\n",
61 ior),
62 1);
65 CORBA::Boolean non_existent = server->_non_existent ();
67 if (non_existent)
68 result = 3;
69 else
70 result = 2;
72 ACE_DEBUG ((LM_DEBUG,
73 "client (%P) _non_existent() returned %d\n",
74 static_cast<int>(non_existent) ));
76 orb->destroy ();
78 catch (const CORBA::OBJECT_NOT_EXIST& ex)
80 ex._tao_print_exception ("ERROR: Exception caught:");
81 result = 4;
83 catch (const CORBA::TRANSIENT&)
85 result = 5;
87 catch (const CORBA::Exception& ex)
89 ex._tao_print_exception ("ERROR: Exception caught:");
90 result = 6;
92 return result;