summaryrefslogtreecommitdiff
path: root/ACE/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.cpp
blob: e6075f9cec636223472f255171e43c601c5db7d7 (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
// $Id$
#include "Foo_B_SimpleClientEngine.h"
#include "Callback_i.h"
#include "Foo_B_Statistics.h"
#include "TestAppExceptionC.h"
#include "AppHelper.h"
#include "ace/Log_Msg.h"
#include "ace/OS.h"

extern const char* ONEWAY_ARG_TEST_STR;

Foo_B_SimpleClientEngine::Foo_B_SimpleClientEngine(Foo_B_ptr obj,
                                                   Callback_ptr callback,
                                                   unsigned client_id,
                                                   bool collocated)
  : obj_(Foo_B::_duplicate(obj)),
    callback_(Callback::_duplicate(callback)),
    client_id_(client_id),
    collocated_(collocated)
{
}


Foo_B_SimpleClientEngine::~Foo_B_SimpleClientEngine()
{
}


bool
Foo_B_SimpleClientEngine::execute(void)
{
  // 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_SimpleClientEngine::execute  " \
                          "client %d connect failed.\n", this->client_id_));
      return false;
    }

  // Verify the return values and return the results.
  bool check_validity = true;

  // Callback test.
  try
  {
    if (CORBA::is_nil(this->callback_.in()))
      {
        ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_SimpleClientEngine::execute  " \
                   "The callback_ objref is nil before op7() call!\n"));
      }

    this->obj_->op7 (this->callback_.in ());
  }
  catch (const FooException& )
  {
    ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_SimpleClientEngine::execute  " \
               "FooException raised by op7() call.\n"));
    check_validity = false;
  }

  // Tell the servant that this client is done.
  this->obj_->done();

  return check_validity;
}


void
Foo_B_SimpleClientEngine::expected_results(Foo_B_Statistics& stats)
{
  stats.expected(7, 1, Foo_B_Statistics::FOO_B_STAT_NONE);
}


unsigned
Foo_B_SimpleClientEngine::expected_callbacks ()
{
  return 1;
}