Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Bug_2953_Regression / client.cpp
blobe85c91e7923564323c5b341ce3dd0da2c0a02bcb
1 // -*- C++ -*-
2 #include "tao/ORB.h"
3 #include "tao/Object.h"
4 #include "tao/SystemException.h"
5 #include "tao/RTCORBA/RTCORBA.h"
6 #include "ace/Log_Msg.h"
7 #include "ace/Thread.h"
8 #include "ace/Get_Opt.h"
10 #include "TestC.h"
12 void shutdownORB(CORBA::ORB_ptr orb, const char * orbid)
14 orb->shutdown(0);
15 ACE_DEBUG ((LM_DEBUG,
16 "ORB <%C> is shutdown\n",
17 orbid));
19 orb->destroy();
20 ACE_DEBUG ((LM_DEBUG,
21 "ORB <%C> is destroyed\n",
22 orbid));
25 static const ACE_TCHAR *orbidAfile = ACE_TEXT("file://iorA.ior");
26 static const ACE_TCHAR *orbidBfile = ACE_TEXT("file://iorB.ior");
28 int
29 parse_args (int argc, ACE_TCHAR *argv[])
31 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("a:b:"));
32 int c;
34 while ((c = get_opts ()) != -1)
35 switch (c)
37 case 'a':
38 orbidAfile = get_opts.optarg;
39 break;
40 case 'b':
41 orbidBfile = get_opts.optarg;
42 break;
43 case '?':
44 default:
45 ACE_ERROR_RETURN ((LM_ERROR,
46 "usage: %s "
47 "-a <iorA> "
48 "-a <iorB> "
49 "\n",
50 argv [0]),
51 -1);
53 // Indicates successful parsing of the command line
54 return 0;
57 int
58 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
60 try
62 if (parse_args (argc, argv) != 0)
64 return 1;
67 const char *orbidA = "orbidA";
68 CORBA::ORB_var orbA = CORBA::ORB_init(argc, argv, orbidA);
70 CORBA::Object_var objA = orbA->string_to_object(orbidAfile);
71 Test::Hello_var helloA(Test::Hello::_narrow(objA.in ()));
72 CORBA::String_var resA = helloA->get_string();
74 CORBA::Object_var objB = orbA->string_to_object(orbidBfile);
75 Test::Hello_var helloB(Test::Hello::_narrow(objB.in ()));
76 CORBA::String_var resB = helloB->get_string();
78 ACE_DEBUG ((LM_DEBUG,
79 "got resA: <%C> and resB: <%C>",
80 resA.in(), resB.in ()));
82 helloA->shutdown ();
83 helloB->shutdown ();
84 shutdownORB(orbA.in (), orbidA);
86 catch (const CORBA::Exception& ex)
88 ex._tao_print_exception ("Caught unexpected exception:");
90 ACE_ERROR ((LM_ERROR, "Bug_2953_Regression test failed.\n"));
91 return 1;
94 ACE_DEBUG ((LM_DEBUG,
95 "Client test completed successfully.\n"));
97 return 0;