Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / ORB_Local_Config / Bug_3049 / Test.cpp
blobd33a9071f03529662dd5fc74291789ba9dfed466
1 // @author Phil Mesnier <mesnier_p@ociweb.com>
3 // This test scenario is documented in bugzilla bug 3049. This test
4 // creates 3 ORBs. ORB-A becomes the default ORB, which shares the
5 // global config context, ORB-B initializes a local configuration
6 // context which loads a service. ORB-C finally shares the configuration
7 // from ORB-B. The demonstration is to show that a service is avialable
8 // to ORB-C from the configuration initalized by ORB-B.
10 #include "tao/corba.h"
11 #include "tao/ORB_Core.h"
12 #include "ace/ARGV.h"
13 #include "ace/Dynamic_Service.h"
14 #include "Service_Configuration_Per_ORB.h"
16 const ACE_TCHAR argA[] = ACE_TEXT ("AAA -ORBGestalt LOCAL -ORBId ORB-A");
17 const ACE_TCHAR argB[] = ACE_TEXT ("BBB -ORBGestalt LOCAL -ORBId ORB-B -ORBSvcConf a.conf");
18 const ACE_TCHAR argC[] = ACE_TEXT ("BBB -ORBGestalt ORB:ORB-B -ORBId ORB-C");
20 int
21 testBug3049 (int , ACE_TCHAR *[])
23 ACE_TRACE ("testBug3049");
25 try
27 ACE_ARGV arg0(argA);
28 int n = arg0.argc();
29 CORBA::ORB_var ORBA = CORBA::ORB_init(n,arg0.argv());
31 ACE_ARGV arg1(argB);
32 n = arg1.argc();
33 CORBA::ORB_var ORBB = CORBA::ORB_init(n,arg1.argv());
35 ACE_ARGV arg2(argC);
36 n = arg2.argc();
37 CORBA::ORB_var ORBC = CORBA::ORB_init(n,arg2.argv());
39 // Confirm that ORBC has SHMIOP, which it inherits from ORBB, and
40 // that SHMIOP is not available in the global context
42 ACE_Service_Object *so = 0;
43 int error = 0;
44 so = ACE_Dynamic_Service<ACE_Service_Object>::instance ("SHMIOP_Factory");
45 if (so != 0)
47 error++;
48 ACE_ERROR ((LM_DEBUG,
49 ACE_TEXT("Unexpected to find SHMIOP_Factory globally\n")));
52 so = ACE_Dynamic_Service<ACE_Service_Object>::instance
53 (ORBC->orb_core()->configuration(), "SHMIOP_Factory");
54 if (so == 0)
56 error++;
57 ACE_ERROR ((LM_DEBUG,
58 ACE_TEXT("Failed to find ")
59 ACE_TEXT("SHMIOP_Factory in ORBC\n")));
62 ORBA->destroy();
64 ORBB->destroy();
66 ORBC->destroy();
68 if (error > 0)
69 return -1;
71 catch(const CORBA::Exception& ex)
73 ex._tao_print_exception ("Unhandled exception caught");
74 return -1;
76 catch(...)
78 ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Unexpected exception\n")), -1);
81 return 0;
84 // @brief the main driver
86 int
87 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
89 return testBug3049(argc, argv);