Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / InterfaceRepo / IDL3_Test / idl3_client.cpp
blob7de7b2026d086e62d9e7ce3ee0caee0a152eef95
1 // -*- C++ -*-
2 #include "idl3_client.h"
3 #include "tao/ORB.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_string.h"
7 // All the magic quantities are here at the top.
9 const char *COMPONENT_ID = "IDL:mod/test_component:1.0";
10 const char *COMPONENT_SCOPED_NAME = "::mod::test_component";
11 const char *COMP_BASE_ID = "IDL:help/c_base:1.0";
13 const char *VALUETYPE_ID = "IDL:mod/test_valuetype:1.0";
14 const char *VALUETYPE_SCOPED_NAME = "::mod::test_valuetype";
15 const char *VT_BASE_ID = "IDL:help/v_base:1.0";
17 const char *HOME_ID = "IDL:mod/test_home:1.0";
18 const char *HOME_SCOPED_NAME = "::mod::test_home";
19 const char *HOME_BASE_ID = "IDL:help/h_base:1.0";
20 const char *HOME_KEY_ID = "IDL:help/h_key:1.0";
22 const char *EVENTTYPE_ID = "IDL:mod/test_eventtype:1.0";
24 const CORBA::ULong ATTRS_LEN = 1;
25 const CORBA::ULong OPS_LEN = 1;
26 const CORBA::ULong FACTORY_LEN = 2;
28 const char *ATTR_LOCAL_NAMES[] =
30 "c_attr1"
33 const CORBA::TCKind ATTR_TC_KINDS[] =
35 CORBA::tk_long
38 const CORBA::ULong GET_EXCEP_LEN[] =
43 const CORBA::ULong PUT_EXCEP_LEN[] =
48 const char *OP_NAMES[] =
50 "v_op"
53 const CORBA::TCKind OP_RET_KINDS[] =
55 CORBA::tk_string
58 const CORBA::ULong PARAMS_LEN[] =
63 const char *PARAM_NAMES[] =
65 "inoutarg",
66 "inarg",
67 "outarg"
70 const CORBA::ULong OP_EXCEP_LEN[] =
75 const CORBA::ULong COMP_SUPPORTED_LEN = 2;
77 const char *COMP_SUPPORTED_IDS[] =
79 "IDL:help/c_supp1:1.0",
80 "IDL:help/c_supp2:1.0"
83 const CORBA::ULong PROVIDES_LEN = 1;
84 const CORBA::ULong USES_LEN = 2;
85 const CORBA::ULong EMITS_LEN = 1;
86 const CORBA::ULong PUBLISHES_LEN = 1;
87 const CORBA::ULong CONSUMES_LEN = 1;
89 const char *PROVIDES_NAMES[] =
91 "test_provides1"
94 const char *PROVIDES_TYPE_IDS[] =
96 "IDL:help/c_provides1:1.0"
99 const char *USES_NAMES[] =
101 "test_uses1",
102 "test_uses2"
105 const char *USES_TYPE_IDS[] =
107 "IDL:help/c_uses1:1.0",
108 "IDL:help/c_uses2:1.0"
111 const CORBA::Boolean USES_MULTIPLE_FLAGS[] =
117 const char *EMITS_NAMES[] =
119 "test_emits1"
122 const char *PUBLISHES_NAMES[] =
124 "test_publishes1"
127 const char *CONSUMES_NAMES[] =
129 "test_consumes1"
132 const char *EMITS_IDS[] =
134 "IDL:help/c_emits1:1.0"
137 const char *PUBLISHES_IDS[] =
139 "IDL:help/c_publishes1:1.0"
142 const char *CONSUMES_IDS[] =
144 "IDL:help/c_consumes1:1.0"
147 const CORBA::ULong VT_SUPPORTED_LEN = 2;
149 const char *VT_SUPPORTED_IDS[] =
151 "IDL:help/v_supp1:1.0",
152 "IDL:help/v_supp2:1.0"
155 const CORBA::ULong MEM_LEN = 2;
157 const CORBA::Visibility MEM_VIS[] =
159 CORBA::PUBLIC_MEMBER,
160 CORBA::PRIVATE_MEMBER
163 const char *MEM_NAMES[] =
165 "test_mem1",
166 "test_mem2",
169 const CORBA::ULong VT_FACTORY_PARAM_LENS[] =
175 const CORBA::ULong VT_FACTORY_EXCEP_LENS[] =
181 const char *VT_FACTORY_PARAM_NAMES[][2] =
183 {"set_tm1", 0},
184 {"set_tm1a", "set_tm2"}
187 const char *VT_FACTORY_EXCEP_NAMES[][2] =
189 {0, 0},
190 {"whups", "doh"}
193 const CORBA::ULong HOME_SUPPORTED_LEN = 2;
195 const char *HOME_SUPPORTED_IDS[] =
197 "IDL:help/h_supp1:1.0",
198 "IDL:help/h_supp2:1.0"
201 const CORBA::ULong HOME_FACTORY_LEN = 1;
202 const CORBA::ULong HOME_FINDER_LEN = 1;
204 const CORBA::ULong HOME_FACTORY_PARAM_LENS[] =
209 const char *HOME_FACTORY_PARAM_NAMES[][1] =
211 {"set_uid"}
214 const CORBA::ULong HOME_FACTORY_EXCEP_LENS[] =
219 const char *HOME_FACTORY_EXCEP_NAMES[][1] =
221 {"doh"}
224 const CORBA::ULong HOME_FINDER_PARAM_LENS[] =
229 const char *HOME_FINDER_PARAM_NAMES[][3] =
231 {"id_number", "id_string", "pkey"}
234 const CORBA::ULong HOME_FINDER_EXCEP_LENS[] =
239 const char *HOME_FINDER_EXCEP_NAMES[][1] =
241 {"whups"}
244 IDL3_Client::IDL3_Client (void)
245 : debug_ (false)
249 IDL3_Client::~IDL3_Client (void)
254 IDL3_Client::init (int argc,
255 ACE_TCHAR *argv[])
257 this->orb_ = CORBA::ORB_init (argc, argv);
259 CORBA::Object_var obj =
260 this->orb_->resolve_initial_references ("InterfaceRepository");
262 if (CORBA::is_nil (obj.in ()))
264 ACE_ERROR_RETURN ((LM_ERROR,
265 "IDL3_Client - IFR resolution failed\n"),
266 -1);
269 this->repo_ =
270 CORBA::ComponentIR::Repository::_narrow (obj.in ());
272 if (CORBA::is_nil (this->repo_.in ()))
274 ACE_ERROR_RETURN ((LM_ERROR,
275 "IDL3_Client - IFR narrow failed\n"),
276 -1);
279 if (this->parse_args (argc, argv) == -1)
281 return -1;
284 return 0;
288 IDL3_Client::run (void)
290 int status = this->component_test ();
292 if (status != 0)
294 return status;
297 status = this->valuetype_test (VALUETYPE_ID,
298 "value");
300 if (status != 0)
302 return status;
305 status = this->home_test ();
307 if (status != 0)
309 return status;
312 status = this->valuetype_test (EVENTTYPE_ID,
313 "event");
315 if (status != 0)
317 return status;
320 return 0;
324 IDL3_Client::parse_args (int argc,
325 ACE_TCHAR *argv[])
327 ACE_Get_Opt opts (argc, argv, ACE_TEXT("d"));
328 int c;
330 while ((c = opts ()) != -1)
331 switch (c)
333 case 'd': // Turn on debugging outoput.
334 this->debug_ = true;
335 break;
336 case '?':
337 default:
338 ACE_ERROR_RETURN ((LM_ERROR,
339 "usage: %s [-d]\n",
340 argv [0]),
341 -1);
344 return 0;
348 IDL3_Client::component_test (void)
350 CORBA::Contained_var result =
351 this->repo_->lookup_id (COMPONENT_ID);
353 if (CORBA::is_nil (result.in ()))
355 if (this->debug_)
357 ACE_DEBUG ((LM_DEBUG,
358 "component_test: lookup by id failed\n"));
361 return -1;
364 CORBA::String_var str =
365 result->absolute_name ();
367 const char *tmp = str.in ();
369 if (tmp == 0)
371 if (this->debug_)
373 ACE_DEBUG ((LM_DEBUG,
374 "component_test: component has null scoped name\n"));
377 return -1;
380 if (ACE_OS::strcmp (tmp, COMPONENT_SCOPED_NAME) != 0)
382 if (this->debug_)
384 ACE_DEBUG ((LM_DEBUG,
385 "component_test: "
386 "component has incorrect scoped name\n"));
389 return -1;
392 CORBA::ComponentIR::ComponentDef_var comp_def =
393 CORBA::ComponentIR::ComponentDef::_narrow (result.in ());
395 CORBA::TypeCode_var comp_tc =
396 comp_def->type ();
398 if (CORBA::is_nil (comp_tc.in ()))
400 if (this->debug_)
402 ACE_DEBUG ((LM_DEBUG,
403 "component_test: "
404 "type code creation failed\n"));
407 return -1;
410 tmp = comp_tc->id ();
412 if (tmp == 0 || ACE_OS::strcmp (tmp, COMPONENT_ID) != 0)
414 if (this->debug_)
416 ACE_DEBUG ((LM_DEBUG,
417 "component_test: "
418 "bad id from type code\n"));
421 return -1;
424 CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription_var desc =
425 comp_def->describe_ext_interface ();
427 if (desc.ptr () == 0)
429 if (this->debug_)
431 ACE_DEBUG ((LM_DEBUG,
432 "component_test: "
433 "describe_ext_interface return null\n"));
436 return -1;
439 int status = this->component_attribute_test (desc);
441 if (status != 0)
443 return -1;
446 status = this->component_inheritance_test (comp_def);
448 if (status != 0)
450 return -1;
453 status = this->component_port_test (comp_def);
455 if (status != 0)
457 return -1;
460 return 0;
464 IDL3_Client::home_test (void)
466 CORBA::Contained_var result =
467 this->repo_->lookup_id (HOME_ID);
469 if (CORBA::is_nil (result.in ()))
471 if (this->debug_)
473 ACE_DEBUG ((LM_DEBUG,
474 "home_test: lookup by id failed\n"));
477 return -1;
480 CORBA::ComponentIR::HomeDef_var home =
481 CORBA::ComponentIR::HomeDef::_narrow (result.in ());
483 if (CORBA::is_nil (result.in ()))
485 if (this->debug_)
487 ACE_DEBUG ((LM_DEBUG,
488 "home_test: home narrow failed\n"));
491 return -1;
494 CORBA::ComponentIR::ComponentDef_var managed =
495 home->managed_component ();
497 if (CORBA::is_nil (managed.in ()))
499 if (this->debug_)
501 ACE_DEBUG ((LM_DEBUG,
502 "home_test: managed component is null\n"));
505 return -1;
508 CORBA::String_var str = managed->id ();
510 if (str.in () == 0 || ACE_OS::strcmp (str.in (), COMPONENT_ID) != 0)
512 if (this->debug_)
514 ACE_DEBUG ((LM_DEBUG,
515 "home_test: bad id for managed component\n"));
518 return -1;
521 CORBA::ValueDef_var pkey =
522 home->primary_key ();
524 if (CORBA::is_nil (pkey.in ()))
526 if (this->debug_)
528 ACE_DEBUG ((LM_DEBUG,
529 "home_test: primary key is null\n"));
532 return -1;
535 str = pkey->id ();
537 if (str.in () == 0 || ACE_OS::strcmp (str.in (), HOME_KEY_ID) != 0)
539 if (this->debug_)
541 ACE_DEBUG ((LM_DEBUG,
542 "home_test: bad id for managed component\n"));
545 return -1;
548 int status = this->home_inheritance_test (home);
550 if (status != 0)
552 return -1;
555 CORBA::Contained::Description_var desc =
556 home->describe ();
558 const CORBA::ComponentIR::HomeDescription *home_desc = 0;
560 if ((desc->value >>= home_desc) == 0)
562 if (this->debug_)
564 ACE_DEBUG ((LM_DEBUG,
565 "home_test: extraction of HomeDescription failed\n"));
568 return -1;
571 status = this->home_factory_test (home_desc);
573 if (status != 0)
575 return -1;
578 status = this->home_finder_test (home_desc);
580 if (status != 0)
582 return -1;
585 return 0;
589 IDL3_Client::valuetype_test (const char *repo_id,
590 const char *prefix)
592 CORBA::Contained_var result =
593 this->repo_->lookup_id (repo_id);
595 if (CORBA::is_nil (result.in ()))
597 if (this->debug_)
599 ACE_DEBUG ((LM_DEBUG,
600 "%Ctype_test: lookup by id failed\n",
601 prefix));
604 return -1;
607 CORBA::ExtValueDef_var evd =
608 CORBA::ExtValueDef::_narrow (result.in ());
610 if (CORBA::is_nil (evd.in ()))
612 if (this->debug_)
614 ACE_DEBUG ((LM_DEBUG,
615 "%Ctype_test: narrow to ExtValueDef failed\n",
616 prefix));
619 return -1;
622 CORBA::ExtValueDef::ExtFullValueDescription_var desc =
623 evd->describe_ext_value ();
625 int status = this->valuetype_attribute_test (desc,
626 prefix);
628 if (status != 0)
630 return -1;
633 status = this->valuetype_inheritance_test (evd,
634 prefix);
636 if (status != 0)
638 return -1;
641 status = this->valuetype_operation_test (desc,
642 prefix);
644 if (status != 0)
646 return -1;
649 status = this->valuetype_member_test (desc,
650 prefix);
652 if (status != 0)
654 return -1;
657 status = this->valuetype_factory_test (desc, prefix);
659 if (status != 0)
661 return -1;
664 return 0;
668 IDL3_Client::component_attribute_test (
669 CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription_var &desc)
671 if (desc->attributes.length () != ATTRS_LEN)
673 if (this->debug_)
675 ACE_DEBUG ((LM_DEBUG,
676 "component_attribute_test: wrong number of attrs\n"));
679 return -1;
682 const char *tmp = 0;
684 for (CORBA::ULong i = 0; i < ATTRS_LEN; ++i)
686 tmp = desc->attributes[i].name.in ();
688 if (tmp == 0 || ACE_OS::strcmp (tmp, ATTR_LOCAL_NAMES[i]) != 0)
690 if (this->debug_)
692 ACE_DEBUG ((LM_DEBUG,
693 "component_attribute_test: "
694 "wrong local name for attribute #%d\n",
695 i + 1));
698 return -1;
701 CORBA::TCKind kind =
702 desc->attributes[i].type->kind ();
704 if (kind != ATTR_TC_KINDS[i])
706 if (this->debug_)
708 ACE_DEBUG ((LM_DEBUG,
709 "component_attribute_test: "
710 "wrong TCKind for attribute #%d\n",
711 i + 1));
714 return -1;
717 if (desc->attributes[i].get_exceptions.length () != GET_EXCEP_LEN[i])
719 if (this->debug_)
721 ACE_DEBUG ((LM_DEBUG,
722 "component_attribute_test: "
723 "wrong number of get-exceptions"
724 " for attribute #%d\n",
725 i + 1));
728 return -1;
731 if (desc->attributes[i].put_exceptions.length () != PUT_EXCEP_LEN[i])
733 if (this->debug_)
735 ACE_DEBUG ((LM_DEBUG,
736 "component_attribute_test: "
737 "wrong number of put-exceptions"
738 " for attribute #%d\n",
739 i + 1));
742 return -1;
746 return 0;
750 IDL3_Client::component_inheritance_test (
751 CORBA::ComponentIR::ComponentDef_var &comp_def)
753 CORBA::ComponentIR::ComponentDef_var comp_base =
754 comp_def->base_component ();
756 if (CORBA::is_nil (comp_base.in ()))
758 if (this->debug_)
760 ACE_DEBUG ((LM_DEBUG,
761 "component_inheritance_test: "
762 "base component is null\n"));
765 return -1;
768 CORBA::String_var str = comp_base->id ();
770 if (str.in () == 0 || ACE_OS::strcmp (str.in (), COMP_BASE_ID) != 0)
772 if (this->debug_)
774 ACE_DEBUG ((LM_DEBUG,
775 "component_inheritance_test: "
776 "bad id on base component\n"));
779 return -1;
782 CORBA::InterfaceDefSeq_var supported =
783 comp_base->supported_interfaces ();
785 CORBA::ULong length = supported->length ();
787 if (length != COMP_SUPPORTED_LEN)
789 if (this->debug_)
791 ACE_DEBUG ((LM_DEBUG,
792 "component_inheritance_test: "
793 "wrong number of supported interfaces\n"));
796 return -1;
799 for (CORBA::ULong i = 0; i < length; ++i)
801 str = supported[i]->id ();
803 if (str.in () == 0
804 || ACE_OS::strcmp (str.in (), COMP_SUPPORTED_IDS[i]) != 0)
806 if (this->debug_)
808 ACE_DEBUG ((LM_DEBUG,
809 "component_inheritance_test: "
810 "bad id on supported interface #%d\n",
811 i + 1));
814 return -1;
818 return 0;
822 IDL3_Client::component_port_test (
823 CORBA::ComponentIR::ComponentDef_var &comp_def)
825 CORBA::Contained::Description_var desc =
826 comp_def->describe ();
828 const CORBA::ComponentIR::ComponentDescription *cd = 0;
830 if ((desc->value >>= cd) == 0)
832 if (this->debug_)
834 ACE_DEBUG ((LM_DEBUG,
835 "component_port_test: "
836 "Any extraction of component description failed\n"));
839 return -1;
842 int status = this->provides_test (cd->provided_interfaces);
844 if (status != 0)
846 return -1;
849 status = this->uses_test (cd->used_interfaces);
851 if (status != 0)
853 return -1;
856 status = this->event_port_test (cd->emits_events,
857 EMITS_LEN,
858 "emits",
859 EMITS_NAMES,
860 EMITS_IDS);
862 if (status != 0)
864 return -1;
867 status = this->event_port_test (cd->publishes_events,
868 PUBLISHES_LEN,
869 "publishes",
870 PUBLISHES_NAMES,
871 PUBLISHES_IDS);
873 if (status != 0)
875 return -1;
878 status = this->event_port_test (cd->consumes_events,
879 CONSUMES_LEN,
880 "consumes",
881 CONSUMES_NAMES,
882 CONSUMES_IDS);
884 if (status != 0)
886 return -1;
889 return 0;
893 IDL3_Client::provides_test (const CORBA::ComponentIR::ProvidesDescriptionSeq &pds)
895 if (pds.length () != PROVIDES_LEN)
897 if (this->debug_)
899 ACE_DEBUG ((LM_DEBUG,
900 "provides_test: "
901 "wrong number of provides interfaces\n"));
904 return -1;
907 const char *tmp = 0;
909 for (CORBA::ULong i = 0; i < PROVIDES_LEN; ++i)
911 tmp = pds[i].name.in ();
913 if (tmp == 0 || ACE_OS::strcmp (tmp, PROVIDES_NAMES[i]) != 0)
915 if (this->debug_)
917 ACE_DEBUG ((LM_DEBUG,
918 "provides_test: "
919 "wrong local name for provides #%d\n",
920 i + 1));
923 return -1;
926 tmp = pds[i].interface_type.in ();
928 if (tmp == 0 || ACE_OS::strcmp (tmp, PROVIDES_TYPE_IDS[i]) != 0)
930 if (this->debug_)
932 ACE_DEBUG ((LM_DEBUG,
933 "provides_test: "
934 "wrong base interface type id for provides #%d\n",
935 i + 1));
938 return -1;
942 return 0;
946 IDL3_Client::uses_test (const CORBA::ComponentIR::UsesDescriptionSeq &uds)
948 if (uds.length () != USES_LEN)
950 if (this->debug_)
952 ACE_DEBUG ((LM_DEBUG,
953 "uses_test: "
954 "wrong number of uses interfaces\n"));
957 return -1;
960 const char *tmp = 0;
961 CORBA::Boolean mult = 0;
963 for (CORBA::ULong i = 0; i < USES_LEN; ++i)
965 tmp = uds[i].name.in ();
967 if (tmp == 0 || ACE_OS::strcmp (tmp, USES_NAMES[i]) != 0)
969 if (this->debug_)
971 ACE_DEBUG ((LM_DEBUG,
972 "uses_test: "
973 "wrong local name for uses #%d\n",
974 i + 1));
977 return -1;
980 tmp = uds[i].interface_type.in ();
982 if (tmp == 0 || ACE_OS::strcmp (tmp, USES_TYPE_IDS[i]) != 0)
984 if (this->debug_)
986 ACE_DEBUG ((LM_DEBUG,
987 "uses_test: "
988 "wrong base interface type id for uses #%d\n",
989 i + 1));
992 return -1;
995 mult = uds[i].is_multiple;
997 if (mult != USES_MULTIPLE_FLAGS[i])
999 if (this->debug_)
1001 ACE_DEBUG ((LM_DEBUG,
1002 "uses_test: "
1003 "wrong is_multiple value for uses #%d\n",
1004 i + 1));
1007 return -1;
1011 return 0;
1015 IDL3_Client::event_port_test (const CORBA::ComponentIR::EventPortDescriptionSeq &eds,
1016 CORBA::ULong seq_length,
1017 const char *port_type,
1018 const char **names,
1019 const char **ids)
1021 if (eds.length () != seq_length)
1023 if (this->debug_)
1025 ACE_DEBUG ((LM_DEBUG,
1026 "event_port_test: "
1027 "wrong number of event %C ports\n",
1028 port_type));
1031 return -1;
1034 const char *tmp = 0;
1036 for (CORBA::ULong i = 0; i < seq_length; ++i)
1038 tmp = eds[i].name.in ();
1040 if (tmp == 0 || ACE_OS::strcmp (tmp, names[i]) != 0)
1042 if (this->debug_)
1044 ACE_DEBUG ((LM_DEBUG,
1045 "event_port_test: "
1046 "wrong local name for %C port #%d\n",
1047 port_type,
1048 i + 1));
1051 return -1;
1054 tmp = eds[i].event.in ();
1056 if (tmp == 0 || ACE_OS::strcmp (tmp, ids[i]) != 0)
1058 if (this->debug_)
1060 ACE_DEBUG ((LM_DEBUG,
1061 "event_port_test: "
1062 "wrong base event type id for %C port #%d\n",
1063 port_type,
1064 i + 1));
1067 return -1;
1071 return 0;
1075 IDL3_Client::valuetype_inheritance_test (CORBA::ExtValueDef_var &vd,
1076 const char *prefix)
1078 CORBA::ValueDef_var bvd = vd->base_value ();
1080 if (CORBA::is_nil (bvd.in ()))
1082 if (this->debug_)
1084 ACE_DEBUG ((LM_DEBUG,
1085 "%Ctype_inheritance_test: "
1086 "base valuetype is null\n",
1087 prefix));
1090 return -1;
1093 CORBA::String_var str = bvd->id ();
1095 if (str.in () == 0 || ACE_OS::strcmp (str.in (), VT_BASE_ID) != 0)
1097 if (this->debug_)
1099 ACE_DEBUG ((LM_DEBUG,
1100 "%Ctype_inheritance_test: "
1101 "wrong repo id for base valuetype\n",
1102 prefix));
1105 return -1;
1108 CORBA::InterfaceDefSeq_var supported =
1109 vd->supported_interfaces ();
1111 CORBA::ULong length = supported->length ();
1113 if (length != VT_SUPPORTED_LEN)
1115 if (this->debug_)
1117 ACE_DEBUG ((LM_DEBUG,
1118 "%Ctype_inheritance_test: "
1119 "wrong number of supported interfaces\n",
1120 prefix));
1123 return -1;
1126 for (CORBA::ULong i = 0; i < length; ++i)
1128 str = supported[i]->id ();
1130 if (str.in () == 0
1131 || ACE_OS::strcmp (str.in (), VT_SUPPORTED_IDS[i]) != 0)
1133 if (this->debug_)
1135 ACE_DEBUG ((LM_DEBUG,
1136 "%Ctype_inheritance_test: "
1137 "bad id on supported interface #%d\n",
1138 prefix,
1139 i + 1));
1142 return -1;
1146 return 0;
1150 IDL3_Client::valuetype_attribute_test (
1151 CORBA::ExtValueDef::ExtFullValueDescription_var &desc,
1152 const char *prefix)
1154 if (desc->attributes.length () != ATTRS_LEN)
1156 if (this->debug_)
1158 ACE_DEBUG ((LM_DEBUG,
1159 "%Ctype_attribute_test: wrong number of attrs\n",
1160 prefix));
1163 return -1;
1166 const char *tmp = 0;
1168 for (CORBA::ULong i = 0; i < ATTRS_LEN; ++i)
1170 tmp = desc->attributes[i].name.in ();
1172 if (tmp == 0 || ACE_OS::strcmp (tmp, ATTR_LOCAL_NAMES[i]) != 0)
1174 if (this->debug_)
1176 ACE_DEBUG ((LM_DEBUG,
1177 "%Ctype_attribute_test: "
1178 "wrong local name for attribute #%d\n",
1179 prefix,
1180 i + 1));
1183 return -1;
1186 CORBA::TCKind kind =
1187 desc->attributes[i].type->kind ();
1189 if (kind != ATTR_TC_KINDS[i])
1191 if (this->debug_)
1193 ACE_DEBUG ((LM_DEBUG,
1194 "%Ctype_attribute_test: "
1195 "wrong TCKind for attribute #%d\n",
1196 prefix,
1197 i + 1));
1200 return -1;
1203 if (desc->attributes[i].get_exceptions.length () != GET_EXCEP_LEN[i])
1205 if (this->debug_)
1207 ACE_DEBUG ((LM_DEBUG,
1208 "%Ctype_attribute_test: "
1209 "wrong number of get-exceptions"
1210 " for attribute #%d\n",
1211 prefix,
1212 i + 1));
1215 return -1;
1218 if (desc->attributes[i].put_exceptions.length () != PUT_EXCEP_LEN[i])
1220 if (this->debug_)
1222 ACE_DEBUG ((LM_DEBUG,
1223 "%Ctype_attribute_test: "
1224 "wrong number of put-exceptions"
1225 " for attribute #%d\n",
1226 prefix,
1227 i + 1));
1230 return -1;
1234 return 0;
1238 IDL3_Client::valuetype_operation_test (
1239 CORBA::ExtValueDef::ExtFullValueDescription_var &desc,
1240 const char *prefix
1243 CORBA::ULong ops_length = desc->operations.length ();
1245 if (ops_length != OPS_LEN)
1247 if (this->debug_)
1249 ACE_DEBUG ((LM_DEBUG,
1250 "%Ctype_operation_test: "
1251 "wrong number of operations\n",
1252 prefix));
1255 return -1;
1258 const char *tmp = 0;
1259 CORBA::ULong j = 0;
1260 CORBA::ULong length = 0;
1262 for (CORBA::ULong i = 0; i < ops_length; ++i)
1264 tmp = desc->operations[i].name.in ();
1266 if (tmp == 0 || ACE_OS::strcmp (tmp, OP_NAMES[i]) != 0)
1268 if (this->debug_)
1270 ACE_DEBUG ((LM_DEBUG,
1271 "%Ctype_operation_test: "
1272 "wrong name for operation #%d\n",
1273 prefix,
1274 i + 1));
1277 return -1;
1280 CORBA::TCKind ret_kind =
1281 desc->operations[i].result.in ()->kind ();
1283 if (ret_kind != OP_RET_KINDS[i])
1285 if (this->debug_)
1287 ACE_DEBUG ((LM_DEBUG,
1288 "%Ctype_operation_test: "
1289 "wrong return type\n",
1290 prefix));
1293 return -1;
1296 length = desc->operations[i].parameters.length ();
1298 if (length != PARAMS_LEN[i])
1300 if (this->debug_)
1302 ACE_DEBUG ((LM_DEBUG,
1303 "%Ctype_operation_test: "
1304 "wrong number of parameters in operation #%d\n",
1305 prefix,
1306 i + 1));
1309 return -1;
1312 for (j = 0; j < length; ++j)
1314 tmp = desc->operations[i].parameters[j].name.in ();
1316 if (tmp == 0 || ACE_OS::strcmp (tmp, PARAM_NAMES[j]) != 0)
1318 if (this->debug_)
1320 ACE_DEBUG ((LM_DEBUG,
1321 "%Ctype_operation_test: "
1322 "wrong name for operation #%d,"
1323 "parameter #%d\n",
1324 prefix,
1325 i + 1,
1326 j + 1));
1329 return -1;
1333 length = desc->operations[i].exceptions.length ();
1335 if (length != OP_EXCEP_LEN[i])
1337 if (this->debug_)
1339 ACE_DEBUG ((LM_DEBUG,
1340 "%Ctype_operation_test: "
1341 "wrong number of exceptions in operation #%d\n",
1342 prefix,
1343 i + 1));
1346 return -1;
1350 return 0;
1354 IDL3_Client::valuetype_member_test (
1355 CORBA::ExtValueDef::ExtFullValueDescription_var &desc,
1356 const char *prefix)
1358 CORBA::ULong length = desc->members.length ();
1360 if (length != MEM_LEN)
1362 if (this->debug_)
1364 ACE_DEBUG ((LM_DEBUG,
1365 "%Ctype_member_test: "
1366 "wrong number of members\n",
1367 prefix));
1370 return -1;
1373 const char *tmp = 0;
1375 for (CORBA::ULong i = 0; i < length; ++i)
1377 if (desc->members[i].access != MEM_VIS[i])
1379 if (this->debug_)
1381 ACE_DEBUG ((LM_DEBUG,
1382 "%Ctype_member_test: "
1383 "wrong access value in member #%d\n",
1384 prefix,
1385 i + 1));
1388 return -1;
1391 tmp = desc->members[i].name.in ();
1393 if (tmp == 0 || ACE_OS::strcmp (tmp, MEM_NAMES[i]) != 0)
1395 if (this->debug_)
1397 ACE_DEBUG ((LM_DEBUG,
1398 "%Ctype_member_test: "
1399 "wrong repo id for member #%d\n",
1400 prefix,
1401 i + 1));
1404 return -1;
1408 return 0;
1412 IDL3_Client::valuetype_factory_test (
1413 CORBA::ExtValueDef::ExtFullValueDescription_var &desc,
1414 const char *prefix)
1416 CORBA::ULong length = desc->initializers.length ();
1418 if (length != FACTORY_LEN)
1420 if (this->debug_)
1422 ACE_DEBUG ((LM_DEBUG,
1423 "%Ctype_factory_test: "
1424 "wrong number of factories\n",
1425 prefix));
1428 return -1;
1431 CORBA::ULong inside_len = 0;
1432 const char *tmp = 0;
1434 for (CORBA::ULong i = 0; i < FACTORY_LEN; ++i)
1436 inside_len = desc->initializers[i].members.length ();
1438 if (inside_len != VT_FACTORY_PARAM_LENS[i])
1440 if (this->debug_)
1442 ACE_DEBUG ((LM_DEBUG,
1443 "%Ctype_factory_test: "
1444 "wrong number of params in factory #%d\n",
1445 prefix,
1446 i + 1));
1449 return -1;
1452 CORBA::ULong j = 0;
1454 for (j = 0; j < VT_FACTORY_PARAM_LENS[i]; ++j)
1456 tmp = desc->initializers[i].members[j].name.in ();
1458 if (tmp == 0
1459 || ACE_OS::strcmp (tmp, VT_FACTORY_PARAM_NAMES[i][j]) != 0)
1461 if (this->debug_)
1463 ACE_DEBUG ((LM_DEBUG,
1464 "%Ctype_factory_test: "
1465 "wrong name for arg #%d in factory #%d\n",
1466 prefix,
1467 j + 1,
1468 i + 1));
1471 return -1;
1475 inside_len = desc->initializers[i].exceptions.length ();
1477 if (inside_len != VT_FACTORY_EXCEP_LENS[i])
1479 if (this->debug_)
1481 ACE_DEBUG ((LM_DEBUG,
1482 "%Ctype_factory_test: "
1483 "wrong number of exceptions in factory #%d\n",
1484 prefix,
1485 i + 1));
1488 return -1;
1491 for (j = 0; j < VT_FACTORY_EXCEP_LENS[i]; ++j)
1493 tmp = desc->initializers[i].exceptions[j].name.in ();
1495 if (tmp == 0
1496 || ACE_OS::strcmp (tmp, VT_FACTORY_EXCEP_NAMES[i][j]) != 0)
1498 if (this->debug_)
1500 ACE_DEBUG ((LM_DEBUG,
1501 "%Ctype_factory_test: "
1502 "wrong name for exception #%d in factory #%d\n",
1503 prefix,
1504 j + 1,
1505 i + 1));
1508 return -1;
1513 return 0;
1517 IDL3_Client::home_inheritance_test (CORBA::ComponentIR::HomeDef_var &hd)
1519 CORBA::ComponentIR::HomeDef_var bhd =
1520 hd->base_home ();
1522 if (CORBA::is_nil (bhd.in ()))
1524 if (this->debug_)
1526 ACE_DEBUG ((LM_DEBUG,
1527 "home_inheritance_test: "
1528 "base home is null\n"));
1531 return -1;
1534 CORBA::String_var str = bhd->id ();
1536 if (str.in () == 0 || ACE_OS::strcmp (str.in (), HOME_BASE_ID) != 0)
1538 if (this->debug_)
1540 ACE_DEBUG ((LM_DEBUG,
1541 "home_inheritance_test: "
1542 "wrong repo id for base home\n"));
1545 return -1;
1548 CORBA::InterfaceDefSeq_var supported =
1549 bhd->supported_interfaces ();
1551 CORBA::ULong length = supported->length ();
1553 if (length != HOME_SUPPORTED_LEN)
1555 if (this->debug_)
1557 ACE_DEBUG ((LM_DEBUG,
1558 "home_inheritance_test: "
1559 "wrong number of supported interfaces\n"));
1562 return -1;
1565 for (CORBA::ULong i = 0; i < length; ++i)
1567 str = supported[i]->id ();
1569 if (str.in () == 0
1570 || ACE_OS::strcmp (str.in (), HOME_SUPPORTED_IDS[i]) != 0)
1572 if (this->debug_)
1574 ACE_DEBUG ((LM_DEBUG,
1575 "home_inheritance_test: "
1576 "bad id on supported interface #%d\n",
1577 i + 1));
1580 return -1;
1584 return 0;
1588 IDL3_Client::home_factory_test (const CORBA::ComponentIR::HomeDescription *hd)
1590 CORBA::ULong length = hd->factories.length ();
1592 if (length != HOME_FACTORY_LEN)
1594 if (this->debug_)
1596 ACE_DEBUG ((LM_DEBUG,
1597 "home_factory_test: "
1598 "wrong number of factories\n"));
1601 return -1;
1604 CORBA::ULong inside_len = 0;
1605 CORBA::ULong j = 0;
1606 const char *tmp = 0;
1608 for (CORBA::ULong i = 0; i < HOME_FACTORY_LEN; ++i)
1610 inside_len = hd->factories[i].parameters.length ();
1612 if (inside_len != HOME_FACTORY_PARAM_LENS[i])
1614 if (this->debug_)
1616 ACE_DEBUG ((LM_DEBUG,
1617 "home_factory_test: "
1618 "wrong number of params in factory #%d\n",
1619 i + 1));
1622 return -1;
1625 for (j = 0; j < inside_len; ++j)
1627 tmp = hd->factories[i].parameters[j].name.in ();
1629 if (tmp == 0
1630 || ACE_OS::strcmp (tmp, HOME_FACTORY_PARAM_NAMES[i][j]) != 0)
1632 if (this->debug_)
1634 ACE_DEBUG ((LM_DEBUG,
1635 "home_factory_test: "
1636 "wrong name for param #%d in factory #%d\n",
1637 j + 1,
1638 i + 1));
1641 return -1;
1645 inside_len = hd->factories[i].exceptions.length ();
1647 if (inside_len != HOME_FACTORY_EXCEP_LENS[i])
1649 if (this->debug_)
1651 ACE_DEBUG ((LM_DEBUG,
1652 "home_factory_test: "
1653 "wrong number of exceptions in factory #%d\n",
1654 i + 1));
1657 return -1;
1660 for (j = 0; j < inside_len; ++j)
1662 tmp = hd->factories[i].exceptions[j].name.in ();
1664 if (tmp == 0
1665 || ACE_OS::strcmp (tmp, HOME_FACTORY_EXCEP_NAMES[i][j]) != 0)
1667 if (this->debug_)
1669 ACE_DEBUG ((LM_DEBUG,
1670 "home_factory_test: "
1671 "wrong name for exception #%d in factory #%d\n",
1672 j + 1,
1673 i + 1));
1676 return -1;
1681 return 0;
1685 IDL3_Client::home_finder_test (const CORBA::ComponentIR::HomeDescription *hd)
1687 CORBA::ULong length = hd->finders.length ();
1689 if (length != HOME_FINDER_LEN)
1691 if (this->debug_)
1693 ACE_DEBUG ((LM_DEBUG,
1694 "home_finder_test: "
1695 "wrong number of finders\n"));
1698 return -1;
1701 CORBA::ULong inside_len = 0;
1702 CORBA::ULong j = 0;
1703 const char *tmp = 0;
1705 for (CORBA::ULong i = 0; i < HOME_FINDER_LEN; ++i)
1707 inside_len = hd->finders[i].parameters.length ();
1709 if (inside_len != HOME_FINDER_PARAM_LENS[i])
1711 if (this->debug_)
1713 ACE_DEBUG ((LM_DEBUG,
1714 "home_finder_test: "
1715 "wrong number of params in finder #%d\n",
1716 i + 1));
1719 return -1;
1722 for (j = 0; j < inside_len; ++j)
1724 tmp = hd->finders[i].parameters[j].name.in ();
1726 if (tmp == 0
1727 || ACE_OS::strcmp (tmp, HOME_FINDER_PARAM_NAMES[i][j]) != 0)
1729 if (this->debug_)
1731 ACE_DEBUG ((LM_DEBUG,
1732 "home_finder_test: "
1733 "wrong name for param #%d in finder #%d\n",
1734 j + 1,
1735 i + 1));
1738 return -1;
1742 inside_len = hd->finders[i].exceptions.length ();
1744 if (inside_len != HOME_FINDER_EXCEP_LENS[i])
1746 if (this->debug_)
1748 ACE_DEBUG ((LM_DEBUG,
1749 "home_finder_test: "
1750 "wrong number of exceptions in finder #%d\n",
1751 i + 1));
1754 return -1;
1757 for (j = 0; j < inside_len; ++j)
1759 tmp = hd->finders[i].exceptions[j].name.in ();
1761 if (tmp == 0
1762 || ACE_OS::strcmp (tmp, HOME_FINDER_EXCEP_NAMES[i][j]) != 0)
1764 if (this->debug_)
1766 ACE_DEBUG ((LM_DEBUG,
1767 "home_finder_test: "
1768 "wrong name for exception #%d in finder #%d\n",
1769 j + 1,
1770 i + 1));
1773 return -1;
1778 return 0;