Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / CSD_Collocation / Collocation_Tester.cpp
blob4eb32c3e5a6dba5e5856391a8cd7fdc339f50304
1 //============================================================================
2 //
3 // =FILENAME
4 // Collocation_Test.h
5 //
6 // =DESCRIPTION
7 // Server class to perform testing of TAO's collocation mechanism.
8 //
9 // =AUTHOR
10 // Nanbor Wang
12 //=============================================================================
14 #include "Collocation_Tester.h"
16 Collocation_Test::Collocation_Test ()
20 void
21 Collocation_Test::shutdown ()
23 this->root_poa_->destroy (1, 1);
24 this->orb_->destroy ();
27 int
28 Collocation_Test::init (int argc, ACE_TCHAR *argv[])
30 // Initialize the ORB.
31 this->orb_ = CORBA::ORB_init (argc, argv);
33 int result = this->parse_args (argc, argv);
34 if (result != 0)
35 return result;
37 // Get an Object reference to RootPOA.
38 CORBA::Object_var obj =
39 this->orb_->resolve_initial_references ("RootPOA");
41 // Narrow the Object reference to a POA reference
42 this->root_poa_ =
43 PortableServer::POA::_narrow (obj.in ());
45 // Get the POAManager of RootPOA
46 this->poa_manager_ =
47 this->root_poa_->the_POAManager ();
49 // Create our own child POA
50 // Empty sequence means all default policies
51 int nPolicies = 0;
52 CORBA::PolicyList policies;
54 policies.length(1);
55 policies[nPolicies++] =
56 this->root_poa_->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION);
58 obj = this->root_poa_->create_POA("child", this->poa_manager_.in(), policies);
59 PortableServer::POA_var childPOA = PortableServer::POA::_narrow (obj.in ());
61 // Destroy the Policy objects (before we may exit as a result of failures)
62 for (CORBA::ULong i = 0; i < policies.length(); ++i)
64 policies[i]->destroy();
67 // Activate the diamond servant and its base classes under childPOA.
68 PortableServer::ObjectId_var id =
69 childPOA->activate_object (&this->top_servant_);
71 // // We only care about the most derived class here.
72 // this->diamond_obj_ = this->diamond_servant_._this ();
74 id =
75 childPOA->activate_object (&this->diamond_servant_);
77 // We only care about the most derived class here.
78 this->diamond_obj_ = childPOA->id_to_reference (id.in ());
80 id =
81 childPOA->activate_object (&this->left_servant_);
83 id =
84 childPOA->activate_object (&this->right_servant_);
87 CORBA::String_var str =
88 this->orb_->object_to_string (this->diamond_obj_.in ());
90 ACE_DEBUG ((LM_DEBUG, "Diamond Servant activated:\n %C\n",
91 str.in()));
93 return 0;
97 int
98 Collocation_Test::parse_args (int /*argc*/,
99 ACE_TCHAR *[] /*argv*/)
101 return 0;
105 Collocation_Test::test_narrow ()
107 Diamond::Top_var top =
108 Diamond::Top::_narrow (this->diamond_obj_.in ());
110 Diamond::Left_var left =
111 Diamond::Left::_narrow (this->diamond_obj_.in ());
113 Diamond::Right_var right =
114 Diamond::Right::_narrow (this->diamond_obj_.in ());
116 Diamond::Buttom_var buttom =
117 Diamond::Buttom::_narrow (this->diamond_obj_.in ());
119 CORBA::String_var str = top->shape ();
120 ACE_DEBUG ((LM_DEBUG, "Calling top->shape: %C\n", str.in ()));
122 str = left->shape ();
123 ACE_DEBUG ((LM_DEBUG, "Calling left->shape: %C\n", str.in ()));
125 str = right->shape ();
126 ACE_DEBUG ((LM_DEBUG, "Calling right->shape: %C\n", str.in ()));
128 str = buttom->shape ();
129 ACE_DEBUG ((LM_DEBUG, "Calling buttom->shape: %C\n", str.in ()));
131 return 0;
135 Collocation_Test::run ()
137 this->poa_manager_->activate ();
139 this->test_narrow ();
141 return 0;