Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Alt_Mapping / client.cpp
blob681c105de4f9788a29ff4d21327fc9a287c10adb
2 //=============================================================================
3 /**
4 * @file client.cpp
6 * This file contains the implementation of the client-side of the
7 * Alt_Mapping application.
9 * @author Jeff Parsons
11 //=============================================================================
14 #ifndef CLIENT_CPP
15 #define CLIENT_CPP
17 #include "options.h"
18 #include "results.h"
19 #include "client.h"
21 // Constructor.p
22 template <class T>
23 Alt_Mapping_Client<T>::Alt_Mapping_Client (CORBA::ORB_ptr orb,
24 Alt_Mapping_ptr objref,
25 T *t)
26 : orb_ (orb),
27 alt_mapping_test_ (objref),
28 test_object_ (t)
32 // destructor
33 template <class T>
34 Alt_Mapping_Client<T>::~Alt_Mapping_Client (void)
36 delete this->test_object_;
39 // All the individual tests.
40 template <class T> int
41 Alt_Mapping_Client<T>::run_sii_test (void)
43 CORBA::ULong i = 0; // loop index
44 Options *opt = OPTIONS::instance (); // get the options
45 const char *opname = this->test_object_->opname (); // operation
47 if (opt->debug ())
48 ACE_DEBUG ((LM_DEBUG,
49 "********** %s SII *********\n",
50 opname));
52 // Initialize call count and error count.
53 this->results_.call_count (0);
54 this->results_.error_count (0);
55 this->results_.iterations (opt->loop_count ());
57 // Declare the Env
58 // Initialize parameters for the test.
59 int check = this->test_object_->init_parameters (this->alt_mapping_test_);
61 if (check == -1)
63 ACE_ERROR_RETURN ((LM_ERROR,
64 "(%N:%l) client.cpp - run_sii_test:"
65 "init_parameters failed for opname - %s",
66 opname),
67 -1);
71 // Make the calls in a loop.
72 for (i = 0; i < opt->loop_count (); i++)
74 try
76 this->results_.call_count (this->results_.call_count () + 1);
77 if (opt->debug ())
79 ACE_DEBUG ((LM_DEBUG, "\n****** Before call values *****\n"));
80 this->test_object_->print_values ();
83 // start the timing
84 this->results_.start_timer ();
86 // make the call
87 this->test_object_->run_sii_test (this->alt_mapping_test_);
89 // stop the timer.
90 this->results_.stop_timer ();
92 // now check if the values returned are as expected
93 if (opt->debug ())
95 ACE_DEBUG ((LM_DEBUG, "\n****** After call values *****\n"));
96 this->test_object_->print_values ();
99 catch (const CORBA::Exception& ex)
102 this->results_.error_count (this->results_.error_count () + 1);
103 ex._tao_print_exception (opname);
104 ACE_ERROR ((LM_ERROR,
105 "(%N:%l) client.cpp - run_sii_test:"
106 "run_sii_test exception in iteration %d",
107 i));
108 goto loop_around;
112 if (!this->test_object_->check_validity ())
114 this->results_.error_count (this->results_.error_count () + 1);
115 ACE_ERROR ((LM_ERROR,
116 "(%N:%l) client.cpp - run_sii_test: "
117 "Invalid results in iteration %d\n",
118 i));
119 continue;
121 // reset parameters for the test.
122 if (this->test_object_->reset_parameters () == -1)
123 ACE_ERROR_RETURN ((LM_ERROR,
124 "(%N:%l) client.cpp - run_sii_test:"
125 "init_parameters failed for opname - %s",
126 opname), -1);
127 loop_around: continue;
130 // print statistics
131 this->results_.print_stats ();
133 if (this->results_.error_count () != 0)
135 ACE_DEBUG ((LM_DEBUG,
136 "********** Error running %s SII *********\n",
137 opname));
139 else if (opt->debug ())
141 ACE_DEBUG ((LM_DEBUG,
142 "********** Finished running %s SII *********\n",
143 opname));
146 return this->results_.error_count ()? -1 : 0;
149 #endif /* CLIENT_CPP */