summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp')
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp b/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp
new file mode 100644
index 00000000000..0fa3468806d
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp
@@ -0,0 +1,78 @@
+// $Id$
+
+#include "TestC.h"
+#include "orbsvcs/CosNamingC.h"
+#include "ace/Get_Opt.h"
+
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var tmp =
+ orb->string_to_object (
+ ACE_TEXT_ALWAYS_CHAR ("corbaloc:iiop:1.2@localhost:9931/NameService"));
+
+ CosNaming::NamingContext_var root =
+ CosNaming::NamingContext::_narrow (tmp.in ());
+
+ if (CORBA::is_nil (root.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("Nil NamingService reference\n")),
+ 1);
+ }
+
+ ACE_DEBUG ((LM_INFO,
+ ACE_TEXT ("**** Narrowed root NamingContext\n")));
+
+ CosNaming::Name name;
+ name.length(3);
+ name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("nsB"));
+ name[1].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("example"));
+ name[2].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("Hello"));
+
+ try
+ {
+ tmp = root->resolve (name);
+ ACE_DEBUG ((LM_INFO,
+ ACE_TEXT ("**** Resolved #nsB/example/Hello\n")));
+
+ Test::Hello_var hello =
+ Test::Hello::_narrow (tmp.in ());
+
+ if (CORBA::is_nil (hello.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("Nil Test::Hello reference\n")),
+ 1);
+ }
+
+ CORBA::String_var the_string = hello->get_string ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - string returned <%C>\n"),
+ the_string.in ()));
+
+ hello->shutdown ();
+ }
+ catch (const CosNaming::NamingContext::CannotProceed&)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Caught correct exception\n")));
+ }
+
+ orb->shutdown ();
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (ACE_TEXT ("Exception caught:"));
+ return 1;
+ }
+
+ return 0;
+}