Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_3299_Regression / client.cpp
blob0f6d624f9817d1b4f7c29ffc5b2619257251a687
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
32 int
33 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
35 try
37 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
39 if (parse_args (argc, argv) != 0)
40 return 1;
42 CORBA::Object_var tmp = orb->string_to_object(ior);
44 Test::Hello_var hello = Test::Hello::_narrow(tmp.in ());
46 if (CORBA::is_nil (hello.in ()))
48 ACE_ERROR_RETURN ((LM_DEBUG,
49 "Nil Test::Hello reference <%s>\n",
50 ior),
51 1);
54 try
56 CORBA::String_var the_string = hello->get_string ();
58 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
59 the_string.in ()));
61 // The *first* invocation of the get_string server always throws a COMPLETED_MAYBE exception. For the call to
62 // succeed we must have reinvoked breaking 'at most once' rules. The job is, therefore, a bogey.
63 ACE_ERROR ((LM_ERROR, "Error - Regression - Test has failed. ORB has retried a COMPLETED_MAYBE\n"));
65 catch (const CORBA::TRANSIENT& trans)
67 // We are expecting a TRANSIENT COMPLETED_MAYBE.
68 if (trans.completed () == CORBA::COMPLETED_MAYBE)
70 // Everything is Peachy
71 hello->shutdown ();
73 orb->destroy ();
75 return 0;
79 catch (const CORBA::Exception& ex)
81 ex._tao_print_exception ("Unexpected exception caught:");
84 return 1;