Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tests / RTCORBA / Bug_3382_Regression / simple_client.cpp
blob620b1327e1475121f1927ed492b2d9c4a7fb17ef
1 #include "tao/ORB_Core.h"
2 #include "tao/RTCORBA/RTCORBA.h"
3 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
4 #include "ace/Get_Opt.h"
6 int
7 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
9 int result = 0;
11 ACE_DEBUG ((LM_DEBUG, "Testing : "));
13 for (int arg_i = 0; arg_i < argc; ++arg_i)
15 ACE_DEBUG ((LM_DEBUG, "%s ", argv[arg_i]));
18 ACE_DEBUG ((LM_DEBUG, "\n\n"));
20 try
22 CORBA::ORB_var orb =
23 CORBA::ORB_init (argc, argv);
25 CORBA::Object_var object =
26 orb->resolve_initial_references ("RTCurrent");
28 RTCORBA::Current_var current =
29 RTCORBA::Current::_narrow (object.in ());
31 object = orb->resolve_initial_references ("PriorityMappingManager");
33 RTCORBA::PriorityMappingManager_var mapping_manager =
34 RTCORBA::PriorityMappingManager::_narrow (object.in ());
36 RTCORBA::PriorityMapping *pm =
37 mapping_manager->mapping ();
39 ACE_DEBUG ((LM_DEBUG, "Testing part #1\n\n"));
41 // Check for this priority mapping that we are kosher
42 RTCORBA::Priority i = RTCORBA::minPriority;
45 CORBA::Short native1 = -1, corba1 = -1, native2 = -1, corba2 = -1;
47 if (pm->to_native (i, native1))
49 if (! (pm->to_CORBA (native1, corba1) &&
50 pm->to_native (corba1, native2) &&
51 pm->to_CORBA (native2, corba2)))
53 ACE_DEBUG ((LM_DEBUG, "ERROR : Mapping reported false during CORBA %d -> Native %d -> CORBA %d -> Native %d\n",
55 native1,
56 corba1,
57 native2
58 ));
60 else if (! (corba2 == corba1 && native1 == native2))
62 // titsup
63 ACE_DEBUG ((LM_DEBUG, "ERROR - Not idem-thingy. Mapping went: CORBA %d -> Native %d -> CORBA %d -> Native %d - CORBA %d\n",
65 native1,
66 corba1,
67 native2,
68 corba2
69 ));
70 result = -1;
73 i = i + 1; // There's a reason to not use unary increment
75 while (i != RTCORBA::minPriority);
77 ACE_DEBUG ((LM_DEBUG, "\n\nTesting part #2\n\n"));
79 // Accessing the priority when it hasn't been set should throw an exception
80 try
82 i = current->the_priority ();
83 ACE_DEBUG ((LM_DEBUG, "ERROR: Unexpectedly was able to access thread CORBA priority of %d when it hadn't been set\n", i));
84 result = -1;
86 catch (const CORBA::INITIALIZE &)
88 // This is what should happen
90 catch (const CORBA::Exception & ex)
92 ex._tao_print_exception ("ERROR: Unexpected exception type accessing thread CORBA priority when it hadn't been set: ");
93 result = -1;
95 catch (...)
97 ACE_DEBUG ((LM_DEBUG, "ERROR: Wildly unexpected exception type accessing thread CORBA priority when it hadn't been set\n", i));
98 result = -1;
101 ACE_DEBUG ((LM_DEBUG, "\nTesting part #3\n\n"));
103 // Setting an invalid CORBA priority should generate a BAD_PARAM if the mapping has rejected it
106 current->the_priority (-1);
107 ACE_DEBUG ((LM_DEBUG, "ERROR: Unexpectedly was able to set a thread CORBA priority\n"));
108 result = -1;
110 catch (const CORBA::BAD_PARAM &)
112 // This is what should happen
114 catch (const CORBA::Exception & ex)
116 ex._tao_print_exception ("ERROR: Unexpected exception type setting an invalid CORBA priority");
117 result = -1;
119 catch (...)
121 ACE_DEBUG ((LM_DEBUG, "ERROR: Wildly unexpected exception setting an invalid CORBA priority\n"));
122 result = -1;
125 catch (const CORBA::Exception & ex)
127 ex._tao_print_exception ("ERROR: Unexpected exception ");
128 result = -1;
130 catch (...)
132 ACE_DEBUG ((LM_DEBUG, "ERROR: Unknown exception\n"));
133 result = -1;
136 return result;