1 #include "Collocation_Tester.h"
2 #include "ace/OS_NS_string.h"
4 const char *Quote::top
= "Ciao";
5 const char *Quote::left
= "Hola";
6 const char *Quote::right
= "Hello";
7 const char *Quote::bottom
= "Previet";
9 Collocation_Tester::Collocation_Tester (CORBA::Object_ptr object
)
11 this->object_
= CORBA::Object::_duplicate (object
);
14 Collocation_Tester::~Collocation_Tester ()
20 Collocation_Tester::match_answer (const char *actual_answer
,
21 const char *right_answer
,
22 const char *method_name
)
24 if (ACE_OS::strcmp (actual_answer
, right_answer
))
27 ACE_TEXT ("Call to <%C> returned the wrong value!\n"), method_name
));
33 ACE_TEXT ("Call to <%C> returned with success: %C\n"), method_name
, actual_answer
));
39 Collocation_Tester::test_top ()
42 ACE_TEXT("\n------------------------<TOP>-------------------------------\n")));
45 Multiple::Top_var top
=
46 Multiple::Top::_narrow (this->object_
.in ());
48 if (CORBA::is_nil (top
.in ()))
51 ACE_TEXT ("Unable to Narrow to Multiple::Top\n")));
56 ACE_TEXT ("\n\nCalling all method supported by the Interface Top\n\n")));
58 CORBA::String_var msg
= top
->top_quote ();
60 failure
+= this->match_answer (Quote::top
, msg
.in (), "top_quote");
64 ACE_TEXT ("The test had %d/%d Failure\n"), failure
, call_num
));
67 ACE_TEXT("\n------------------------<TOP>-------------------------------\n")));
73 Collocation_Tester::test_right ()
76 ACE_TEXT("\n------------------------<RIGHT>-------------------------------\n")));
79 Multiple::Right_var right
=
80 Multiple::Right::_narrow (this->object_
.in ());
82 if (CORBA::is_nil (right
.in ()))
85 ACE_TEXT ("Unable to Narrow to Multiple::Right\n")));
90 ACE_TEXT ("\n\nCalling all method supported by the Interface Right\n\n")));
92 CORBA::String_var msg
= right
->top_quote ();
94 failure
+= this->match_answer (Quote::top
, msg
.in (), "top_quote");
96 msg
= right
->right_quote ();
98 failure
+= this->match_answer (Quote::right
, msg
.in (), "right_quote");
101 ACE_ERROR ((LM_DEBUG
,
102 ACE_TEXT ("The test had %d/%d Failure"), failure
, call_num
));
104 ACE_DEBUG ((LM_DEBUG
,
105 ACE_TEXT("\n------------------------<RIGHT>-------------------------------\n")));
112 Collocation_Tester::test_left ()
114 ACE_DEBUG ((LM_DEBUG
,
115 ACE_TEXT("\n------------------------<LEFT>-------------------------------\n")));
119 Multiple::Left_var left
=
120 Multiple::Left::_narrow (this->object_
.in ());
122 if (CORBA::is_nil (left
.in ()))
124 ACE_ERROR ((LM_DEBUG
,
125 ACE_TEXT ("Unable to Narrow to Multiple::Right\n")));
129 ACE_DEBUG ((LM_DEBUG
,
130 ACE_TEXT ("\n\nCalling all method supported by the Interface Left\n\n")));
132 CORBA::String_var msg
= left
->top_quote ();
134 failure
+= this->match_answer (Quote::top
, msg
.in (), "top_quote");
136 msg
= left
->left_quote ();
138 failure
+= this->match_answer (Quote::left
, msg
.in (), "left_quote");
141 ACE_ERROR ((LM_DEBUG
,
142 ACE_TEXT ("The test had %d/%d Failure"), failure
, call_num
));
144 ACE_DEBUG ((LM_DEBUG
,
145 ACE_TEXT("\n------------------------<LEFT>-------------------------------\n")));
152 Collocation_Tester::test_bottom ()
154 ACE_DEBUG ((LM_DEBUG
,
155 ACE_TEXT("\n-----------------------<BOTTOM>-------------------------------\n")));
159 Multiple::Bottom_var bottom
=
160 Multiple::Bottom::_narrow (this->object_
.in ());
162 if (CORBA::is_nil (bottom
.in ()))
164 ACE_ERROR ((LM_DEBUG
,
165 ACE_TEXT ("Unable to Narrow to Multiple::Right\n")));
169 ACE_DEBUG ((LM_DEBUG
,
170 ACE_TEXT ("\n\nCalling all method supported by the Interface Bottom\n\n")));
172 CORBA::String_var msg
= bottom
->top_quote ();
174 failure
+= this->match_answer (Quote::top
, msg
.in (), "top_quote");
176 msg
= bottom
->left_quote ();
178 failure
+= this->match_answer (Quote::left
, msg
.in (), "left_quote");
180 msg
= bottom
->right_quote ();
182 failure
+= this->match_answer (Quote::right
, msg
.in (), "right_quote");
184 msg
= bottom
->bottom_quote ();
186 failure
+= this->match_answer (Quote::bottom
, msg
.in (), "bottom_quote");
189 ACE_ERROR ((LM_DEBUG
,
190 ACE_TEXT ("The test had %d/%d Failure"), failure
, call_num
));
192 ACE_DEBUG ((LM_DEBUG
,
193 ACE_TEXT("\n-----------------------<BOTTOM>-------------------------------\n")));
199 Collocation_Tester::shutdown ()
201 Multiple::Top_var top
=
202 Multiple::Top::_narrow (this->object_
.in ());
204 if (CORBA::is_nil (top
.in ()))
206 ACE_ERROR ((LM_DEBUG
,
207 ACE_TEXT ("Unable to Narrow to Multiple::Top\n")));
211 ACE_DEBUG ((LM_DEBUG
,
212 ACE_TEXT ("\n\nCalling ShutDown on Top.\n\n")));
218 Collocation_Tester::run ()
220 int failure_num
= this->test_top ();
222 failure_num
+= this->test_left ();
224 failure_num
+= this->test_right ();
226 failure_num
+= this->test_bottom ();
229 ACE_ERROR ((LM_DEBUG
,
230 ACE_TEXT ("\n\nThe Test failed in %d cases."), failure_num
));
232 ACE_DEBUG ((LM_DEBUG
,
233 ACE_TEXT ("\n\nThe Test Completed Successfully. Congratulations! ")));