summaryrefslogtreecommitdiff
path: root/trunk/TAO/tests/CSD_Strategy_Tests/TP_Foo_C/Foo_C_Custom_ClientEngine.cpp
blob: 260bf44b3e990c0f46ceb102fa41e3fb5eceb9d0 (plain)
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
115
116
117
118
119
120
121
122
123
// $Id$
#include "Foo_C_Custom_ClientEngine.h"
#include "CustomExceptionC.h"
#include "ace/Log_Msg.h"


Foo_C_Custom_ClientEngine::Foo_C_Custom_ClientEngine
                                        (Foo_C_i*               servant,
                                         Foo_C_ptr              objref,
                                         TAO::CSD::TP_Strategy* strategy,
                                         unsigned               client_id)
  : proxy_(servant,objref,strategy),
    client_id_(client_id)
{
}


Foo_C_Custom_ClientEngine::~Foo_C_Custom_ClientEngine()
{
}


bool
Foo_C_Custom_ClientEngine::execute(void)
{
  // Make sure the connection is established before making
  // remote invocations.
  if (this->proxy_.validate_connection () == false)
    {
      ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_ClientEngine::execute  " \
                          "client %d connect failed.\n", this->client_id_));
      return false;
    }

  bool check_validity = true;
  CORBA::Long i = this->client_id_;

  this->proxy_.op1();
  this->proxy_.op2(i);
  CORBA::Long value = this->proxy_.op3(i);

  if (value != i)
    {
      check_validity = false;
    }


  for (CORBA::Long j = 1; j <= 5; j++)
    {
      this->proxy_.op4(495 + (i * 5) + j);
    }

  bool caught_exception = false;
  try
    {
      this->proxy_.op5();
    }
  catch (const FooException& )
    {
      // Expected
      caught_exception = true;
    }

  if (! caught_exception)
    {
      check_validity = false;
    }

  long cust_i = this->client_id_;

  this->proxy_.cust_op1();
  this->proxy_.cust_op2(cust_i);
  long cust_value = this->proxy_.cust_op3(cust_i);

  if (cust_value != i)
    {
      check_validity = false;
    }

  for (long cust_j = 1; cust_j <= 5; cust_j++)
    {
      this->proxy_.cust_op4(495 + (cust_i * 5) + cust_j);
    }

  caught_exception = false;

  try
    {
      this->proxy_.cust_op5();
    }
  catch (const CORBA::Exception&)//(CustomException, ex)
    {
      // Expected
      caught_exception = true;
    }

  if (! caught_exception)
    {
      check_validity = false;
    }

  this->proxy_.done();

  return check_validity;
}


void
Foo_C_Custom_ClientEngine::expected_results(Foo_C_Statistics& stats)
{
  // This ClientEngine is used by collocated clients.
  stats.expected(1, 1, false);
  stats.expected(2, 1, false);
  stats.expected(3, 1, false);
  stats.expected(4, 5, false);
  stats.expected(5, 1, false);
  stats.expected(6, 1, false);
  stats.expected(7, 1, false);
  stats.expected(8, 1, false);
  stats.expected(9, 5, false);
  stats.expected(10, 1, false);
}