Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / ORB_destroy / ORB_destroy.cpp
blob66a6bc334c9632997650a85a0064b7d9800eab58
2 //=============================================================================
3 /**
4 * @file ORB_destroy.cpp
6 * Simple ORB destruction test.
8 * @author Irfan Pyarali <irfan@cs.wustl.edu>
9 */
10 //=============================================================================
13 #include "tao/ORB.h"
14 #include "tao/PortableServer/PortableServer.h"
16 #include "ace/Log_Msg.h"
18 int
19 test_with_regular_poa_manager (int argc,
20 ACE_TCHAR **argv,
21 const char *orb_name,
22 int destroy_orb,
23 int destroy_poa)
25 try
27 CORBA::ORB_var orb =
28 CORBA::ORB_init (argc, argv, orb_name);
30 CORBA::Object_var obj =
31 orb->resolve_initial_references ("RootPOA");
33 PortableServer::POA_var root_poa =
34 PortableServer::POA::_narrow (obj.in ());
36 PortableServer::POAManager_var poa_manager =
37 root_poa->the_POAManager ();
39 poa_manager->activate ();
41 if (destroy_poa)
43 root_poa->destroy (true, true);
46 if (destroy_orb)
48 orb->destroy ();
51 catch (const CORBA::Exception& ex)
53 ex._tao_print_exception ("Exception raised");
56 return 0;
59 int
60 test_with_funky_poa_manager (int argc,
61 ACE_TCHAR **argv,
62 const char *orb_name,
63 int destroy_orb,
64 int destroy_poa,
65 int funky_poa_manager)
67 try
69 CORBA::ORB_var orb =
70 CORBA::ORB_init (argc, argv, orb_name);
72 CORBA::Object_var obj =
73 orb->resolve_initial_references ("RootPOA");
75 PortableServer::POA_var root_poa =
76 PortableServer::POA::_narrow (obj.in ());
78 if (funky_poa_manager)
80 PortableServer::POAManager_var poa_manager =
81 root_poa->the_POAManager ();
83 poa_manager->activate ();
86 if (destroy_poa)
88 root_poa->destroy (true, true);
91 if (destroy_orb)
93 orb->destroy ();
96 catch (const CORBA::Exception& ex)
98 ex._tao_print_exception ("Exception raised");
101 return 0;
105 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
107 int result = 0;
109 result = test_with_regular_poa_manager (argc, argv,
110 "destroy_nothing_with_poa_manager",
111 0, 0);
112 ACE_ASSERT (result == 0);
114 result = test_with_regular_poa_manager (argc, argv,
115 "destroy_poa_with_poa_manager",
116 0, 1);
117 ACE_ASSERT (result == 0);
119 result = test_with_regular_poa_manager (argc, argv,
120 "destroy_orb_with_poa_manager",
121 1, 0);
122 ACE_ASSERT (result == 0);
124 result = test_with_regular_poa_manager (argc, argv,
125 "destroy_poa_and_orb_with_poa_manager",
126 1, 1);
127 ACE_ASSERT (result == 0);
129 result = test_with_funky_poa_manager (argc, argv,
130 "destroy_nothing_without_poa_manager",
131 0, 0, 0);
132 ACE_ASSERT (result == 0);
134 result = test_with_funky_poa_manager (argc, argv,
135 "destroy_poa_without_poa_manager",
136 0, 1, 0);
137 ACE_ASSERT (result == 0);
139 result = test_with_funky_poa_manager (argc, argv,
140 "destroy_orb_without_poa_manager",
141 1, 0, 0);
142 ACE_ASSERT (result == 0);
144 result = test_with_funky_poa_manager (argc, argv,
145 "destroy_poa_and_orb_without_poa_manager",
146 1, 1, 0);
147 ACE_ASSERT (result == 0);
149 result = test_with_funky_poa_manager (argc, argv,
150 "destroy_nothing_with_funky_poa_manager",
151 0, 0, 1);
152 ACE_ASSERT (result == 0);
154 result = test_with_funky_poa_manager (argc, argv,
155 "destroy_poa_with_funky_poa_manager",
156 0, 1, 1);
157 ACE_ASSERT (result == 0);
159 result = test_with_funky_poa_manager (argc, argv,
160 "destroy_orb_with_funky_poa_manager",
161 1, 0, 1);
162 ACE_ASSERT (result == 0);
164 result = test_with_funky_poa_manager (argc, argv,
165 "destroy_poa_and_orb_with_funky_poa_manager",
166 1, 1, 1);
167 ACE_ASSERT (result == 0);
169 return result;