2 #include "ace/Get_Opt.h"
3 #include "tao/RTCORBA/RTCORBA.h"
5 const ACE_TCHAR
*ior1
= ACE_TEXT("file://test1.ior");
6 const ACE_TCHAR
*ior2
= ACE_TEXT("file://test2.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("p:o:"));
14 while ((c
= get_opts ()) != -1)
18 ior1
= get_opts
.opt_arg ();
21 ior2
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
38 check_for_nil (CORBA::Object_ptr obj
, const char *msg
)
40 if (CORBA::is_nil (obj
))
41 ACE_ERROR_RETURN ((LM_ERROR
,
42 "ERROR: Object reference <%C> is nil\n",
50 check_policy (Test_ptr server
)
52 CORBA::Policy_var policy
=
53 server
->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE
);
55 RTCORBA::PriorityModelPolicy_var priority_policy
=
56 RTCORBA::PriorityModelPolicy::_narrow (policy
.in ());
58 if (check_for_nil (priority_policy
.in (), "PriorityModelPolicy") == -1)
61 RTCORBA::PriorityModel priority_model
=
62 priority_policy
->priority_model ();
63 if (priority_model
!= RTCORBA::SERVER_DECLARED
)
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 "ERROR: priority_model != "
66 "RTCORBA::SERVER_DECLARED!\n"),
69 return priority_policy
->server_priority ();
73 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
77 // Initialize the ORB, resolve references and parse arguments.
81 CORBA::ORB_init (argc
, argv
);
84 if (parse_args (argc
, argv
) != 0)
88 CORBA::Object_var object
=
89 orb
->string_to_object (ior1
);
91 Test_var server1
= Test::_narrow (object
.in ());
92 if (check_for_nil (server1
.in (), "server1") == -1)
96 object
= orb
->string_to_object (ior2
);
98 Test_var server2
= Test::_narrow (object
.in ());
99 if (check_for_nil (server2
.in (), "server2") == -1)
102 // Check that test objects are configured with SERVER_DECLARED
103 // PriorityModelPolicy, and get their server priorities.
106 CORBA::Short server1_priority
=
107 check_policy (server1
.in ());
109 if (server1_priority
== -1)
113 CORBA::Short server2_priority
=
114 check_policy (server2
.in ());
115 if (server2_priority
== -1)
118 // Testing: make several invocations on test objects.
119 for (int i
= 0; i
< 5; ++i
)
121 server1
->test_method (server1_priority
);
123 server2
->test_method (server2_priority
);
126 // Testing over. Shut down Server ORB.
127 server1
->shutdown ();
129 catch (const CORBA::Exception
& ex
)
131 ex
._tao_print_exception (
132 "Unexpected exception in Server_Declared test client:");