summaryrefslogtreecommitdiff
path: root/TAO/tests/Collocated_DerivedIF/Client_Task.cpp
blob: 01fc08696f7136d1a1ddfa6680148445c3e66ef7 (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

#include "Client_Task.h"
#include "TestC.h"

Client_Task::Client_Task (const ACE_TCHAR *ior,
                          CORBA::ORB_ptr corb,
                          ACE_Thread_Manager *thr_mgr)
  : ACE_Task_Base (thr_mgr)
    , input_ (ior)
    , corb_ (CORBA::ORB::_duplicate (corb))

{
}

int
Client_Task::svc ()
{
  int status = 0;

  try
    {
      CORBA::Object_var tmp =
        this->corb_->string_to_object (input_);

       Test::HelloAgain_var hello_again =
         Test::HelloAgain::_narrow(tmp.in ());

      if (CORBA::is_nil (hello_again.in()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Nil Test::HelloAgain reference <%s>\n",
                             input_),
                             1);
        }

      CORBA::String_var  the_string = hello_again->get_string ();
      if (ACE_OS::strcmp (the_string.in (), "Hello there!") != 0)
         {
           ACE_ERROR ((LM_ERROR, "(%P|%t) - Error, incorrect string returned <%C>\n",
                       the_string.in ()));
           status = 1;
         }
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string from hello_again returned <%C>\n",
                  the_string.in ()));
       the_string = hello_again->get_string_again ();

      if (ACE_OS::strcmp (the_string.in (), "Bye!") != 0)
        {
          ACE_ERROR ((LM_ERROR, "(%P|%t) - Error, incorrect string returned <%C>\n",
                      the_string.in ()));
          status = 1;
        }

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string  from hello_again returned <%C>\n",
                  the_string.in ()));
      hello_again->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      status = 1;
    }

  return status;
}