3 #include "tao/Object.h"
4 #include "tao/SystemException.h"
6 #include "ace/Log_Msg.h"
9 // Do not attempt to narrow the object represented by this IOR, nor
10 // should you modify the IOR unless you replace it with another
12 static const char IOR
[] =
13 "IOR:010000001600000049444c3a43756269745f466163746f72793a312e30000000010000000000000090000000010102cd14000000616e647572696c2e6563652e7563692e6564750057fecdcd2d00000014010f004e5550000000130000000001000000006368696c645f706f61000000000001000000666163746f7279cdcdcd03000000000000000800000001cdcdcd004f4154010000001400000001cdcdcd01000100000000000901010000000000004f41540400000001cd0000";
16 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
22 const char orbid
[] = "mighty_orb";
24 CORBA::ORB_ptr my_orb
= CORBA::ORB::_nil();
27 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
, orbid
);
31 // Once we leave this scope, the ORB is released but it should
32 // be possible to obtain the same ORB with another call to
33 // CORBA::ORB_init() by using the same ORBid argument that was
34 // assigned to this ORB.
37 // -------------------------------------------------------------
38 // Verify that the same ORB is returned from a second call to
39 // CORBA::ORB_init() in a different scope when the same ORBid is
40 // used in that scope.
41 // -------------------------------------------------------------
43 orb
= CORBA::ORB_init (argc
, argv
, orbid
);
45 // This isn't portable, but TAO implements an ORB_ptr as a
46 // pointer so we're okay.
48 // Check if the ORB returned from the ORB_init() call is the
50 if (my_orb
== orb
.in ())
54 "The ORB <%C> was successfully returned from a second\n"
55 "call to CORBA::ORB_init() after it was released in\n"
62 ACE_ERROR_RETURN ((LM_ERROR
,
64 "ORB <%C> was not successfully returned from a\n"
65 "second call to CORBA::ORB_init() despite the\n"
66 "fact it wasn't explicitly destroyed.\n"
72 // -------------------------------------------------------------
73 // Now explicitly destroy the ORB with the given ORBid and
74 // attempt to initialize a new ORB with the same ORBid.
75 // -------------------------------------------------------------
79 orb
= CORBA::ORB_init (argc
, argv
, orbid
);
81 // This isn't portable, but TAO implements an ORB_ptr as a
82 // pointer so we're okay.
84 // Check if the ORB returned from the ORB_init() call is the
86 if (my_orb
!= orb
.in ())
90 "A new ORB with ORBid <%C> was successfully returned\n"
91 "from a second call to CORBA::ORB_init() after the\n"
92 "first ORB with the same ORBid was destroyed.\n"
100 "ORB <%C> was not successfully destroyed.\n"
104 throw CORBA::INTERNAL ();
107 // -------------------------------------------------------------
108 // Create an object (but don't narrow() it) so that we can test
109 // that some of the TAO_Stub internals are functioning properly
111 // -------------------------------------------------------------
113 CORBA::Object_var object
=
114 orb
->string_to_object (IOR
);
116 // -------------------------------------------------------------
117 // Initialize another two ORBs but don't explicitly destroy them
118 // to allow testing of TAO's internal ORB table resource
120 // -------------------------------------------------------------
121 CORBA::ORB_var orb2
=
122 CORBA::ORB_init (argc
, argv
, "ORB number 2");
124 CORBA::ORB_var orb3
=
125 CORBA::ORB_init (argc
, argv
, "ORB number 3");
127 // -------------------------------------------------------------
128 // Now try to perform an operation using the destroyed ORB
129 // pseudo object. A CORBA::OBJECT_NOT_EXIST() exception should
130 // be thrown. This also tests whether or not exceptions or the
131 // ORB itself break when the last ORB is released.
132 // -------------------------------------------------------------
136 CORBA::Object_var obj
=
137 orb
->resolve_initial_references ("RootPOA");
139 // If we get here, then something went wrong. A
140 // CORBA::OBJECT_NOT_EXIST() exception should have been thrown!.
141 ACE_ERROR ((LM_ERROR
,
143 "CORBA::OBJECT_NOT_EXIST() exception was not thrown\n"
144 "during attempt to perform an ORB operation using\n"
145 "destroyed ORB <%C>\n"
146 "The CORBA::OBJECT_NOT_EXIST() exception should have\n"
151 throw CORBA::INTERNAL ();
153 catch (const CORBA::OBJECT_NOT_EXIST
& exc
)
155 // Do something with the exception to make sure it actually
156 // exists. If it doesn't exist then there is something wrong
157 // with exception lifetime.
160 "Successfully caught CORBA system exception after the\n"
161 "last ORB was released with the following repository ID:\n"
163 "This exception was expected. It is safe to ignore it.\n",
166 catch (const CORBA::Exception
& ex
)
168 ex
._tao_print_exception ("Caught unexpected exception:");
171 ACE_DEBUG ((LM_ERROR
,
173 "ORB_init test failed.\n"));
180 "ORB_init test completed successfully.\n"));