Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / FaultTolerance / IOGRManipulation / IOGRTest.cpp
blob8803f71bfa9960fd02ffed0b753af3e3538bb23c
2 //=============================================================================
3 /**
4 * @file IOGRTest.cpp
6 * This program tests the basic functionality FT IOGR implementation
8 * @author Bala Natarajan <bala@cs.wustl.edu>
9 */
10 //=============================================================================
13 #include "tao/ORB.h"
14 #include "orbsvcs/FT_CORBA_ORBC.h"
15 #include "orbsvcs/FaultTolerance/FT_IOGR_Property.h"
17 int
18 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
20 ACE_DEBUG ((LM_DEBUG, "---------------------------------------------\n"));
21 ACE_DEBUG ((LM_DEBUG, "Running the IOGRManipulation Tests.\n"));
23 try
25 // Retrieve the ORB.
26 CORBA::ORB_var orb_ = CORBA::ORB_init (argc, argv);
27 // **********************************************************************
29 // Get an object reference for the ORBs IORManipulation object!
30 CORBA::Object_var IORM =
31 orb_->resolve_initial_references (TAO_OBJID_IORMANIPULATION, 0);
33 TAO_IOP::TAO_IOR_Manipulation_var iorm =
34 TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in ());
35 // **********************************************************************
37 // Create a few fictitious IORs
38 CORBA::Object_var name1 =
39 orb_->string_to_object ("iiop://acme.cs.wustl.edu:6060/xyz");
40 CORBA::Object_var name2 =
41 orb_->string_to_object ("iiop://tango.cs.wustl.edu:7070/xyz");
43 // **********************************************************************
44 // Create IOR list for use with merge_iors.
45 TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
46 iors.length (2);
47 iors [0] = name1;
48 iors [1] = name2;
49 // **********************************************************************
51 CORBA::Object_var merged = iorm->merge_iors (iors);
53 // Check for set and get primaries
54 // Make a dummy property set
55 FT::TagFTGroupTaggedComponent ft_tag_component;
56 TAO_FT_IOGR_Property prop (ft_tag_component);
58 CORBA::Boolean retval =
59 iorm->set_primary (&prop, name2.in (), merged.in ());
61 if (retval != 0)
63 ACE_DEBUG ((LM_DEBUG,
64 ACE_TEXT ("\tThe primary has been set\n")));
66 else
68 ACE_ERROR ((LM_ERROR,
69 ACE_TEXT ("\tError in setting primary\n")));
70 return -1;
73 // Check whether a primary has been set
74 retval = iorm->is_primary_set (&prop, merged.in ());
76 if (retval)
78 ACE_DEBUG ((LM_DEBUG,
79 ACE_TEXT ("\tis_primary_set () returned true\n")));
81 else
83 ACE_ERROR ((LM_ERROR,
84 ACE_TEXT ("\tis_primary_set () returned false\n")));
86 ACE_ERROR ((LM_ERROR,
87 ACE_TEXT ("\tSo Exiting\n")));
88 return -1;
91 // Get the primary
92 CORBA::Object_var prim = iorm->get_primary (&prop, merged.in ());
94 // Check whether we got back the right primary
95 if (prim->_is_equivalent (name2.in ()))
97 ACE_DEBUG ((LM_DEBUG,
98 ACE_TEXT ("\tWe got the right primary back\n")));
100 else
102 ACE_ERROR ((LM_ERROR,
103 ACE_TEXT ("\tWe have a problem in getting the right primary\n")));
104 ACE_ERROR ((LM_ERROR,
105 ACE_TEXT ("\tSo exiting\n")));
106 return -1;
108 // **********************************************************************
109 // Set properties
110 // Property values
112 // Major and Minor revision numbers
113 ft_tag_component.component_version.major = (CORBA::Octet) 1;
114 ft_tag_component.component_version.minor = (CORBA::Octet) 0;
116 // Domain id
117 const char *id = "iogr_regression";
118 ft_tag_component.group_domain_id = id;
120 // Object group id
121 ft_tag_component.object_group_id = (CORBA::ULongLong) 10;
123 // Version
124 ft_tag_component.object_group_ref_version = (CORBA::ULong) 5;
126 // Set the property
127 retval = iorm->set_property (&prop, merged.in ());
129 /// Extract the property
130 FT::TagFTGroupTaggedComponent ftc;
131 TAO_FT_IOGR_Property tmp_prop;
133 retval = tmp_prop.get_tagged_component (merged.in (), ftc);
136 ACE_DEBUG ((LM_DEBUG,
137 "(%P|%t) Testing for tagged component\n"));
139 if ((ftc.object_group_ref_version != 5) &&
140 (ftc.object_group_id != 10))
141 ACE_ERROR ((LM_ERROR,
142 "%P|%t) Not working right\n"));
144 if (retval)
145 ACE_DEBUG ((LM_DEBUG,
146 ACE_TEXT ("\tWe have set the property\n")));
148 orb_->destroy ();
150 catch (const TAO_IOP::NotFound& userex)
152 userex._tao_print_exception (
153 ACE_TEXT ("Unexpected NotFound Exception!\n"));
154 return -1;
156 catch (const TAO_IOP::Duplicate& userex)
158 userex._tao_print_exception ("Unexpected Duplicate Exception!\n");
159 return -1;
161 catch (const TAO_IOP::Invalid_IOR& userex)
163 userex._tao_print_exception ("Unexpected Invalid_IOR Exception!\n");
164 return -1;
166 catch (const CORBA::SystemException& sysex)
168 sysex._tao_print_exception ("Unexpected system Exception!!\n");
169 return -1;
171 catch (const CORBA::Exception& ex)
173 ex._tao_print_exception ("Unexpected CORBA Exception!\n");
174 return -1;
177 ACE_DEBUG ((LM_DEBUG, "IORManipulation Tests Successfully Completed!\n"));
178 ACE_DEBUG ((LM_DEBUG, "---------------------------------------------\n"));
180 return 0;