1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
//
// $Id$
//
#include "Service.h"
ACE_RCSID(Callback, Service, "$Id$")
Service::Service (CORBA::ORB_ptr orb)
: test_count_ (0),
orb_ (CORBA::ORB::_duplicate (orb))
{
}
void
Service::dump_results (void)
{
if (this->test_count_ == 0)
{
ACE_DEBUG ((LM_DEBUG,
"ERROR: no tests were completed!\n"));
}
}
void
Service::run_test (Test::Callback_ptr callback
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
int exceptions =
this->call_are_you_there (callback ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
exceptions +=
this->call_test_oneway (callback ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
if (exceptions != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: There were %d exceptions\n"));
}
/// Increment the number of tests completed
this->test_count_++;
ACE_TRY
{
callback->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
ACE_DEBUG ((LM_ERROR, "(%P|%t) - Service, client shutdown FAILED\n"));
}
ACE_ENDTRY;
// shutdown ourselves
this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER);
}
int
Service::call_are_you_there (Test::Callback_ptr callback
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC (())
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, calling are_you_there\n"));
const int iterations = 10;
int exception_count = 0;
for (int i = 0; i != iterations; ++i)
{
char* outstr;
CORBA::String_out out_str (outstr);
ACE_TRY
{
(void) callback->are_you_there (out_str ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
exception_count++;
}
ACE_ENDTRY;
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, answer = %s\n", outstr));
}
return exception_count;
}
int
Service::call_test_oneway (Test::Callback_ptr callback
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC (())
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, calling test_oneway\n"));
const int iterations = 10;
int exception_count = 0;
for (int i = 0; i != iterations; ++i)
{
ACE_TRY
{
(void) callback->test_oneway (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
exception_count++;
}
ACE_ENDTRY;
}
return exception_count;
}
|