2 //=============================================================================
6 * This program tests the basic functionality FT IOGR implementation
8 * @author Bala Natarajan <bala@cs.wustl.edu>
10 //=============================================================================
14 #include "orbsvcs/FT_CORBA_ORBC.h"
15 #include "orbsvcs/FaultTolerance/FT_IOGR_Property.h"
18 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
20 ACE_DEBUG ((LM_DEBUG
, "---------------------------------------------\n"));
21 ACE_DEBUG ((LM_DEBUG
, "Running the IOGRManipulation Tests.\n"));
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);
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 ());
64 ACE_TEXT ("\tThe primary has been set\n")));
69 ACE_TEXT ("\tError in setting primary\n")));
73 // Check whether a primary has been set
74 retval
= iorm
->is_primary_set (&prop
, merged
.in ());
79 ACE_TEXT ("\tis_primary_set () returned true\n")));
84 ACE_TEXT ("\tis_primary_set () returned false\n")));
87 ACE_TEXT ("\tSo Exiting\n")));
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 ()))
98 ACE_TEXT ("\tWe got the right primary back\n")));
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")));
108 // **********************************************************************
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;
117 const char *id
= "iogr_regression";
118 ft_tag_component
.group_domain_id
= id
;
121 ft_tag_component
.object_group_id
= (CORBA::ULongLong
) 10;
124 ft_tag_component
.object_group_ref_version
= (CORBA::ULong
) 5;
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"));
145 ACE_DEBUG ((LM_DEBUG
,
146 ACE_TEXT ("\tWe have set the property\n")));
150 catch (const TAO_IOP::NotFound
& userex
)
152 userex
._tao_print_exception (
153 ACE_TEXT ("Unexpected NotFound Exception!\n"));
156 catch (const TAO_IOP::Duplicate
& userex
)
158 userex
._tao_print_exception ("Unexpected Duplicate Exception!\n");
161 catch (const TAO_IOP::Invalid_IOR
& userex
)
163 userex
._tao_print_exception ("Unexpected Invalid_IOR Exception!\n");
166 catch (const CORBA::SystemException
& sysex
)
168 sysex
._tao_print_exception ("Unexpected system Exception!!\n");
171 catch (const CORBA::Exception
& ex
)
173 ex
._tao_print_exception ("Unexpected CORBA Exception!\n");
177 ACE_DEBUG ((LM_DEBUG
, "IORManipulation Tests Successfully Completed!\n"));
178 ACE_DEBUG ((LM_DEBUG
, "---------------------------------------------\n"));