1 #include "Server_Task.h"
2 #include "Client_Task.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Argv_Type_Converter.h"
5 #include "ace/SString.h"
6 #include "ace/Manual_Event.h"
8 const ACE_TCHAR
*output
= ACE_TEXT("server.ior");
9 const ACE_TCHAR
*input
= ACE_TEXT("file://server.ior");
10 const ACE_TCHAR
*simple_test_output
= ACE_TEXT("simple_test.ior");
11 const ACE_TCHAR
*simple_test_input
= ACE_TEXT("file://simple_test.ior");
12 // static int named_orbs = 0;
13 ACE_CString server_orb
;
14 ACE_CString client_orb
;
16 CORBA::Boolean debug
= 0;
19 parse_args (int argc
, ACE_TCHAR
*argv
[])
21 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:o:nd"));
24 while ((c
= get_opts ()) != -1)
28 output
= get_opts
.opt_arg ();
31 input
= get_opts
.opt_arg ();
35 server_orb
.set ("server_orb");
36 client_orb
.set ("client_orb");
43 // This is a hack but that is okay!
46 // Indicates successful parsing of the command line
51 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
59 ACE_Argv_Type_Converter
satc (argc
, argv
);
61 CORBA::ORB_init (satc
.get_argc (),
62 satc
.get_TCHAR_argv (),
66 Server_Task
server_task (output
,
70 ACE_Thread_Manager::instance ());
72 if (server_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
76 ACE_ERROR ((LM_ERROR
, "Error activating server task\n"));
79 // Wait for the server thread to do some processing
82 ACE_Argv_Type_Converter
catc (argc
, argv
);
84 CORBA::ORB_init (catc
.get_argc (),
85 catc
.get_TCHAR_argv (),
88 Client_Task
client_task (input
,
91 ACE_Thread_Manager::instance ());
93 if (client_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
97 ACE_ERROR ((LM_ERROR
, "Error activating client task\n"));
100 // Wait for the client and server to finish
101 ACE_Thread_Manager::instance ()->wait ();
103 // Now that all threads have completed we can destroy the ORB
105 if (server_orb
!= client_orb
)
110 CORBA::ULong errors
= client_task
.error_count () + server_task
.error_count ();
113 ACE_DEBUG((LM_DEBUG
, "(%P|%t) test passed\n"));
117 ACE_DEBUG((LM_DEBUG
, "(%P|%t) test failed - error_count=%u\n", errors
));
121 catch (const CORBA::Exception
&)
123 // Ignore exceptions..