summaryrefslogtreecommitdiff
path: root/TAO/tests/CSD_Strategy_Tests/TP_Foo_C/Foo_C_ClientEngine.cpp
blob: fdd8b4e26716440d198c2d700458f04b30c1fc19 (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
// $Id$
#include "Foo_C_ClientEngine.h"
#include "AppHelper.h"
#include "ace/Log_Msg.h"


Foo_C_ClientEngine::Foo_C_ClientEngine(Foo_C_ptr obj,
                                       unsigned  client_id)
  : obj_(Foo_C::_duplicate(obj)),
    client_id_ (client_id)
{
}


Foo_C_ClientEngine::~Foo_C_ClientEngine()
{
}


bool
Foo_C_ClientEngine::execute(ACE_ENV_SINGLE_ARG_DECL)
{  
  // Verify the return values and return the results.
  bool check_validity = true;

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

  CORBA::Long i = this->client_id_;

  this->obj_->op1(ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (false);

  this->obj_->op2(i ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (false);

  CORBA::Long value = this->obj_->op3(i ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (false);

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

  for (CORBA::Long j = 1; j <= 5; j++)
    {
      this->obj_->op4(495 + (i * 5) + j ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (false);
    }

  bool caught_exception = false;
  
  ACE_TRY
  {
    this->obj_->op5(ACE_ENV_SINGLE_ARG_PARAMETER);
    ACE_TRY_CHECK;
  }
  ACE_CATCH (FooException, ex)
  {
    // Expected
    caught_exception = true;
  }
  ACE_ENDTRY;

  if (! caught_exception)
    {
      check_validity = false;
    }

  this->obj_->done(ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (false);

  return check_validity;
}


void
Foo_C_ClientEngine::expected_results(Foo_C_Statistics& stats)
{
  // This ClientEngine is used by remote clients.
  stats.expected(1, 1, true); 
  stats.expected(2, 1, true);
  stats.expected(3, 1, true);
  stats.expected(4, 5, true);
  stats.expected(5, 1, true);
}