Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / BiDirectional_MultipleORB / destroy.cpp
blobbdbc66000a2d886970be7b1c7929267a606112df
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"
19 int
20 test_with_bidir_poa (int argc,
21 ACE_TCHAR **argv,
22 const char *orb_name,
23 int destroy_orb)
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 ();
40 CORBA::PolicyList policies (1);
41 policies.length (1);
43 CORBA::Any pol;
44 pol <<= BiDirPolicy::BOTH;
45 policies[0] =
46 orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
47 pol);
49 // Create POA as child of RootPOA with the above policies. This POA
50 // will receive request in the same connection in which it sent
51 // the request
52 PortableServer::POA_var child_poa =
53 root_poa->create_POA ("childPOA",
54 poa_manager.in (),
55 policies);
57 // Creation of childPOA is over. Destroy the Policy objects.
58 for (CORBA::ULong i = 0;
59 i < policies.length ();
60 ++i)
62 policies[i]->destroy ();
65 poa_manager->activate ();
68 root_poa->destroy (true, true);
70 if (destroy_orb)
72 orb->destroy ();
75 catch (const CORBA::Exception& ex)
77 ex._tao_print_exception ("Exception raised");
80 return 0;
83 int
84 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
86 int result = 0;
88 for (int i=0; i<10; i++)
90 result = test_with_bidir_poa (argc, argv, "poa_1", 1);
91 ACE_ASSERT (result == 0);
93 result = test_with_bidir_poa (argc, argv, "poa_2", 1);
94 ACE_ASSERT (result == 0);
96 ACE_DEBUG ((LM_DEBUG, "Completed OK\n"));
97 return result;