Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / IPV6 / client.cpp
blob6d39358d5aa0e31da008bba779fd4ec417d47a7b
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/SString.h"
5 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 bool expect_error = false;
9 int
10 parse_args (int argc, ACE_TCHAR *argv[])
12 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'k':
19 ior = get_opts.opt_arg ();
20 break;
22 case 'x':
23 expect_error = true;
24 break;
26 case '?':
27 default:
28 ACE_ERROR_RETURN ((LM_ERROR,
29 "usage: %s "
30 "-k <ior> "
31 "\n",
32 argv [0]),
33 -1);
35 // Indicates successful parsing of the command line
36 return 0;
39 int
40 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
42 try
44 CORBA::ORB_var orb =
45 CORBA::ORB_init (argc, argv);
47 if (parse_args (argc, argv) != 0)
48 return 1;
50 CORBA::Object_var tmp =
51 orb->string_to_object(ior);
53 Test::Hello_var hello =
54 Test::Hello::_narrow(tmp.in ());
56 if (CORBA::is_nil (hello.in ()))
58 ACE_ERROR_RETURN ((LM_DEBUG,
59 "Nil Test::Hello reference <%s>\n",
60 ior),
61 1);
64 CORBA::String_var the_string =
65 hello->get_string ();
67 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
68 the_string.in ()));
70 hello->shutdown ();
72 orb->destroy ();
74 catch (const CORBA::Exception& ex)
76 if (expect_error)
78 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - expected exception occurred!\n%s\n",
79 ex._info().c_str()));
81 return 0;
83 else
85 ex._tao_print_exception ("Exception caught:");
86 return 1;
90 if (expect_error)
92 ACE_DEBUG ((LM_ERROR, "(%P|%t) client - expected error did not occur!\n"));
94 return 1;
97 return 0;