summaryrefslogtreecommitdiff
path: root/TAO/tests/Portable_Interceptors/Slot/driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/Portable_Interceptors/Slot/driver.cpp')
-rw-r--r--TAO/tests/Portable_Interceptors/Slot/driver.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/TAO/tests/Portable_Interceptors/Slot/driver.cpp b/TAO/tests/Portable_Interceptors/Slot/driver.cpp
new file mode 100644
index 00000000000..b7d2b320500
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/Slot/driver.cpp
@@ -0,0 +1,64 @@
+// file : Slot/driver.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// cvs-id : $Id$
+
+#include "tao/PI/PI.h"
+#include "tao/LocalObject.h"
+#include "tao/ORBInitializer_Registry.h"
+
+PortableInterceptor::SlotId slot_id;
+
+class ORB_Initializer : public virtual PortableInterceptor::ORBInitializer,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+ virtual void
+ pre_init (PortableInterceptor::ORBInitInfo_ptr) throw (CORBA::SystemException)
+ {
+ }
+
+ virtual void
+ post_init (PortableInterceptor::ORBInitInfo_ptr info) throw (CORBA::SystemException)
+ {
+ slot_id = info->allocate_slot_id ();
+ ACE_DEBUG ((LM_DEBUG, "Allocated slot with id %d.\n", slot_id));
+ }
+};
+
+int
+main (int argc, char *argv[])
+{
+
+ try
+ {
+ PortableInterceptor::ORBInitializer_var orb_initializer = new ORB_Initializer ();
+ PortableInterceptor::register_orb_initializer (orb_initializer.in ());
+
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var pic_obj = orb->resolve_initial_references ("PICurrent");
+ PortableInterceptor::Current_var pic (
+ PortableInterceptor::Current::_narrow (pic_obj.in ()));
+
+ CORBA::Any in;
+ in <<= CORBA::ULong (1);
+ pic->set_slot (slot_id, in);
+
+ CORBA::ULong v (0);
+ CORBA::Any_var out = pic->get_slot (slot_id);
+ out >>= v;
+
+ if (v != 1)
+ {
+ ACE_ERROR ((LM_ERROR, "ERROR: Slot value was not preserved.\n"));
+ return 1;
+ }
+ }
+ catch (PortableInterceptor::InvalidSlot const&)
+ {
+ ACE_ERROR ((LM_ERROR, "ERROR: Caught InvalidSlot exception.\n"));
+ return 1;
+ }
+
+ return 0;
+}