Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tests / Bug_1495_Regression / Client_Task.cpp
blobe74bea493969c426f1ce50ad88c58509379f31a2
1 /**
2 * @file Client_Task.cpp
3 * @author Will Otte <wotte@dre.vanderbilt.edu
5 * Implements the Client_Task class defined in Client_Task.h.
6 */
8 #include "Client_Task.h"
9 #include "testC.h"
10 #include "Client_ORBInitializer.h"
11 #include "tid_to_int.h"
12 #include "ace/OS_NS_unistd.h"
13 #include "ace/OS_NS_sys_stat.h"
15 Client_Task::Client_Task (const ACE_TCHAR *input,
16 CORBA::ORB_ptr corb,
17 ACE_Thread_Manager *thr_mgr)
18 : ACE_Task_Base (thr_mgr),
19 input_ (input),
20 corb_ (CORBA::ORB::_duplicate (corb))
23 int
24 Client_Task::svc ()
26 try
28 // The test was designed so that we have to wait here.
29 ACE_stat st;
30 int timeout = 10;
31 while (--timeout)
33 if (ACE_OS::stat (this->input_, &st) == 0 &&
34 st.st_size != 0)
36 break;
39 ACE_OS::sleep (1);
42 ACE_TString infile = ACE_TString (ACE_TEXT("file://")) + this->input_;
44 CORBA::Object_var object =
45 this->corb_->string_to_object (infile.c_str ());
47 Bug1495_Regression::Bug1495_var server =
48 Bug1495_Regression::Bug1495::_narrow (object.in ());
50 if (CORBA::is_nil (server.in ()))
52 ACE_ERROR ((LM_ERROR,
53 "Object reference <%s> is nil\n",
54 input_));
56 return 1;
59 // Try multiple calls to see if we keep being forwarded
60 for (int i = 0; i < 5; ++i)
62 using Bug1495_Regression::ThreadId;
64 // call the thread_id function on the test object
65 ThreadId remote_thread_id;
67 server->get_thread_id (remote_thread_id);
69 ACE_DEBUG ((LM_INFO,
70 ACE_TEXT ("Remote thread ID was ")
71 ACE_INT64_FORMAT_SPECIFIER
72 ACE_TEXT ("\n"),
73 remote_thread_id));
75 ThreadId const mythread_id =
76 ACE_thread_t_to_integer<ThreadId> (ACE_Thread::self ());
78 if (mythread_id != remote_thread_id)
80 ACE_ERROR ((LM_ERROR,
81 ACE_TEXT ("ERROR: Failed Bug_1495_Regression test. ")
82 ACE_TEXT ("Expected thread id was ")
83 ACE_INT64_FORMAT_SPECIFIER
84 ACE_TEXT (", received ")
85 ACE_INT64_FORMAT_SPECIFIER
86 ACE_TEXT (".\n"),
87 mythread_id,
88 remote_thread_id));
90 else
92 ACE_DEBUG ((LM_INFO,
93 ACE_TEXT ("Passed Bug_1495_Regression test.\n")
94 ACE_TEXT ("Local thread id was ")
95 ACE_INT64_FORMAT_SPECIFIER
96 ACE_TEXT (", received ")
97 ACE_INT64_FORMAT_SPECIFIER
98 ACE_TEXT (".\n"),
99 mythread_id,
100 remote_thread_id));
104 catch (const CORBA::Exception& ex)
106 ex._tao_print_exception ("Caught exception in client task:");
107 return 1;
110 return 0;