Merge remote-tracking branch 'upstream/master'
[ACE_TAO.git] / TAO / tests / Collocation / Collocation_Tester.cpp
blob9aaf7b5050725dabf4330fc8454967afc0246e95
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 // Activate the diamond servant and its base classes under RootPOA.
50 PortableServer::ObjectId_var id =
51 this->root_poa_->activate_object (&this->top_servant_);
53 // // We only care about the most derived class here.
54 // this->diamond_obj_ = this->diamond_servant_._this ();
56 id =
57 this->root_poa_->activate_object (&this->diamond_servant_);
59 // We only care about the most derived class here.
60 this->diamond_obj_ = this->root_poa_->id_to_reference (id.in ());
62 id =
63 this->root_poa_->activate_object (&this->left_servant_);
65 id =
66 this->root_poa_->activate_object (&this->right_servant_);
68 CORBA::String_var str =
69 this->orb_->object_to_string (this->diamond_obj_.in ());
71 ACE_DEBUG ((LM_DEBUG, "Diamond Servant activated:\n %C\n",
72 str.in()));
74 return 0;
79 int
80 Collocation_Test::parse_args (int /*argc*/,
81 ACE_TCHAR *[] /*argv*/)
83 return 0;
86 int
87 Collocation_Test::test_narrow (void)
89 Diamond::Top_var top =
90 Diamond::Top::_narrow (this->diamond_obj_.in ());
92 Diamond::Left_var left =
93 Diamond::Left::_narrow (this->diamond_obj_.in ());
95 Diamond::Right_var right =
96 Diamond::Right::_narrow (this->diamond_obj_.in ());
98 Diamond::Buttom_var buttom =
99 Diamond::Buttom::_narrow (this->diamond_obj_.in ());
101 CORBA::String_var str = top->shape ();
102 ACE_DEBUG ((LM_DEBUG, "Calling top->shape: %C\n", str.in ()));
104 str = left->shape ();
105 ACE_DEBUG ((LM_DEBUG, "Calling left->shape: %C\n", str.in ()));
107 str = right->shape ();
108 ACE_DEBUG ((LM_DEBUG, "Calling right->shape: %C\n", str.in ()));
110 str = buttom->shape ();
111 ACE_DEBUG ((LM_DEBUG, "Calling buttom->shape: %C\n", str.in ()));
113 return 0;
117 Collocation_Test::run (void)
119 this->poa_manager_->activate ();
121 this->test_narrow ();
123 return 0;