Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / FT_Naming / Federation / client.cpp
blob883cd040bfa3b0a0f43c4275f930c3b2621e61c9
1 #include "TestC.h"
2 #include "orbsvcs/CosNamingC.h"
3 #include "ace/Get_Opt.h"
6 int
7 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
9 try
11 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
13 CORBA::Object_var tmp =
14 orb->string_to_object ("corbaloc:iiop:1.2@localhost:9931/NameService");
16 CosNaming::NamingContext_var root =
17 CosNaming::NamingContext::_narrow (tmp.in ());
19 if (CORBA::is_nil (root.in ()))
21 ACE_ERROR_RETURN ((LM_DEBUG,
22 ACE_TEXT ("Nil NamingService reference\n")),
23 1);
26 ACE_DEBUG ((LM_INFO,
27 ACE_TEXT ("**** Narrowed root NamingContext\n")));
29 CosNaming::Name name;
30 name.length(3);
31 name[0].id = CORBA::string_dup ("nsB");
32 name[1].id = CORBA::string_dup ("example");
33 name[2].id = CORBA::string_dup ("Hello");
35 try
37 tmp = root->resolve (name);
38 ACE_DEBUG ((LM_INFO,
39 ACE_TEXT ("**** Resolved #nsB/example/Hello\n")));
41 Test::Hello_var hello =
42 Test::Hello::_narrow (tmp.in ());
44 if (CORBA::is_nil (hello.in ()))
46 ACE_ERROR_RETURN ((LM_DEBUG,
47 ACE_TEXT ("Nil Test::Hello reference\n")),
48 1);
51 CORBA::String_var the_string = hello->get_string ();
53 ACE_DEBUG ((LM_DEBUG,
54 ACE_TEXT ("(%P|%t) - string returned <%C>\n"),
55 the_string.in ()));
57 hello->shutdown ();
59 catch (const CosNaming::NamingContext::CannotProceed&)
61 ACE_DEBUG ((LM_DEBUG,
62 ACE_TEXT ("Caught correct exception\n")));
65 orb->shutdown ();
66 orb->destroy ();
68 catch (const CORBA::Exception& ex)
70 ex._tao_print_exception (ACE_TEXT ("Exception caught:"));
71 return 1;
74 return 0;