Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / BiDirectional_MultipleORB / destroy.cpp
blob0491f77ede52df4fd375654a1d83f164505a4c10
2 //=============================================================================
3 /**
4 * @file destroy.cpp
6 * Modified ORB destruction test.
8 * @author Andrew Schnable <Andrew.Schnable@veritas.com> Iliyan Jeliazkov <jeliazkov_i@ociweb.com>
9 */
10 //=============================================================================
13 #include "tao/corba.h"
14 #include "tao/PortableServer/PortableServer.h"
15 #include "tao/AnyTypeCode/Any.h"
16 #include "tao/BiDir_GIOP/BiDirGIOP.h"
20 int
21 test_with_bidir_poa (int argc,
22 ACE_TCHAR **argv,
23 const char *orb_name,
24 int destroy_orb)
27 try
29 CORBA::ORB_var orb =
30 CORBA::ORB_init (argc, argv, orb_name);
32 CORBA::Object_var obj =
33 orb->resolve_initial_references ("RootPOA");
35 PortableServer::POA_var root_poa =
36 PortableServer::POA::_narrow (obj.in ());
38 PortableServer::POAManager_var poa_manager =
39 root_poa->the_POAManager ();
42 CORBA::PolicyList policies (1);
43 policies.length (1);
45 CORBA::Any pol;
46 pol <<= BiDirPolicy::BOTH;
47 policies[0] =
48 orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
49 pol);
51 // Create POA as child of RootPOA with the above policies. This POA
52 // will receive request in the same connection in which it sent
53 // the request
54 PortableServer::POA_var child_poa =
55 root_poa->create_POA ("childPOA",
56 poa_manager.in (),
57 policies);
59 // Creation of childPOA is over. Destroy the Policy objects.
60 for (CORBA::ULong i = 0;
61 i < policies.length ();
62 ++i)
64 policies[i]->destroy ();
67 poa_manager->activate ();
70 root_poa->destroy (1, 1);
72 if (destroy_orb)
74 orb->destroy ();
77 catch (const CORBA::Exception& ex)
79 ex._tao_print_exception ("Exception raised");
82 return 0;
85 int
86 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
88 int result = 0;
90 for (int i=0; i<10; i++)
92 result = test_with_bidir_poa (argc, argv, "poa_1", 1);
93 ACE_ASSERT (result == 0);
95 result = test_with_bidir_poa (argc, argv, "poa_2", 1);
96 ACE_ASSERT (result == 0);
98 ACE_DEBUG ((LM_DEBUG, "Completed OK\n"));
99 return result;