=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Register_Initial_References / server.cpp
blob1694c6615a3c3fec9dba95f3388ed5ba27e744df
1 #include "Server_ORBInitializer.h"
2 #include "tao/ORBInitializer_Registry.h"
3 #include "test_i.h"
5 int test_orb (CORBA::ORB_ptr orb)
7 int errors = 0;
9 POA_TestModule::test* test = 0;
10 ACE_NEW_RETURN (test,
11 test_i, 1);
12 PortableServer::ServantBase_var safe (test);
14 CORBA::Object_var object = test->_this ();
16 orb->register_initial_reference ("ORBMyService",
17 object.in ());
19 bool invalid_name = false;
20 try
22 // Registering with an empty string should give an exception
23 orb->register_initial_reference ("",
24 object.in ());
26 catch (const CORBA::ORB::InvalidName&)
28 invalid_name = true;
30 catch (const CORBA::Exception&)
34 if (!invalid_name)
36 errors++;
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;
42 try
44 // Registering with an duplicate string should give an exception
45 orb->register_initial_reference ("ORBMyService",
46 object.in ());
48 catch (const CORBA::ORB::InvalidName&)
50 duplicate_name = true;
52 catch (const CORBA::Exception&)
56 if (!duplicate_name)
58 errors++;
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;
64 try
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&)
81 if (!invalid_object)
83 errors++;
84 ACE_ERROR ((LM_ERROR, "ERROR: Registering with a nil object to ORB "
85 "doesn't throw bad param with minor code 27\n"));
88 return errors;
91 int
92 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
94 Server_ORBInitializer *initializer = 0;
95 int retval = 0;
97 ACE_NEW_RETURN (initializer,
98 Server_ORBInitializer,
99 -1); // No exceptions yet!
101 PortableInterceptor::ORBInitializer_var initializer_var =
102 initializer;
106 CORBA::ORB_var orb =
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 ();
118 orb->destroy ();
120 catch (const CORBA::Exception& ex)
122 ex._tao_print_exception ("Caught exception in server:");
123 return 1;
126 return retval;