1 #include "Server_ORBInitializer.h"
2 #include "tao/ORBInitializer_Registry.h"
5 int test_orb (CORBA::ORB_ptr orb
)
9 POA_TestModule::test
* test
= 0;
12 PortableServer::ServantBase_var
safe (test
);
14 CORBA::Object_var object
= test
->_this ();
16 orb
->register_initial_reference ("ORBMyService",
19 bool invalid_name
= false;
22 // Registering with an empty string should give an exception
23 orb
->register_initial_reference ("",
26 catch (const CORBA::ORB::InvalidName
&)
30 catch (const CORBA::Exception
&)
37 ACE_ERROR ((LM_ERROR
, "ERROR: Registering with an empty string with the ORB"
38 "doesn't throw an exception\n"));
41 bool duplicate_name
= false;
44 // Registering with an duplicate string should give an exception
45 orb
->register_initial_reference ("ORBMyService",
48 catch (const CORBA::ORB::InvalidName
&)
50 duplicate_name
= true;
52 catch (const CORBA::Exception
&)
59 ACE_ERROR ((LM_ERROR
, "ERROR: Registering with a duplicate with ORB "
60 "doesn't throw the expected exception\n"));
63 bool invalid_object
= false;
66 // Registering with a nil object
67 orb
->register_initial_reference ("ORBNilServer",
68 CORBA::Object::_nil());
70 catch (const CORBA::BAD_PARAM
& ex
)
72 if ((ex
.minor() & 0xFFFU
) == 27)
74 invalid_object
= true;
77 catch (const CORBA::Exception
&)
84 ACE_ERROR ((LM_ERROR
, "ERROR: Registering with a nil object to ORB "
85 "doesn't throw bad param with minor code 27\n"));
92 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
94 Server_ORBInitializer
*initializer
= 0;
97 ACE_NEW_RETURN (initializer
,
98 Server_ORBInitializer
,
99 -1); // No exceptions yet!
101 PortableInterceptor::ORBInitializer_var initializer_var
=
107 CORBA::ORB_init (argc
, argv
);
109 retval
= test_orb (orb
.in ());
111 PortableInterceptor::register_orb_initializer (initializer_var
.in ());
113 CORBA::ORB_var second_orb
=
114 CORBA::ORB_init (argc
, argv
, "SecondORB");
116 second_orb
->destroy ();
120 catch (const CORBA::Exception
& ex
)
122 ex
._tao_print_exception ("Caught exception in server:");