Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Bug_2791_Regression / client.cpp
blob016f71f13d1eb01a4ec8723718f549544974c643
2 #include "MessageFactory.h"
3 #include "MessageC.h"
4 #include "tao/corba.h"
5 #include "tao/AnyTypeCode/TypeCode.h"
8 int
9 ACE_TMAIN (
10 int argc,
11 ACE_TCHAR *argv[])
13 try
15 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
17 MessageFactory *mf = new MessageFactory ();
18 CORBA::String_var id = _tc_Message->id ();
20 ACE_DEBUG ((LM_DEBUG, "Registering factory reference\n"));
21 orb->register_value_factory (id.in (), mf);
23 ACE_DEBUG ((LM_DEBUG, "Unregistering factory reference\n"));
24 orb->unregister_value_factory (id.in ());
26 ACE_DEBUG ((LM_DEBUG, "Value factory destructor flag: %i\n", MessageFactory::destructorInvoked_));
28 ACE_DEBUG ((LM_DEBUG, "Actively removing reference\n"));
29 mf->_remove_ref ();
31 ACE_DEBUG ((LM_DEBUG, "Value factory destructor flag: %i\n", MessageFactory::destructorInvoked_));
33 ACE_DEBUG ((LM_DEBUG, "Shutting down / destroying ORB\n"));
34 orb->shutdown (true);
35 orb->destroy ();
37 if (MessageFactory::destructorInvoked_ == 1)
39 ACE_DEBUG ((LM_ERROR, "Test passed: value factory destructor was invoked as expected\n"));
40 return 0;
42 else
44 ACE_DEBUG ((LM_ERROR, "Test failed: value factory destructor was not invoked\n"));
45 return 1;
48 catch (const CORBA::Exception& ex)
50 ex._tao_print_exception ("CORBA exception caught during execution");
51 return -1;
53 catch (...)
55 ACE_DEBUG ((LM_ERROR, "Non-CORBA exception caught during execution"));
56 return -1;