Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / CSD_Collocation / Collocation_Tester.cpp
blob76f15b8057cc5be8a054440af6d6692d1a31f598
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 (void)
20 void
21 Collocation_Test::shutdown (void)
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;
98 int
99 Collocation_Test::parse_args (int /*argc*/,
100 ACE_TCHAR *[] /*argv*/)
102 return 0;
106 Collocation_Test::test_narrow (void)
108 Diamond::Top_var top =
109 Diamond::Top::_narrow (this->diamond_obj_.in ());
111 Diamond::Left_var left =
112 Diamond::Left::_narrow (this->diamond_obj_.in ());
114 Diamond::Right_var right =
115 Diamond::Right::_narrow (this->diamond_obj_.in ());
117 Diamond::Buttom_var buttom =
118 Diamond::Buttom::_narrow (this->diamond_obj_.in ());
120 CORBA::String_var str = top->shape ();
121 ACE_DEBUG ((LM_DEBUG, "Calling top->shape: %C\n", str.in ()));
123 str = left->shape ();
124 ACE_DEBUG ((LM_DEBUG, "Calling left->shape: %C\n", str.in ()));
126 str = right->shape ();
127 ACE_DEBUG ((LM_DEBUG, "Calling right->shape: %C\n", str.in ()));
129 str = buttom->shape ();
130 ACE_DEBUG ((LM_DEBUG, "Calling buttom->shape: %C\n", str.in ()));
132 return 0;
136 Collocation_Test::run (void)
138 this->poa_manager_->activate ();
140 this->test_narrow ();
142 return 0;