More tests update
[ACE_TAO.git] / TAO / tests / ORB_destroy / ORB_destroy.cpp
blobf000ecf4bd77228b4f8739dbd8e12db95dd88d21
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)
26 try
28 CORBA::ORB_var orb =
29 CORBA::ORB_init (argc, argv, orb_name);
31 CORBA::Object_var obj =
32 orb->resolve_initial_references ("RootPOA");
34 PortableServer::POA_var root_poa =
35 PortableServer::POA::_narrow (obj.in ());
37 PortableServer::POAManager_var poa_manager =
38 root_poa->the_POAManager ();
40 poa_manager->activate ();
42 if (destroy_poa)
44 root_poa->destroy (1, 1);
47 if (destroy_orb)
49 orb->destroy ();
52 catch (const CORBA::Exception& ex)
54 ex._tao_print_exception ("Exception raised");
57 return 0;
60 int
61 test_with_funky_poa_manager (int argc,
62 ACE_TCHAR **argv,
63 const char *orb_name,
64 int destroy_orb,
65 int destroy_poa,
66 int funky_poa_manager)
69 try
71 CORBA::ORB_var orb =
72 CORBA::ORB_init (argc, argv, orb_name);
74 CORBA::Object_var obj =
75 orb->resolve_initial_references ("RootPOA");
77 PortableServer::POA_var root_poa =
78 PortableServer::POA::_narrow (obj.in ());
80 if (funky_poa_manager)
82 PortableServer::POAManager_var poa_manager =
83 root_poa->the_POAManager ();
85 poa_manager->activate ();
88 if (destroy_poa)
90 root_poa->destroy (1, 1);
93 if (destroy_orb)
95 orb->destroy ();
98 catch (const CORBA::Exception& ex)
100 ex._tao_print_exception ("Exception raised");
103 return 0;
107 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
109 int result = 0;
111 result = test_with_regular_poa_manager (argc, argv,
112 "destroy_nothing_with_poa_manager",
113 0, 0);
114 ACE_ASSERT (result == 0);
116 result = test_with_regular_poa_manager (argc, argv,
117 "destroy_poa_with_poa_manager",
118 0, 1);
119 ACE_ASSERT (result == 0);
121 result = test_with_regular_poa_manager (argc, argv,
122 "destroy_orb_with_poa_manager",
123 1, 0);
124 ACE_ASSERT (result == 0);
126 result = test_with_regular_poa_manager (argc, argv,
127 "destroy_poa_and_orb_with_poa_manager",
128 1, 1);
129 ACE_ASSERT (result == 0);
131 result = test_with_funky_poa_manager (argc, argv,
132 "destroy_nothing_without_poa_manager",
133 0, 0, 0);
134 ACE_ASSERT (result == 0);
136 result = test_with_funky_poa_manager (argc, argv,
137 "destroy_poa_without_poa_manager",
138 0, 1, 0);
139 ACE_ASSERT (result == 0);
141 result = test_with_funky_poa_manager (argc, argv,
142 "destroy_orb_without_poa_manager",
143 1, 0, 0);
144 ACE_ASSERT (result == 0);
146 result = test_with_funky_poa_manager (argc, argv,
147 "destroy_poa_and_orb_without_poa_manager",
148 1, 1, 0);
149 ACE_ASSERT (result == 0);
151 result = test_with_funky_poa_manager (argc, argv,
152 "destroy_nothing_with_funky_poa_manager",
153 0, 0, 1);
154 ACE_ASSERT (result == 0);
156 result = test_with_funky_poa_manager (argc, argv,
157 "destroy_poa_with_funky_poa_manager",
158 0, 1, 1);
159 ACE_ASSERT (result == 0);
161 result = test_with_funky_poa_manager (argc, argv,
162 "destroy_orb_with_funky_poa_manager",
163 1, 0, 1);
164 ACE_ASSERT (result == 0);
166 result = test_with_funky_poa_manager (argc, argv,
167 "destroy_poa_and_orb_with_funky_poa_manager",
168 1, 1, 1);
169 ACE_ASSERT (result == 0);
171 return result;