(file) Return to test_NumberProvider.cpp CVS log (file) (dir) Up to [OMI] / omi / unittest / NumberProvider

   1 mike  1.1 /*
   2           **==============================================================================
   3           **
   4           ** Open Management Infrastructure (OMI)
   5           **
   6           ** Copyright (c) Microsoft Corporation
   7           ** 
   8           ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
   9           ** use this file except in compliance with the License. You may obtain a copy 
  10           ** of the License at 
  11           **
  12           **     http://www.apache.org/licenses/LICENSE-2.0 
  13           **
  14           ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15           ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
  16           ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
  17           ** MERCHANTABLITY OR NON-INFRINGEMENT. 
  18           **
  19           ** See the Apache 2 License for the specific language governing permissions 
  20           ** and limitations under the License.
  21           **
  22 mike  1.1 **==============================================================================
  23           */
  24           
  25           #include <vector>
  26           #include <set>
  27           #include <cstdlib>
  28           #include <iostream>
  29           #include <ut/ut.h>
  30           #include <unittest/utils.h>
  31           #include <protocol/protocol.h>
  32 mike  1.2 #include <sock/sock.h>
  33 mike  1.1 #include <base/base.h>
  34           #include <base/paths.h>
  35           #include <base/io.h>
  36           #include <omiclient/client.h>
  37           
  38           using namespace std;
  39           //using namespace mi;
  40           
  41           /* extern definitions - these functions are declared in test_wsman.cpp */
  42           void WSMAN_Tests_With_Server();
  43           
  44           static Protocol* s_protocol;
  45           static int trace = 0;
  46           static vector<MI_Result> s_results;
  47           static vector<PostInstanceMsg*> s_instances;
  48           static string  s_nsPrefix;
  49           
  50           static void setUp()
  51           {
  52               s_instances.reserve( 11000 );
  53           }
  54 mike  1.1 
  55           static void cleanup()
  56           {
  57               s_results.clear();
  58           
  59               for ( unsigned int i = 0; i < s_instances.size(); i++ )
  60                   PostInstanceMsg_Release(s_instances[i]);
  61               
  62               s_instances.clear();
  63           
  64               {
  65                   // clear buffers
  66                   vector<MI_Result> results;
  67                   vector<PostInstanceMsg*> instances;
  68           
  69                   s_results.swap(results);
  70                   s_instances.swap(instances);
  71               }
  72           }
  73           
  74           static MI_Uint64 _NextMsgID()
  75 mike  1.1 {
  76               static MI_Uint64 _msgID = 10000;
  77               return _msgID++;
  78           }
  79           
  80           BEGIN_EXTERNC
  81           static MI_Boolean _Callback(
  82               Protocol* protocol,
  83               Message* msg,
  84               void* data)
  85           {
  86               data=data;
  87               protocol = protocol;
  88           
  89               switch (msg->tag)
  90               {
  91                   case NoOpRspTag:
  92                   {
  93                       if (trace)
  94                       {
  95                           NoOpRsp* rsp = (NoOpRsp*)msg;
  96 mike  1.1                 NoOpRsp_Print(rsp , stdout);
  97                       }
  98                       break;
  99                   }
 100                   case PostInstanceMsgTag:
 101                   {
 102                       PostInstanceMsg* rsp = (PostInstanceMsg*)msg;
 103           
 104                       s_instances.push_back(rsp);
 105                       Message_AddRef(&rsp->base);
 106           
 107                       if (trace)
 108                       {
 109                           PostInstanceMsg_Print(rsp, stdout);
 110                       }
 111                       break;
 112                   }
 113                   case PostResultMsgTag:
 114                   {
 115                       {
 116                           PostResultMsg* rsp = (PostResultMsg*)msg;
 117 mike  1.1 
 118                           s_results.push_back( rsp->result );
 119                           if (trace)
 120                               PostResultMsg_Print(rsp, stdout);
 121                       }
 122                       break;
 123                   }
 124                   default:
 125                   {
 126                       printf("unsupported msg: tag=%u\n", msg->tag);
 127                       break;
 128                   }
 129               }
 130           
 131               return MI_TRUE;
 132           }
 133           END_EXTERNC
 134           
 135           static const MI_Char* MI_strchr(const MI_Char* s, unsigned int c)
 136           {
 137               while (s && *s)
 138 mike  1.1     {
 139                   if (c == (unsigned int)*s)
 140                       return s;
 141           
 142                   s++;
 143               }
 144               return 0;
 145           }
 146           
 147           /* parses part Key1=Value1[,Key2=value2...]*/
 148           static void _GetKeysFromCmd(
 149               MI_Instance* dynamicInstance,
 150               MI_Char* whole_line)
 151           {
 152               MI_String current_segment = whole_line;
 153           
 154               while (current_segment)
 155               {
 156                   MI_String next_segment = (MI_String)MI_strchr(current_segment, ',');
 157                   /* replace ',' with \0, remember next segment */
 158                   if (next_segment)
 159 mike  1.1         {
 160                       *next_segment = 0;
 161                       next_segment++;
 162                   }
 163           
 164                   {
 165                       MI_String pos = (MI_String)MI_strchr(current_segment, '=');
 166                       MI_String name = current_segment;
 167                       MI_Value value;
 168                       MI_Result r;
 169           
 170                       // Split key and value.
 171                       UT_ASSERT(pos);
 172           
 173                       *pos = 0;
 174                       pos++;
 175                       value.string = pos;
 176           
 177                       // Set the property.
 178                       r = MI_Instance_AddElement(dynamicInstance, name, &value, 
 179                           MI_STRING, MI_FLAG_KEY|MI_FLAG_BORROW);
 180 mike  1.1 
 181                       UT_ASSERT(r == MI_RESULT_OK);
 182                   }
 183           
 184                   current_segment = next_segment;
 185               }
 186           }
 187           
 188           /* converts string CLASSNAME.KEY1=VALUE1[,Key2=Value2...] to dynamic instance;
 189               returns CLASSNAME only if ".KEY.." part is missing */
 190           static MI_Instance* _ReferenceStringToInstance(
 191               Batch* batch,
 192               const char* cmdArg,
 193               MI_ConstString* cnOut)
 194           {
 195               MI_String cn, keys;
 196               MI_Result r;
 197               MI_Instance* dynamicInstance;
 198           
 199               /* extract class-name */
 200               cn = Batch_Strdup2(batch, cmdArg);
 201 mike  1.1     keys = (MI_String)MI_strchr(cn, '.');
 202           
 203               if ( !keys )
 204               {
 205                   /* cn - only - return */
 206                   if (cnOut)
 207                       *cnOut = cn;
 208           
 209                   return 0;
 210               }
 211           
 212               *keys = 0;
 213               keys++;
 214           
 215               if (cnOut)
 216                   *cnOut = cn;
 217           
 218               r = Instance_NewDynamic(&dynamicInstance, cn, MI_FLAG_CLASS, batch);
 219           
 220               UT_ASSERT(MI_RESULT_OK == r);
 221           
 222 mike  1.1     // Set keys from key-value pairs.
 223               _GetKeysFromCmd(dynamicInstance,keys);
 224               return  dynamicInstance;
 225           }
 226           
 227           
 228           static void _CallGetInstance( const char* ns_, const char* ref )
 229           {
 230               GetInstanceReq* msg;
 231               MI_Result r;
 232               MI_Instance* dynamicInstance;
 233               Batch batch = BATCH_INITIALIZER;
 234               string ns = s_nsPrefix + ns_;
 235           
 236               msg = GetInstanceReq_New(_NextMsgID(), BinaryProtocolFlag);
 237           
 238               msg->nameSpace = Batch_Strdup2(msg->base.batch, ns.c_str());
 239           
 240               /* create dynamic instance */
 241               dynamicInstance = _ReferenceStringToInstance(&batch, ref, 0);
 242           
 243 mike  1.1     UT_ASSERT(dynamicInstance);
 244           
 245               if (trace)
 246                   MI_Instance_Print(dynamicInstance, stdout, 0);
 247           
 248               /* pack instance */
 249               r = InstanceToBatch(dynamicInstance, NULL, NULL, msg->base.batch, 
 250                       &msg->packedInstanceNamePtr, &msg->packedInstanceNameSize);
 251           
 252               UT_ASSERT(MI_RESULT_OK == r);
 253           
 254               r = Protocol_Send(s_protocol, &msg->base);
 255           
 256               UT_ASSERT(MI_RESULT_OK == r);
 257           
 258               GetInstanceReq_Release(msg);
 259               Batch_Destroy(&batch);
 260           
 261               // process send/recv loop
 262               // run loop with 1 ms increment until result received or 5 sec elapsed
 263           
 264 mike  1.1     for ( int i = 0; i < 15000 && s_results.empty(); i++ )
 265                   Protocol_Run(s_protocol, 1000);
 266           }
 267           
 268           static void _CallEnumerate( const char* ns_, const char* cn, MI_Boolean deep )
 269           {
 270               EnumerateInstancesReq* msg;
 271               MI_Result r;
 272               string ns = s_nsPrefix + ns_;
 273           
 274               // Create new request.
 275               msg = EnumerateInstancesReq_New(_NextMsgID(), BinaryProtocolFlag);
 276           
 277               msg->nameSpace = Batch_Strdup2(msg->base.batch, ns.c_str());
 278               msg->className = Batch_Strdup2(msg->base.batch, cn);
 279               msg->deepInheritance = deep;
 280           
 281               r = Protocol_Send(s_protocol, &msg->base);
 282           
 283               UT_ASSERT(MI_RESULT_OK == r);
 284           
 285 mike  1.1     EnumerateInstancesReq_Release(msg);
 286           
 287               // process send/recv loop
 288               // run loop with 1 ms increment until result received or 5 sec elapsed
 289               for ( int i = 0; i < 9000 && s_results.empty(); i++ )
 290                   Protocol_Run(s_protocol, 1000);
 291           }
 292           
 293           static void _CallInvoke( const char* ns_, const char* ref, const char* fn, const char* char_params, MI_Instance* outParam = 0 )
 294           {
 295               InvokeReq* msg;
 296               MI_Result r;
 297               MI_Instance* dynamicInstance = 0;
 298               MI_Instance* dynamicInstanceParams = 0;
 299               Batch   dynamicBatch = BATCH_INITIALIZER;
 300               MI_ConstString cn;
 301               MI_String params_cn, params;
 302               string ns = s_nsPrefix + ns_;
 303           
 304               // Create new request.
 305               msg = InvokeReq_New(_NextMsgID(), BinaryProtocolFlag);
 306 mike  1.1 
 307               // Extract arguments.
 308               msg->nameSpace = Batch_Strdup2(msg->base.batch, ns.c_str());
 309           
 310               /* create dynamic instance */
 311               {
 312                   dynamicInstance = _ReferenceStringToInstance( &dynamicBatch, ref, &cn );
 313           
 314                   msg->className = Batch_Zdup(msg->base.batch, cn);
 315           
 316                   if (trace && dynamicInstance)
 317                       MI_Instance_Print(dynamicInstance, stdout, 0);
 318           
 319                   /* pack instance */
 320                   if (dynamicInstance)
 321                   {
 322                       r = InstanceToBatch(dynamicInstance, NULL, NULL, msg->base.batch, 
 323                               &msg->packedInstancePtr, &msg->packedInstanceSize);
 324           
 325                       UT_ASSERT(MI_RESULT_OK == r);
 326                   }
 327 mike  1.1     }
 328           
 329               msg->function = Batch_Strdup2(msg->base.batch, fn);
 330           
 331               /* params */
 332               if (char_params)
 333               {
 334                   /* parameters instance classname is ignored, but has to have valid syntax */
 335                   params_cn = Batch_Strdup2(&dynamicBatch, "param");
 336           
 337                   r = Instance_NewDynamic(
 338                       &dynamicInstanceParams,
 339                       params_cn,
 340                       MI_FLAG_CLASS,
 341                       &dynamicBatch);
 342           
 343                   UT_ASSERT (MI_RESULT_OK == r);
 344           
 345                   // Set keys from key-value pairs.
 346                   params = Batch_Strdup2(&dynamicBatch, char_params);
 347                   _GetKeysFromCmd(dynamicInstanceParams,params);
 348 mike  1.1 
 349                   if (trace)
 350                       MI_Instance_Print(dynamicInstanceParams, stdout, 0);
 351           
 352                   /* pack instance */
 353                   r = InstanceToBatch(dynamicInstanceParams, NULL, NULL, msg->base.batch, 
 354                           &msg->packedInstanceParamsPtr, &msg->packedInstanceParamsSize);
 355                   UT_ASSERT (MI_RESULT_OK == r);
 356               }
 357               else if (outParam)
 358               {
 359                   /* pack instance */
 360                   r = InstanceToBatch(outParam, NULL, NULL, msg->base.batch, 
 361                           &msg->packedInstanceParamsPtr, &msg->packedInstanceParamsSize);
 362                   UT_ASSERT (MI_RESULT_OK == r);
 363               }
 364           
 365               r = Protocol_Send(s_protocol, &msg->base);
 366               UT_ASSERT (MI_RESULT_OK == r);
 367           
 368               InvokeReq_Release(msg);
 369 mike  1.1     Batch_Destroy(&dynamicBatch);
 370           
 371               // process send/recv loop
 372               // run loop with 1 ms increment until result received or 5 sec elapsed
 373               for ( int i = 0; i < 15000 && s_results.empty(); i++ )
 374                   Protocol_Run(s_protocol, 1000);
 375           }
 376           
 377           static void _CallAssociators( const char* ns_, const char* ref, const char* ac, const char* rc, const char* role, const char* rrole )
 378           {
 379               AssociatorsOfReq* msg;
 380               MI_Result r;
 381               MI_Instance* dynamicInstance = 0;
 382               Batch   dynamicBatch = BATCH_INITIALIZER;
 383               string ns = s_nsPrefix + ns_;
 384           
 385               // Create new request.
 386               msg = AssociatorsOfReq_New(_NextMsgID(), BinaryProtocolFlag);
 387           
 388               // Extract arguments.
 389               msg->nameSpace = Batch_Strdup2(msg->base.batch, ns.c_str());
 390 mike  1.1 
 391               /* create dynamic instance */
 392               /* create dynamic instance */
 393               dynamicInstance = _ReferenceStringToInstance( &dynamicBatch, ref, 0 );
 394           
 395               UT_ASSERT(dynamicInstance);
 396           
 397               if (trace)
 398                   MI_Instance_Print(dynamicInstance, stdout, 0);
 399           
 400               /* pack instance */
 401               r = InstanceToBatch(dynamicInstance, NULL, NULL, msg->base.batch, 
 402                       &msg->packedInstancePtr, &msg->packedInstanceSize);
 403           
 404               UT_ASSERT(MI_RESULT_OK == r);
 405           
 406               // optional params
 407               if (ac)
 408                   msg->assocClass = Batch_Strdup2(msg->base.batch, ac);
 409           
 410               if (rc)
 411 mike  1.1         msg->resultClass = Batch_Strdup2(msg->base.batch, rc);
 412           
 413               if (role)
 414                   msg->role = Batch_Strdup2(msg->base.batch, role);
 415           
 416               if (rrole)
 417                   msg->resultRole = Batch_Strdup2(msg->base.batch, rrole);
 418           
 419               r = Protocol_Send(s_protocol, &msg->base);
 420           
 421               UT_ASSERT(MI_RESULT_OK == r);
 422           
 423               AssociatorsOfReq_Release(msg);
 424               Batch_Destroy(&dynamicBatch);
 425           
 426           
 427               // process send/recv loop
 428               // run loop with 1 ms increment until result received or 5 sec elapsed
 429               for ( int i = 0; i < 15000 && s_results.empty(); i++ )
 430                   Protocol_Run(s_protocol, 1000);
 431           }
 432 mike  1.1 
 433           static void _CallReferences( const char* ns_, const char* ref, const char* ac, const char* role )
 434           {
 435               ReferencesOfReq* msg;
 436               MI_Result r;
 437               MI_Instance* dynamicInstance = 0;
 438               Batch   dynamicBatch = BATCH_INITIALIZER;
 439               string ns = s_nsPrefix + ns_;
 440           
 441               // Create new request.
 442               msg = ReferencesOfReq_New(_NextMsgID(), BinaryProtocolFlag);
 443           
 444               // Extract arguments.
 445               msg->nameSpace = Batch_Strdup2(msg->base.batch, ns.c_str());
 446           
 447               /* create dynamic instance */
 448               /* create dynamic instance */
 449               dynamicInstance = _ReferenceStringToInstance( &dynamicBatch, ref, 0 );
 450           
 451               UT_ASSERT(dynamicInstance);
 452           
 453 mike  1.1     if (trace)
 454                   MI_Instance_Print(dynamicInstance, stdout, 0);
 455           
 456               /* pack instance */
 457               r = InstanceToBatch(dynamicInstance, NULL, NULL, msg->base.batch, 
 458                       &msg->packedInstancePtr, &msg->packedInstanceSize);
 459           
 460               UT_ASSERT(MI_RESULT_OK == r);
 461           
 462               // optional params
 463               if (ac)
 464                   msg->assocClass = Batch_Strdup2(msg->base.batch, ac);
 465           
 466               if (role)
 467                   msg->role = Batch_Strdup2(msg->base.batch, role);
 468           
 469               r = Protocol_Send(s_protocol, &msg->base);
 470           
 471               UT_ASSERT(MI_RESULT_OK == r);
 472           
 473               ReferencesOfReq_Release(msg);
 474 mike  1.1     Batch_Destroy(&dynamicBatch);
 475           
 476           
 477               // process send/recv loop
 478               // run loop with 1 ms increment until result received or 5 sec elapsed
 479               for ( int i = 0; i < 15000 && s_results.empty(); i++ )
 480                   Protocol_Run(s_protocol, 1000);
 481           }
 482           
 483           static void TestGetInstanceSmallNumber()
 484           {
 485               // omicli gi test/cpp X_SmallNumber.Number=1093
 486               //instance of X_SmallNumber
 487               //{
 488               //    Number=1093
 489               //    SpelledNumber=one thousand ninety three
 490               //}
 491               _CallGetInstance("test/cpp", "X_SmallNumber.Number=1093");
 492           
 493               // validate response
 494               UT_ASSERT_EQUAL(s_results.size(), 1);
 495 mike  1.1     UT_ASSERT(s_results[0] == MI_RESULT_OK);
 496           
 497               UT_ASSERT(s_instances.size() == 1);
 498           
 499               MI_Value value;
 500               MI_Type type;
 501               MI_Uint32 flags = 0;
 502           
 503               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Number"), &value, &type, &flags, 0));
 504               UT_ASSERT(type == MI_UINT64);
 505               UT_ASSERT(value.uint64 == 1093);
 506               UT_ASSERT(!(flags & MI_FLAG_NULL));
 507           
 508               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("SpelledNumber"), &value, &type, &flags, 0));
 509               UT_ASSERT(type == MI_STRING);
 510               UT_ASSERT(value.string == ut::String(T("one thousand ninety three")));
 511               UT_ASSERT(!(flags & MI_FLAG_NULL));
 512           }
 513           
 514           static void TestGetInstanceHugeNumberWithEmbeddedInstance()
 515           {
 516 mike  1.1     //omicli gi test/cpp X_HugeNumber.Number=1000000
 517               //instance of test/cpp/X_HugeNumber
 518               //{
 519               //    Description=NULL
 520               //    Number=1000000
 521               //    Magnitude=6
 522               //    MagnitudeObj=instance of test/cpp/X_SmallNumber
 523               //    {
 524               //        Description=NULL
 525               //        Number=6
 526               //        SpelledNumber=six
 527               //    }
 528               //    Numbers123=[3]{
 529               //        instance of test/cpp/X_SmallNumber
 530               //        {
 531               //            Description=NULL
 532               //            Number=1
 533               //            SpelledNumber=one
 534               //        },
 535               //        instance of test/cpp/X_SmallNumber
 536               //        {
 537 mike  1.1     //            Description=NULL
 538               //            Number=2
 539               //            SpelledNumber=two
 540               //        },
 541               //        instance of test/cpp/X_SmallNumber
 542               //        {
 543               //            Description=NULL
 544               //            Number=3
 545               //            SpelledNumber=three
 546               //        }
 547               //    }
 548               //    Number0=instance of X_Halves
 549               //    {
 550               //        number= REF instance of test/cpp/X_SmallNumber
 551               //        {
 552               //            Description=NULL
 553               //            Number=0
 554               //            SpelledNumber=zero
 555               //        }
 556               //        half= REF instance of test/cpp/X_SmallNumber
 557               //        {
 558 mike  1.1     //            Description=NULL
 559               //            Number=0
 560               //            SpelledNumber=zero
 561               //        }
 562               //    }
 563               //    TwoTestObjects=[2]{
 564               //        instance of X_TestObject
 565               //        {
 566               //            id=17
 567               //            str=a string
 568               //        },
 569               //        instance of interop/X_Profile
 570               //        {
 571               //            InstanceID=a profile
 572               //            RegisteredName=embedded object
 573               //        }
 574               //    }
 575               //    TestObject=NULL
 576               //}
 577           
 578               _CallGetInstance("test/cpp", "X_HugeNumber.Number=1000000");
 579 mike  1.1 
 580               // validate response
 581               UT_ASSERT(s_results.size() == 1);
 582               UT_ASSERT(s_results[0] == MI_RESULT_OK);
 583           
 584               UT_ASSERT(s_instances.size() == 1);
 585           
 586               MI_Value value, value_instance;
 587               MI_Type type;
 588               MI_Uint32 flags = 0;
 589           
 590               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Number"), &value, &type, &flags, 0));
 591               UT_ASSERT(type == MI_UINT64);
 592               UT_ASSERT(value.uint64 == 1000000);
 593               UT_ASSERT(!(flags & MI_FLAG_NULL));
 594           
 595               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Magnitude"), &value, &type, &flags, 0));
 596               UT_ASSERT(type == MI_UINT32);
 597               UT_ASSERT(value.uint32 == 6);
 598               UT_ASSERT(!(flags & MI_FLAG_NULL));
 599           
 600 mike  1.1     {   // embedded-instance: MagnitudeObj
 601                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MagnitudeObj"), &value_instance, &type, &flags, 0));
 602                   UT_ASSERT(type == MI_INSTANCE);
 603                   UT_ASSERT(value_instance.instance != NULL);
 604                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 605           
 606                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("Number"), &value, &type, &flags, 0));
 607                   UT_ASSERT(type == MI_UINT64);
 608                   UT_ASSERT(value.uint64 == 6);
 609                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 610           
 611                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("SpelledNumber"), &value, &type, &flags, 0));
 612                   UT_ASSERT(type == MI_STRING);
 613                   UT_ASSERT(value.string == ut::String(T("six")));
 614                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 615               }
 616           
 617               {   // embedded-instance[]: Numbers123
 618                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Numbers123"), &value_instance, &type, &flags, 0));
 619                   UT_ASSERT(type == MI_INSTANCEA);
 620                   UT_ASSERT(value_instance.instancea.size == 3);
 621 mike  1.1         UT_ASSERT(!(flags & MI_FLAG_NULL));
 622           
 623                   for ( int num = 0; num < 3; num++ )
 624                   {
 625                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[num], T("Number"), &value, &type, &flags, 0));
 626                       UT_ASSERT(type == MI_UINT64);
 627                       UT_ASSERT(value.uint64 == (MI_Uint64)(1 + num));
 628                       UT_ASSERT(!(flags & MI_FLAG_NULL));
 629                   }
 630           
 631                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[0], T("SpelledNumber"), &value, &type, &flags, 0));
 632                   UT_ASSERT(type == MI_STRING);
 633                   UT_ASSERT(value.string == ut::String(T("one")));
 634                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 635               }
 636           
 637               {   // embedded-object Numbers0 - expecting X_Halves there
 638                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Number0"), &value_instance, &type, &flags, 0));
 639                   UT_ASSERT(type == MI_INSTANCE);
 640                   UT_ASSERT(value_instance.instance != NULL);
 641                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 642 mike  1.1 
 643                   MI_ConstString cn = 0;
 644                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value_instance.instance, &cn));
 645                   UT_ASSERT(cn == ut::String(T("X_Halves")));
 646                   
 647           
 648                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("number"), &value, &type, &flags, 0));
 649                   UT_ASSERT(type == MI_REFERENCE);
 650                   UT_ASSERT(value.instance != NULL);
 651                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 652           
 653                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("half"), &value, &type, &flags, 0));
 654                   UT_ASSERT(type == MI_REFERENCE);
 655                   UT_ASSERT(value.instance != NULL);
 656                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 657               }
 658           
 659               {   // embedded-objects[]: TwoTestObjects
 660                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("TwoTestObjects"), &value_instance, &type, &flags, 0));
 661                   UT_ASSERT(type == MI_INSTANCEA);
 662                   UT_ASSERT(value_instance.instancea.size == 2);
 663 mike  1.1         UT_ASSERT(!(flags & MI_FLAG_NULL));
 664           
 665                   for ( int num = 0; num < 2; num++ )
 666                   {
 667                       MI_ConstString cn = 0;
 668                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value_instance.instancea.data[num], &cn));
 669           
 670                       if (cn == ut::String(T("X_TestObject")))
 671                       {
 672                           UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[num], T("id"), &value, &type, &flags, 0));
 673                           UT_ASSERT(type == MI_UINT64);
 674                           UT_ASSERT(value.uint64 == 17);
 675                           UT_ASSERT(!(flags & MI_FLAG_NULL));
 676                       }
 677                       else if (cn == ut::String(T("X_Profile")))
 678                       {
 679                           UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[num], T("Registeredname"), &value, &type, &flags, 0));
 680                           UT_ASSERT(type == MI_STRING);
 681                           UT_ASSERT(value.string == ut::String(T("embedded object")));
 682                           UT_ASSERT(!(flags & MI_FLAG_NULL));
 683                       }
 684 mike  1.1             else
 685                       {
 686                           UT_ASSERT_FAILED_MSG( (string("unexcpected class name ") + ut::StrToChar(cn)).c_str() );
 687                       }
 688                   }
 689               }
 690           
 691           }
 692           
 693           static void _TestGetInstancePersonWithEmbeddedInstance(const char* ns)
 694           {
 695               //omicli gi test/cpp TestEmbeddedOperations.Key=1
 696               //instance of TestEmbeddedOperations
 697               //{
 698               //    key=1
 699               //    person=instance of MSFT_Person
 700               //    {
 701               //        Key=7
 702               //        Species=NULL
 703               //        Last=Smith
 704               //        First=John
 705 mike  1.1     //        ExpensiveProperty=NULL
 706               //    }
 707               //    threePersons=[3]{
 708               //        instance of MSFT_Person
 709               //        {
 710               //            Key=7
 711               //            Species=NULL
 712               //            Last=Black
 713               //            First=John
 714               //            ExpensiveProperty=NULL
 715               //        },
 716               //        instance of MSFT_Person
 717               //        {
 718               //            Key=8
 719               //            Species=NULL
 720               //            Last=White
 721               //            First=Bill
 722               //            ExpensiveProperty=NULL
 723               //        },
 724               //        instance of MSFT_Person
 725               //        {
 726 mike  1.1     //            Key=8
 727               //            Species=NULL
 728               //            Last=Brown
 729               //            First=Ben
 730               //            ExpensiveProperty=NULL
 731               //        }
 732               //    }
 733               //}
 734           
 735               _CallGetInstance(ns, "TestEmbeddedOperations.Key=1");
 736           
 737               // validate response
 738               UT_ASSERT(s_results.size() == 1);
 739               UT_ASSERT(s_results[0] == MI_RESULT_OK);
 740           
 741               UT_ASSERT(s_instances.size() == 1);
 742           
 743               MI_Value value, value_instance;
 744               MI_Type type;
 745               MI_Uint32 flags = 0;
 746           
 747 mike  1.1     UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("key"), &value, &type, &flags, 0));
 748               UT_ASSERT(type == MI_UINT32);
 749               UT_ASSERT(value.uint32 == 1);
 750               UT_ASSERT(!(flags & MI_FLAG_NULL));
 751           
 752               {   // embedded-instance: person
 753                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("person"), &value_instance, &type, &flags, 0));
 754                   UT_ASSERT(type == MI_INSTANCE);
 755                   UT_ASSERT(value_instance.instance != NULL);
 756                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 757           
 758                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("Last"), &value, &type, &flags, 0));
 759                   UT_ASSERT(type == MI_STRING);
 760                   UT_ASSERT(value.string == ut::String(T("Smith")));
 761                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 762           
 763                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("First"), &value, &type, &flags, 0));
 764                   UT_ASSERT(type == MI_STRING);
 765                   UT_ASSERT(value.string == ut::String(T("John")));
 766                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 767               }
 768 mike  1.1 
 769               {   // embedded-instance[]: threePersons
 770                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("threePersons"), &value_instance, &type, &flags, 0));
 771                   UT_ASSERT(type == MI_INSTANCEA);
 772                   UT_ASSERT(value_instance.instancea.size == 3);
 773                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 774           
 775                   for ( int num = 0; num < 3; num++ )
 776                   {
 777                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[num], T("key"), &value, &type, &flags, 0));
 778                       UT_ASSERT(type == MI_UINT32);
 779                       UT_ASSERT(value.uint32 == (MI_Uint64)(7 + num));
 780                       UT_ASSERT(!(flags & MI_FLAG_NULL));
 781                   }
 782           
 783                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[0], T("First"), &value, &type, &flags, 0));
 784                   UT_ASSERT(type == MI_STRING);
 785                   UT_ASSERT(value.string == ut::String(T("John")));
 786                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 787                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[1], T("First"), &value, &type, &flags, 0));
 788                   UT_ASSERT(type == MI_STRING);
 789 mike  1.1         UT_ASSERT(value.string == ut::String(T("Bill")));
 790                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 791                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[2], T("First"), &value, &type, &flags, 0));
 792                   UT_ASSERT(type == MI_STRING);
 793                   UT_ASSERT(value.string == ut::String(T("Ben")));
 794                   UT_ASSERT(!(flags & MI_FLAG_NULL));
 795               }
 796           }
 797           
 798           static void TestGetInstancePersonWithEmbeddedInstance_c()
 799           {
 800           	_TestGetInstancePersonWithEmbeddedInstance("test/c");
 801           }
 802           
 803           static void TestGetInstancePersonWithEmbeddedInstance_cpp()
 804           {
 805           	_TestGetInstancePersonWithEmbeddedInstance("test/cpp");
 806           }
 807           
 808           static void TestGetInstanceSmallNumberNotFound()
 809           {
 810 mike  1.1     //omicli gi test/cpp X_SmallNumber.Number=10001
 811               //PostResultMsg
 812               //{
 813               //    tag=4
 814               //    msgID=10000
 815               //    clientID=12128856
 816               //    result=7 [NOT_FOUND]
 817               //    request=NULL
 818               //}
 819               _CallGetInstance("test/cpp", "X_SmallNumber.Number=10001");
 820           
 821               // validate response
 822               UT_ASSERT(s_results.size() == 1);
 823               UT_ASSERT(s_results[0] == MI_RESULT_NOT_FOUND);
 824           
 825               UT_ASSERT(s_instances.size() == 0);
 826           }
 827           
 828           static void TestGetInstanceInvalidNameSpace()
 829           {
 830               //omicli gi non/exisiting/namespace X_SmallNumber.Number=11
 831 mike  1.1     //PostResultMsg
 832               //{
 833               //    tag=4
 834               //    msgID=10000
 835               //    clientID=12128856
 836               //    result=7 [INVALID_NAMESPACE]
 837               //    request=NULL
 838               //}
 839               _CallGetInstance("non/exisiting/namespace", "X_SmallNumber.Number=11");
 840           
 841               // validate response
 842               UT_ASSERT(s_results.size() == 1);
 843               UT_ASSERT(s_results[0] == MI_RESULT_INVALID_NAMESPACE);
 844           
 845               UT_ASSERT(s_instances.size() == 0);
 846           }
 847           
 848           static void TestEnumerateHugeNumber()
 849           {
 850               //omicli ei test/cpp X_HugeNumber
 851               //instance of X_HugeNumber
 852 mike  1.1     //{
 853               //    Number=1000000
 854               //    Magnitude=6
 855               //}
 856               //instance of X_HugeNumber
 857               //{
 858               //    Number=1000000000
 859               //    Magnitude=9
 860               //}
 861           
 862               _CallEnumerate("test/cpp", "X_HugeNumber", MI_FALSE);
 863           
 864               // validate response
 865               UT_ASSERT(s_results.size() == 1);
 866               UT_ASSERT(s_results[0] == MI_RESULT_OK);
 867           
 868               UT_ASSERT(s_instances.size() == 2);
 869           
 870               MI_Value value;
 871               MI_Type type;
 872               MI_Uint32 flags = 0;
 873 mike  1.1 
 874               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Number"), &value, &type, &flags, 0));
 875               UT_ASSERT(type == MI_UINT64);
 876               UT_ASSERT(value.uint64 == 1000000 || value.uint64 == 1000000000);
 877               UT_ASSERT(!(flags & MI_FLAG_NULL));
 878           
 879               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Magnitude"), &value, &type, &flags, 0));
 880               UT_ASSERT(type == MI_UINT32);
 881               UT_ASSERT(value.uint32 == 6 || value.uint32 == 9);
 882               UT_ASSERT(!(flags & MI_FLAG_NULL));
 883           
 884               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[1]->instance, T("Number"), &value, &type, &flags, 0));
 885               UT_ASSERT(type == MI_UINT64);
 886               UT_ASSERT(value.uint64 == 1000000 || value.uint64 == 1000000000);
 887               UT_ASSERT(!(flags & MI_FLAG_NULL));
 888           
 889               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[1]->instance, T("Magnitude"), &value, &type, &flags, 0));
 890               UT_ASSERT(type == MI_UINT32);
 891               UT_ASSERT(value.uint32 == 6 || value.uint32 == 9);
 892               UT_ASSERT(!(flags & MI_FLAG_NULL));
 893           }
 894 mike  1.1 
 895           static void TestEnumerateX_Number1000001()
 896           {
 897               //omicli ei test/cpp X_Number1000001
 898           
 899               _CallEnumerate("test/cpp", "X_Number1000001", MI_FALSE);
 900           
 901               // validate response
 902               UT_ASSERT(s_results.size() == 1);
 903               UT_ASSERT(s_results[0] == MI_RESULT_OK);
 904           
 905               UT_ASSERT_EQUAL(s_instances.size(), 1);
 906           
 907               MI_Value value;
 908               MI_Type type;
 909               MI_Uint32 flags = 0;
 910           
 911               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Number"), &value, &type, &flags, 0));
 912               UT_ASSERT(type == MI_UINT64);
 913               UT_ASSERT(value.uint64 == 1000001);
 914               UT_ASSERT(!(flags & MI_FLAG_NULL));
 915 mike  1.1 
 916               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Magnitude"), &value, &type, &flags, 0));
 917               UT_ASSERT(type == MI_UINT32);
 918               UT_ASSERT(value.uint32 == 6);
 919               UT_ASSERT(!(flags & MI_FLAG_NULL));
 920           
 921               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Property0"), &value, &type, &flags, 0));
 922               UT_ASSERT(type == MI_UINT32);
 923               UT_ASSERT(value.uint32 == 9);
 924               UT_ASSERT(!(flags & MI_FLAG_NULL));
 925           }
 926           
 927           static void TestEnumerateNumberShallow_NotFound()
 928           {
 929               //omicli ei test/cpp X_Number
 930               //PostResultMsg
 931               //{
 932               //    tag=4
 933               //    msgID=10000
 934               //    clientID=12194392
 935               //    result=7 [NOT_FOUND]
 936 mike  1.1     //    request=NULL
 937               //}
 938           
 939               _CallEnumerate("test/cpp", "X_Number", MI_FALSE);
 940           
 941               // validate response
 942               UT_ASSERT_EQUAL(s_results.size(), 1);
 943               UT_ASSERT(s_results[0] == MI_RESULT_NOT_FOUND);
 944           
 945               UT_ASSERT(s_instances.size() == 0);
 946           }
 947           
 948           static void TestEnumerateNumberDeep()
 949           {
 950               //omicli ei test/cpp X_Number -deep
 951               //instance of X_HugeNumber
 952               //{
 953               //    Number=1000000
 954               //    Magnitude=6
 955               //}
 956               //instance of X_HugeNumber
 957 mike  1.1     //{
 958               //    Number=1000000000
 959               //    Magnitude=9
 960               //}
 961               //instance of X_SmallNumber
 962               //{
 963               //    Number=0
 964               //    SpelledNumber=zero
 965               //}
 966               //instance of X_SmallNumber
 967               //{
 968               //    Number=1
 969               //    SpelledNumber=one
 970               //}
 971               //....
 972           
 973               _CallEnumerate("test/cpp", "X_Number", MI_TRUE);
 974           
 975               // validate response
 976               UT_ASSERT(s_results.size() == 1);
 977               UT_ASSERT(s_results[0] == MI_RESULT_OK);
 978 mike  1.1 
 979               // 2 Huge + 10000 small
 980               UT_ASSERT_EQUAL(s_instances.size(), 10003);
 981           }
 982           
 983           static void TestEnumerateHugeNumberConformsToProfile()
 984           {
 985               //omicli ei test/cpp X_HugeNumberConformsToProfile
 986               //instance of X_HugeNumberConformsToProfile
 987               //{
 988               //    Profile= REF     instance of interop/X_Profile
 989               //    {
 990               //        InstanceID=number
 991               //    }
 992               //    Element= REF     instance of test/cpp/X_HugeNumber
 993               //    {
 994               //        Number=1000000
 995               //    }
 996               //}
 997               //instance of X_HugeNumberConformsToProfile
 998               //{
 999 mike  1.1     //    Profile= REF     instance of interop/X_Profile
1000               //    {
1001               //        InstanceID=number
1002               //    }
1003               //    Element= REF     instance of test/cpp/X_HugeNumber
1004               //    {
1005               //        Number=1000000000
1006               //    }
1007               //}
1008           
1009               // Verify that REF instances contin key properties only
1010           
1011               _CallEnumerate("test/cpp", "X_HugeNumberConformsToProfile", MI_TRUE);
1012           
1013               // validate response
1014               UT_ASSERT(s_results.size() == 1);
1015               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1016           
1017               UT_ASSERT(s_instances.size() == 2);
1018           
1019               MI_Value value, value_instance;
1020 mike  1.1     MI_Type type;
1021               MI_Uint32 flags = 0;
1022           
1023               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Profile"), &value_instance, &type, &flags, 0));
1024               UT_ASSERT(type == MI_REFERENCE);
1025               UT_ASSERT(value_instance.instance != NULL);
1026               UT_ASSERT(!(flags & MI_FLAG_NULL));
1027           
1028               {   // verify first instance
1029                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instance, T("instanceID"), &value, &type, &flags, 0));
1030                   UT_ASSERT(type == MI_STRING);
1031                   UT_ASSERT(value.string == ut::String(T("number")));
1032                   UT_ASSERT(!(flags & MI_FLAG_NULL));
1033           
1034                   MI_Uint32 count = 0;
1035           
1036                   // Verify that only one property is returned - key ('InstanceID')
1037                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElementCount(value_instance.instance, &count));
1038                   UT_ASSERT(count == 1);
1039               }
1040           }
1041 mike  1.1 
1042           static void TestEnumerateInvalidClass()
1043           {
1044               //omicli ei test/cpp NonExisitingClass
1045               //PostResultMsg
1046               //{
1047               //    tag=4
1048               //    msgID=10000
1049               //    clientID=10097240
1050               //    result=7 [NOT_FOUND]
1051               //    request=NULL
1052               //}
1053           
1054               _CallEnumerate("test/cpp", "NonExisitingClass", MI_FALSE);
1055           
1056               // validate response
1057               UT_ASSERT(s_results.size() == 1);
1058               UT_ASSERT(s_results[0] == MI_RESULT_NOT_FOUND);
1059           
1060               UT_ASSERT(s_instances.size() == 0);
1061           }
1062 mike  1.1 
1063           static void TestEnumerateFailedToLoadProvider(const char* ns)
1064           {
1065               _CallGetInstance(ns, "X_FailedAtLoad.id=1");
1066           
1067               // validate response
1068               UT_ASSERT(s_results.size() == 1);
1069               // expecting 'failed' result, since load failed
1070               UT_ASSERT_EQUAL(s_results[0], MI_RESULT_FAILED);
1071           
1072               UT_ASSERT(s_instances.size() == 0);
1073           }
1074           
1075           static void TestEnumerateFailedToLoadProvider_c()
1076           {
1077               TestEnumerateFailedToLoadProvider("test/c");
1078           }
1079           
1080           static void TestEnumerateFailedToLoadProvider_cpp()
1081           {
1082               TestEnumerateFailedToLoadProvider("test/cpp");
1083 mike  1.1 }
1084           
1085           static void TestInvokeSmallNumberSpellNumber0()
1086           {
1087               //omicli iv test/cpp X_SmallNumber SpellNumber num=0
1088               //instance of SpellNumber
1089               //{
1090               //    MIReturn=zero
1091               //    num=NULL
1092               //}
1093               _CallInvoke("test/cpp", "X_SmallNumber", "SpellNumber", "num=0");
1094           
1095               // validate response
1096               UT_ASSERT(s_results.size() == 1);
1097               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1098           
1099               UT_ASSERT(s_instances.size() == 1);
1100           
1101               MI_Value value;
1102               MI_Type type;
1103               MI_Uint32 flags = 0;
1104 mike  1.1 
1105               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1106               UT_ASSERT(type == MI_STRING);
1107               UT_ASSERT(value.string == ut::String(T("zero")));
1108               UT_ASSERT(!(flags & MI_FLAG_NULL));
1109           }
1110           
1111           static void TestInvokeSmallNumberSpellNumber120394()
1112           {
1113               //omicli iv test/cpp X_SmallNumber SpellNumber num=120394
1114               //instance of SpellNumber
1115               //{
1116               //    MIReturn=one hundred twenty  thousand three hundred ninety four
1117               //    num=NULL
1118               //}
1119           
1120               _CallInvoke("test/cpp", "X_SmallNumber", "SpellNumber", "num=120394");
1121           
1122               // validate response
1123               UT_ASSERT(s_results.size() == 1);
1124               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1125 mike  1.1 
1126               UT_ASSERT(s_instances.size() == 1);
1127           
1128               MI_Value value;
1129               MI_Type type;
1130               MI_Uint32 flags = 0;
1131           
1132               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1133               UT_ASSERT(type == MI_STRING);
1134               UT_ASSERT(value.string == ut::String(T("one hundred twenty  thousand three hundred ninety four")));
1135               UT_ASSERT(!(flags & MI_FLAG_NULL));
1136           }
1137           
1138           static void TestInvokeSmallNumberGetFactors_NotFound()
1139           {
1140               //omicli iv test/cpp X_SmallNumber.Number=11635 GetFactors
1141               //PostResultMsg
1142               //{
1143               //    tag=4
1144               //    msgID=10000
1145               //    clientID=10228312
1146 mike  1.1     //    result=7 [NOT_FOUND]
1147               //    request=NULL
1148               //}
1149           
1150               _CallInvoke("test/cpp", "X_SmallNumber.Number=11635", "GetFactors", 0);
1151           
1152               // validate response
1153               UT_ASSERT(s_results.size() == 1);
1154               UT_ASSERT(s_results[0] == MI_RESULT_NOT_FOUND);
1155           
1156               UT_ASSERT(s_instances.size() == 0);
1157           }
1158           
1159           static void TestInvokeSmallNumberGetFactors_InvalidParameter()
1160           {
1161               // trying to refer to non-static funciton in 'static' way
1162               //omicli iv test/cpp X_SmallNumber GetFactors
1163               //PostResultMsg
1164               //{
1165               //    tag=4
1166               //    msgID=10000
1167 mike  1.1     //    clientID=10752600
1168               //    result=4 [INVALID_PARAMETER]
1169               //    request=NULL
1170               //}
1171           
1172               _CallInvoke("test/cpp", "X_SmallNumber", "GetFactors", 0);
1173           
1174               // validate response
1175               UT_ASSERT(s_results.size() == 1);
1176               UT_ASSERT(s_results[0] == MI_RESULT_INVALID_PARAMETER);
1177           
1178               UT_ASSERT(s_instances.size() == 0);
1179           }
1180           
1181           static void TestInvokeSmallNumber_InvalidFn()
1182           {
1183               // trying to non-exisiting function
1184               //omicli iv test/cpp X_SmallNumber FunciotnThatDoesnotExist
1185               //PostResultMsg
1186               //{
1187               //    tag=4
1188 mike  1.1     //    msgID=10000
1189               //    clientID=10752600
1190               //    result=4 [FAILED]
1191               //    request=NULL
1192               //}
1193           
1194               _CallInvoke("test/cpp", "X_SmallNumber", "FunciotnThatDoesnotExist", 0);
1195           
1196               // validate response
1197               UT_ASSERT(s_results.size() == 1);
1198               UT_ASSERT(s_results[0] == MI_RESULT_FAILED);
1199           
1200               UT_ASSERT(s_instances.size() == 0);
1201           }
1202           
1203           static void TestInvokeSmallNumberGetFactors135()
1204           {
1205               //omicli iv test/cpp X_SmallNumber.Number=135 GetFactors
1206               //instance of GetFactors
1207               //{
1208               //    MIReturn=4
1209 mike  1.1     //    numbers={3, 3, 3, 5}
1210               //    spelled_numbers={three, three, three, five}
1211               //}
1212           
1213               _CallInvoke("test/cpp", "X_SmallNumber.Number=135", "GetFactors", 0);
1214           
1215               // validate response
1216               UT_ASSERT(s_results.size() == 1);
1217               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1218           
1219               UT_ASSERT(s_instances.size() == 1);
1220           
1221               MI_Value value;
1222               MI_Type type;
1223               MI_Uint32 flags = 0;
1224           
1225               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1226               UT_ASSERT(type == MI_UINT32);
1227               UT_ASSERT(value.uint32 == 4);
1228               UT_ASSERT(!(flags & MI_FLAG_NULL));
1229           
1230 mike  1.1     UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("numbers"), &value, &type, &flags, 0));
1231               UT_ASSERT(type == MI_UINT64A);
1232               UT_ASSERT(value.uint64a.size == 4);
1233               UT_ASSERT(value.uint64a.data[0] == 3);
1234               UT_ASSERT(value.uint64a.data[1] == 3);
1235               UT_ASSERT(value.uint64a.data[2] == 3);
1236               UT_ASSERT(value.uint64a.data[3] == 5);
1237               UT_ASSERT(!(flags & MI_FLAG_NULL));
1238           
1239               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("spelled_numbers"), &value, &type, &flags, 0));
1240               UT_ASSERT(type == MI_STRINGA);
1241               UT_ASSERT(value.stringa.size == 4);
1242               UT_ASSERT(value.stringa.data[0] == ut::String(T("three")));
1243               UT_ASSERT(value.stringa.data[1] == ut::String(T("three")));
1244               UT_ASSERT(value.stringa.data[2] == ut::String(T("three")));
1245               UT_ASSERT(value.stringa.data[3] == ut::String(T("five")));
1246               UT_ASSERT(!(flags & MI_FLAG_NULL));
1247           
1248           }
1249           
1250           static void TestInvokeHugeNumberSpellMagnitude()
1251 mike  1.1 {
1252               //omicli iv test/cpp X_HugeNumber.Number=1000000 SpellMagnitude
1253               //instance of SpellMagnitude
1254               //{
1255               //    MIReturn=six
1256               //}
1257           
1258               _CallInvoke("test/cpp", "X_HugeNumber.Number=1000000", "SpellMagnitude", 0);
1259           
1260               // validate response
1261               UT_ASSERT(s_results.size() == 1);
1262               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1263           
1264               UT_ASSERT(s_instances.size() == 1);
1265           
1266               MI_Value value;
1267               MI_Type type;
1268               MI_Uint32 flags = 0;
1269           
1270               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1271               UT_ASSERT(type == MI_STRING);
1272 mike  1.1     UT_ASSERT(value.string == ut::String(T("six")));
1273               UT_ASSERT(!(flags & MI_FLAG_NULL));
1274           }
1275           
1276           #if defined(CONFIG_POSIX)
1277           static void TestInvokeTerminate()
1278           {
1279               //omicli iv test/cpp X_NumberWorld Terminate
1280               // should terminate agent process
1281           
1282               _CallInvoke("test/cpp", "X_NumberWorld", "Terminate", 0);
1283           
1284               // validate response
1285               UT_ASSERT(s_results.size() == 1);
1286               UT_ASSERT(s_results[0] == MI_RESULT_FAILED);
1287           
1288               UT_ASSERT(s_instances.size() == 0);
1289           }
1290           #endif
1291           
1292           static void TestInvokeHugeNumberTestEmbedded()
1293 mike  1.1 {
1294               //omicli iv test/cpp X_HugeNumber TestEmbedded <instance params>
1295               // current version of omicli does not support these parameters
1296           
1297               _CallInvoke("test/cpp", "X_HugeNumber", "TestEmbedded", 0);
1298           
1299               // validate response
1300               UT_ASSERT(s_results.size() == 1);
1301               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1302           
1303               UT_ASSERT(s_instances.size() == 1);
1304           
1305               MI_Value value;
1306               MI_Type type;
1307               MI_Uint32 flags = 0;
1308           
1309               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1310               UT_ASSERT(type == MI_INSTANCE);
1311               UT_ASSERT(value.instance != NULL);
1312               UT_ASSERT(!(flags & MI_FLAG_NULL));
1313           
1314 mike  1.1     MI_ConstString cn = 0;
1315               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value.instance, &cn));
1316               UT_ASSERT(cn == ut::String(T("X_TestObject")));
1317           
1318           }
1319           
1320           static void _TestInvokePersonTestEmbeddedInstanceReturnKey20100609(const char* ns)
1321           {
1322               //omicli iv test/cpp TestEmbeddedOperations.Key=1 TestEmbeddedInstanceReturnKey20100609
1323               //instance of TestEmbeddedInstanceReturnKey20100609
1324               //{
1325               //    MIReturn=instance of X_TestEmbeddedInstanceMIReturnObject
1326               //    {
1327               //        id=20100609
1328               //        s=NULL
1329               //    }
1330               //}
1331           
1332               _CallInvoke(ns, "TestEmbeddedOperations.Key=1", "TestEmbeddedInstanceReturnKey20100609", 0);
1333           
1334               // validate response
1335 mike  1.1     UT_ASSERT(s_results.size() == 1);
1336               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1337           
1338               UT_ASSERT(s_instances.size() == 1);
1339           
1340               MI_Value value;
1341               MI_Type type;
1342               MI_Uint32 flags = 0;
1343           
1344               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1345               UT_ASSERT(type == MI_INSTANCE);
1346               UT_ASSERT(value.instance != NULL);
1347               UT_ASSERT(!(flags & MI_FLAG_NULL));
1348           
1349               MI_ConstString cn = 0;
1350               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value.instance, &cn));
1351               UT_ASSERT(cn == ut::String(T("X_TestEmbeddedInstanceMIReturnObject")));
1352           
1353               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value.instance, T("id"), &value, &type, &flags, 0));
1354               UT_ASSERT(type == MI_UINT64);
1355               UT_ASSERT(value.uint64 == 20100609);
1356 mike  1.1     UT_ASSERT(!(flags & MI_FLAG_NULL));
1357           }
1358           
1359           static void TestInvokePersonTestEmbeddedInstanceReturnKey20100609_c()
1360           {
1361           	_TestInvokePersonTestEmbeddedInstanceReturnKey20100609("test/c");
1362           }
1363           static void TestInvokePersonTestEmbeddedInstanceReturnKey20100609_cpp()
1364           {
1365           	_TestInvokePersonTestEmbeddedInstanceReturnKey20100609("test/cpp");
1366           }
1367           
1368           static void _TestInvokePersonTestEmbeddedObjectReturnKey20100609(const char* ns)
1369           {
1370               //omicli iv test/cpp TestEmbeddedOperations.Key=1 TestEmbeddedObjectReturnKey20100609
1371               //instance of TestEmbeddedObjectReturnKey20100609
1372               //{
1373               //    MIReturn=instance of X_TestEmbeddedObjectNotReferenced
1374               //    {
1375               //        ObjectID=20100609
1376               //    }
1377 mike  1.1     //}
1378           
1379               _CallInvoke(ns, "TestEmbeddedOperations.Key=1", "TestEmbeddedObjectReturnKey20100609", 0);
1380           
1381               // validate response
1382               UT_ASSERT(s_results.size() == 1);
1383               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1384           
1385               UT_ASSERT(s_instances.size() == 1);
1386           
1387               MI_Value value;
1388               MI_Type type;
1389               MI_Uint32 flags = 0;
1390           
1391               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1392               UT_ASSERT(type == MI_INSTANCE);
1393               UT_ASSERT(value.instance != NULL);
1394               UT_ASSERT(!(flags & MI_FLAG_NULL));
1395           
1396               MI_ConstString cn = 0;
1397               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value.instance, &cn));
1398 mike  1.1     UT_ASSERT(cn == ut::String(T("X_TestEmbeddedObjectNotReferenced")));
1399           
1400               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value.instance, T("ObjectId"), &value, &type, &flags, 0));
1401               UT_ASSERT(type == MI_UINT64);
1402               UT_ASSERT(value.uint64 == 20100609);
1403               UT_ASSERT(!(flags & MI_FLAG_NULL));
1404           }
1405           
1406           
1407           static void TestInvokePersonTestEmbeddedObjectReturnKey20100609_c()
1408           {
1409           	_TestInvokePersonTestEmbeddedObjectReturnKey20100609("test/c");
1410           }
1411           
1412           static void TestInvokePersonTestEmbeddedObjectReturnKey20100609_cpp()
1413           {
1414           	_TestInvokePersonTestEmbeddedObjectReturnKey20100609("test/cpp");
1415           }
1416           
1417           static void _TestInvokePersonTestEmbeddedParameters(const char* ns)
1418           {
1419 mike  1.1     //omicli iv test/cpp TestEmbeddedOperations.Key=1 TestEmbedded
1420               // omicli does not support it yet ([in] embedded objects params)
1421           
1422           
1423               // INPUT:
1424               // objectsArray - 2 instances of MSFT_Base
1425               // objectSingle - MSFT_Person
1426               // testObjectsArray - 3 objects
1427               // testObjectSingle - not set
1428           
1429               // OUTPUT
1430               // objectsArray - 2 instances of MSFT_Animal with the same keys and species "test"
1431               // objectSingle - the same
1432               // testObjectsArray - last 2 objects of input
1433               // testObjectSingle - key is a sum of input objects
1434           
1435           	//[static, EmbeddedInstance("X_TestObject")]
1436           	//ut::String TestEmbedded(
1437           	//    [EmbeddedObject, IN, OUT]
1438           	//    ut::String objectsArray[],
1439           	//    [EmbeddedObject, IN, OUT]
1440 mike  1.1 	//    ut::String objectSingle,
1441           	//    
1442           	//    [EmbeddedInstance("X_TestObject"), in,out]
1443           	//    ut::String testObjectsArray[],
1444           	//    [EmbeddedInstance("X_TestObject"), in,out]
1445           	//    ut::String testObjectSingle
1446           	//);
1447           
1448           
1449               MI_Result r;
1450               MI_Instance* dynamicInstanceParams = 0;
1451               Batch   dynamicBatch = BATCH_INITIALIZER;
1452           
1453               r = Instance_NewDynamic(
1454                   &dynamicInstanceParams,
1455                   MI_T("params"),
1456                   MI_FLAG_CLASS,
1457                   &dynamicBatch);
1458           
1459               UT_ASSERT (MI_RESULT_OK == r);
1460           
1461 mike  1.1     // objectSingle
1462               MI_Value value;
1463           
1464               value.instance = _ReferenceStringToInstance(&dynamicBatch, "MSFT_Animal.Key=17", 0);
1465               UT_ASSERT( value.instance );
1466           
1467               r = MI_Instance_AddElement(dynamicInstanceParams, MI_T("objectSingle"), 
1468                   &value, MI_INSTANCE, MI_FLAG_BORROW);
1469               UT_ASSERT(r == MI_RESULT_OK);
1470           
1471               MI_Instance* instances[3];
1472           
1473               instances[0] = _ReferenceStringToInstance(&dynamicBatch, "MSFT_Animal.Key=101", 0);
1474               instances[1] = _ReferenceStringToInstance(&dynamicBatch, "MSFT_Animal.Key=102", 0);
1475               value.instancea.data = instances;
1476               value.instancea.size = 2;
1477           
1478               r = MI_Instance_AddElement(dynamicInstanceParams, MI_T("objectsArray"), 
1479                   &value, MI_INSTANCEA, MI_FLAG_BORROW);
1480               UT_ASSERT(r == MI_RESULT_OK);
1481           
1482 mike  1.1     instances[0] = _ReferenceStringToInstance(&dynamicBatch, "X_TestObject.id=101", 0);
1483               instances[1] = _ReferenceStringToInstance(&dynamicBatch, "X_TestObject.id=102", 0);
1484               instances[2] = _ReferenceStringToInstance(&dynamicBatch, "X_TestObject.id=103", 0);
1485               value.instancea.data = instances;
1486               value.instancea.size = 3;
1487           
1488               r = MI_Instance_AddElement(dynamicInstanceParams, 
1489                   MI_T("testObjectsArray"), &value, MI_INSTANCEA, MI_FLAG_BORROW);
1490               UT_ASSERT(r == MI_RESULT_OK);
1491           
1492               if (trace)
1493                   MI_Instance_Print(dynamicInstanceParams, stdout, 0);
1494           
1495               _CallInvoke(ns, "TestEmbeddedOperations.Key=1", "TestEmbedded", 0, dynamicInstanceParams);
1496           
1497               Batch_Destroy(&dynamicBatch);
1498           
1499               // validate response
1500               UT_ASSERT(s_results.size() == 1);
1501               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1502           
1503 mike  1.1     UT_ASSERT(s_instances.size() == 1);
1504           
1505               MI_Type type;
1506               MI_Uint32 flags = 0;
1507           
1508               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
1509               UT_ASSERT(type == MI_INSTANCE);
1510               UT_ASSERT(value.instance != NULL);
1511               UT_ASSERT(!(flags & MI_FLAG_NULL));
1512           
1513               MI_ConstString cn = 0;
1514               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value.instance, &cn));
1515               UT_ASSERT(cn == ut::String(T("X_TestObject")));
1516           
1517               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value.instance, T("id"), &value, &type, &flags, 0));
1518               UT_ASSERT(type == MI_UINT64);
1519           
1520               UT_ASSERT(value.uint64 == (101+102+103));   /* expecting sum of keys */
1521               UT_ASSERT(!(flags & MI_FLAG_NULL));
1522           
1523               {
1524 mike  1.1         MI_Value value_instance;
1525           
1526                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("testObjectsArray"), &value_instance, &type, &flags, 0));
1527                   UT_ASSERT(type == MI_INSTANCEA);
1528                   UT_ASSERT(value_instance.instancea.size == 2);
1529                   UT_ASSERT(!(flags & MI_FLAG_NULL));
1530           
1531                   /* expecting last two elements */
1532                   for ( int num = 0; num < 2; num++ )
1533                   {
1534                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value_instance.instancea.data[num], &cn));
1535                       UT_ASSERT(cn == ut::String(T("X_TestObject")));
1536           
1537                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[num], T("id"), &value, &type, &flags, 0));
1538                       UT_ASSERT(type == MI_UINT64);
1539                       UT_ASSERT(value.uint64 == (MI_Uint64)(102 + num));
1540                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1541                   }
1542               }
1543               {
1544                   MI_Value value_instance;
1545 mike  1.1 
1546                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("objectsArray"), &value_instance, &type, &flags, 0));
1547                   UT_ASSERT(type == MI_INSTANCEA);
1548                   UT_ASSERT(value_instance.instancea.size == 2);
1549                   UT_ASSERT(!(flags & MI_FLAG_NULL));
1550           
1551                   /* expecting last two elements */
1552                   for ( int num = 0; num < 2; num++ )
1553                   {
1554                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(value_instance.instancea.data[num], &cn));
1555                       UT_ASSERT(cn == ut::String(T("MSFT_Animal")));
1556           
1557                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(value_instance.instancea.data[num], T("species"), &value, &type, &flags, 0));
1558                       UT_ASSERT(type == MI_STRING);
1559                       UT_ASSERT(value.string == ut::String(T("test")));
1560                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1561                   }
1562               }
1563           
1564           }
1565           
1566 mike  1.1 
1567           static void TestInvokePersonTestEmbeddedParameters_c()
1568           {
1569               _TestInvokePersonTestEmbeddedParameters("test/c");
1570           }
1571           
1572           static void TestInvokePersonTestEmbeddedParameters_cpp()
1573           {
1574           	_TestInvokePersonTestEmbeddedParameters("test/cpp");
1575           }
1576           
1577           static void TestAssociatorsFriends()
1578           {
1579               //omicli a test/cpp MSFT_Person.Key=1  -ac MSFT_Friends -rc MSFT_Base
1580               //instance of MSFT_Person
1581               //{
1582               //    Key=2
1583               //    Species=NULL
1584               //    Last=Adams
1585               //    First=John
1586               //}
1587 mike  1.1 
1588               _CallAssociators("test/cpp", "MSFT_Person.Key=1", "MSFT_Friends", "MSFT_Base", "Left", "Right");
1589           
1590               // validate response
1591               UT_ASSERT(s_results.size() == 1);
1592               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1593           
1594               UT_ASSERT(s_instances.size() == 1);
1595           
1596               MI_Value value;
1597               MI_Type type;
1598               MI_Uint32 flags = 0;
1599           
1600               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Last"), &value, &type, &flags, 0));
1601               UT_ASSERT(type == MI_STRING);
1602               UT_ASSERT(value.string == ut::String(T("Adams")));
1603               UT_ASSERT(!(flags & MI_FLAG_NULL));
1604           
1605               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("First"), &value, &type, &flags, 0));
1606               UT_ASSERT(type == MI_STRING);
1607               UT_ASSERT(value.string == ut::String(T("John")));
1608 mike  1.1     UT_ASSERT(!(flags & MI_FLAG_NULL));
1609           
1610               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("Key"), &value, &type, &flags, 0));
1611               UT_ASSERT(type == MI_UINT32);
1612               UT_ASSERT(value.uint32 == 2);
1613               UT_ASSERT(!(flags & MI_FLAG_NULL));
1614           }
1615           
1616           enum ExpectedNumProvInstances
1617           {
1618               enumExpectProfileWorld  = 1,
1619               enumExpectProfileHuge   = 2,
1620               enumExpectSmallEven     = 4,
1621               enumExpectSmallOdd      = 8,
1622               enumExpectHuge          = 16,
1623               enumExpectWorld         = 32,
1624               enumExpectSmallNumber350    = 64,
1625               enumExpectSmallNumber1400   = 128,
1626               enumExpectSmallNumber0  = 256
1627           };
1628           
1629 mike  1.1 static void _ValidateNumberProvInstances(
1630               int expected)
1631           {
1632               set<MI_Uint64> even, odd, huge;
1633               bool gotWorld = false, 
1634                   gotProfileWorld = false, 
1635                   gotProfileNumber = false;
1636           
1637               for ( size_t i = 0; i < s_instances.size(); i++ )
1638               {
1639                   MI_ConstString cn = 0;
1640                   UT_ASSERT(MI_RESULT_OK == MI_Instance_GetClassName(s_instances[i]->instance, &cn));
1641           
1642                   MI_Value value;
1643                   MI_Type type;
1644                   MI_Uint32 flags = 0;
1645           
1646                   ut::String s(cn);
1647                   if ( s == MI_T("X_SmallNumber") )
1648                   {
1649           
1650 mike  1.1             UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[i]->instance, T("Number"), &value, &type, &flags, 0));
1651                       UT_ASSERT(type == MI_UINT64);
1652                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1653                       if (value.uint64 % 2 == 0)
1654                       {
1655                           UT_ASSERT( (expected & (enumExpectSmallEven|enumExpectSmallNumber350|enumExpectSmallNumber1400|enumExpectSmallNumber0) ) != 0 );
1656                           even.insert(value.uint64);
1657                       }
1658                       else
1659                       {
1660                           UT_ASSERT( (expected & (enumExpectSmallOdd) ) != 0 );
1661                           odd.insert(value.uint64);
1662                       }
1663           
1664                       // check that SpelledNumber is not empty
1665                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[i]->instance, T("SpelledNumber"), &value, &type, &flags, 0));
1666                       UT_ASSERT(type == MI_STRING);
1667                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1668                       UT_ASSERT( !ut::String(value.string).empty());
1669           
1670                       // namespace
1671 mike  1.1             MI_ConstString ns = 0;
1672                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetNameSpace(s_instances[i]->instance, &ns));
1673           
1674                       UT_ASSERT( ns != 0 );
1675                       UT_ASSERT(ns == ut::String(T("test/cpp")));
1676                   }
1677                   else if ( s == MI_T("X_HugeNumber") )
1678                   {
1679                       UT_ASSERT( (expected & enumExpectHuge ) != 0 );
1680           
1681                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[i]->instance, T("Number"), &value, &type, &flags, 0));
1682                       UT_ASSERT(type == MI_UINT64);
1683                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1684           
1685                       huge.insert(value.uint64);
1686                   }
1687                   else if ( s == MI_T("X_NumberWorld") )
1688                   {
1689                       UT_ASSERT( (expected & enumExpectWorld ) != 0 );
1690           
1691                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[i]->instance, T("Name"), &value, &type, &flags, 0));
1692 mike  1.1             UT_ASSERT(type == MI_STRING);
1693                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1694                       UT_ASSERT(value.string == ut::String(T("theWorld")));
1695                       gotWorld = true;
1696           
1697                       // namespace
1698                       MI_ConstString ns = 0;
1699                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetNameSpace(s_instances[i]->instance, &ns));
1700           
1701                       UT_ASSERT( ns != 0 );
1702                       UT_ASSERT(ns == ut::String(T("test/cpp")));
1703                   }
1704                   else if ( s == MI_T("X_Profile") )
1705                   {
1706                       UT_ASSERT( (expected & (enumExpectProfileWorld|enumExpectProfileHuge) ) != 0 );
1707           
1708                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[i]->instance, T("InstanceID"), &value, &type, &flags, 0));
1709                       UT_ASSERT(type == MI_STRING);
1710                       UT_ASSERT(!(flags & MI_FLAG_NULL));
1711           
1712                       if (value.string == ut::String(T("world")))
1713 mike  1.1             {
1714                           UT_ASSERT( (expected & (enumExpectProfileWorld) ) != 0 );
1715                           gotProfileWorld = true;
1716                       }
1717                       else if (value.string == ut::String(T("number")))
1718                       {
1719                           UT_ASSERT( (expected & (enumExpectProfileHuge) ) != 0 );
1720                           gotProfileNumber = true;
1721                       }
1722                       else
1723                           UT_ASSERT_FAILED_MSG( (string("unexpected profile ") + ut::StrToChar(value.string)).c_str() );
1724           
1725                       // namespace
1726                       MI_ConstString ns = 0;
1727                       UT_ASSERT(MI_RESULT_OK == MI_Instance_GetNameSpace(s_instances[i]->instance, &ns));
1728           
1729                       UT_ASSERT( ns != 0 );
1730                       UT_ASSERT(ns == ut::String(T("interop")));
1731           
1732                   }
1733                   else
1734 mike  1.1         {
1735                       UT_ASSERT_FAILED_MSG( (string("unexpected class ") + ut::StrToChar(s)).c_str() );
1736                   }
1737               }
1738           
1739               // validate results
1740               if (expected & enumExpectHuge)
1741               {
1742                   UT_ASSERT(huge.size() == 2);
1743                   UT_ASSERT(huge.find(1000000) != huge.end());
1744                   UT_ASSERT(huge.find(1000000000) != huge.end());
1745               }
1746           
1747               if (expected & enumExpectSmallEven)
1748               {
1749                   UT_ASSERT(even.size() == 5000);
1750                   for ( int i = 0; i < 10000; i++ )
1751                   {
1752                       if ( i % 2 != 0 )
1753                           continue;
1754           
1755 mike  1.1             UT_ASSERT(even.find(i) != even.end());
1756                   }
1757               }
1758               if (expected & enumExpectSmallNumber0)
1759               {
1760                   UT_ASSERT(even.find(0) != even.end());
1761               }
1762               if (expected & enumExpectSmallNumber350)
1763               {
1764                   UT_ASSERT(even.find(350) != even.end());
1765               }
1766               if (expected & enumExpectSmallNumber1400)
1767               {
1768                   UT_ASSERT(even.find(1400) != even.end());
1769               }
1770               if (expected & enumExpectSmallOdd)
1771               {
1772                   UT_ASSERT(odd.size() == 5000);
1773                   for ( int i = 0; i < 10000; i++ )
1774                   {
1775                       if ( i % 2 == 0 )
1776 mike  1.1                 continue;
1777           
1778                       UT_ASSERT(odd.find(i) != odd.end());
1779                   }
1780               }
1781           
1782               if (expected & enumExpectProfileWorld)
1783               {
1784                   UT_ASSERT(gotProfileWorld);
1785               }
1786               if (expected & enumExpectProfileHuge)
1787               {
1788                   UT_ASSERT(gotProfileNumber);
1789               }
1790               if (expected & enumExpectWorld)
1791               {
1792                   UT_ASSERT(gotWorld);
1793               }
1794           }
1795           
1796           static void TestAssociatorsNumProv_AllOfWorld()
1797 mike  1.1 {
1798               // omicli a test/cpp X_numberWorld.Name=theWorld
1799               // ... gazillion of results
1800               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", 0, 0, 0, 0);
1801           
1802               // validate response
1803               UT_ASSERT(s_results.size() == 1);
1804               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1805           
1806               UT_ASSERT(s_instances.size() == (
1807                   10000 /* small numbers */ + 2 /* huge numbers */ + 1 /* profile */
1808                   ));
1809           
1810               // verify instances
1811               _ValidateNumberProvInstances(enumExpectProfileWorld | enumExpectSmallEven | enumExpectSmallOdd | enumExpectHuge);
1812           }
1813           
1814           static void TestAssociatorsNumProv_ProfileOfWorldByAssocClass()
1815           {
1816               //omicli a test/cpp X_numberWorld.Name=theWorld -ac X_ElementConformsToProfile
1817               //instance of X_Profile
1818 mike  1.1     //{
1819               //    InstanceID=world
1820               //    RegisteredName=World
1821               //}
1822           
1823              _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "X_ElementConformsToProfile", 0, 0, 0);
1824           
1825               // validate response
1826               UT_ASSERT(s_results.size() == 1);
1827               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1828           
1829               UT_ASSERT(s_instances.size() == (
1830                   1 /* profile */
1831                   ));
1832           
1833               // verify instances
1834               _ValidateNumberProvInstances(enumExpectProfileWorld);
1835           }
1836           
1837           static void TestAssociatorsNumProv_ProfileOfWorldByResultClass()
1838           {
1839 mike  1.1     //omicli a test/cpp X_numberWorld.Name=theWorld -rc X_Profile
1840               //instance of X_Profile
1841               //{
1842               //    InstanceID=world
1843               //    RegisteredName=World
1844               //}
1845           
1846              _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", 0, "X_Profile", 0, 0);
1847           
1848               // validate response
1849               UT_ASSERT(s_results.size() == 1);
1850               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1851           
1852               UT_ASSERT(s_instances.size() == (
1853                   1 /* profile */
1854                   ));
1855           
1856               // verify instances
1857               _ValidateNumberProvInstances(enumExpectProfileWorld);
1858           }
1859           
1860 mike  1.1 static void TestAssociatorsNumProv_ProfileOfWorldByRole()
1861           {
1862               //omicli a test/cpp X_numberWorld.Name=theWorld -role Element
1863               //instance of X_Profile
1864               //{
1865               //    InstanceID=world
1866               //    RegisteredName=World
1867               //}
1868           
1869              _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", 0, 0, "Element", 0);
1870           
1871               // validate response
1872               UT_ASSERT(s_results.size() == 1);
1873               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1874           
1875               UT_ASSERT(s_instances.size() == (
1876                   1 /* profile */
1877                   ));
1878           
1879               // verify instances
1880               _ValidateNumberProvInstances(enumExpectProfileWorld);
1881 mike  1.1 }
1882           
1883           static void TestAssociatorsNumProv_ProfileOfWorldByResultRole()
1884           {
1885               //omicli a test/cpp X_numberWorld.Name=theWorld -rrole Profile
1886               //instance of X_Profile
1887               //{
1888               //    InstanceID=world
1889               //    RegisteredName=World
1890               //}
1891           
1892              _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", 0, 0, 0, "Profile");
1893           
1894               // validate response
1895               UT_ASSERT(s_results.size() == 1);
1896               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1897           
1898               UT_ASSERT(s_instances.size() == (
1899                   1 /* profile */
1900                   ));
1901           
1902 mike  1.1     // verify instances
1903               _ValidateNumberProvInstances(enumExpectProfileWorld);
1904           }
1905           
1906           static void TestAssociatorsNumProv_AllNumbersOfWorld()
1907           {
1908               // omicli a test/cpp X_numberWorld.Name=theWorld -ac x_AllNumbers
1909               // ... gazillion of results
1910               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "x_aLLnUMBERS", 0, 0, 0);
1911           
1912               // validate response
1913               UT_ASSERT(s_results.size() == 1);
1914               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1915           
1916               UT_ASSERT(s_instances.size() == (
1917                   10000 /* small numbers */ + 2 /* huge numbers */ 
1918                   ));
1919           
1920               // verify instances
1921               _ValidateNumberProvInstances(enumExpectSmallEven | enumExpectSmallOdd | enumExpectHuge);
1922           }
1923 mike  1.1 static void TestAssociatorsNumProv_AllHugeNumbersOfWorld()
1924           {
1925               // omicli a test/cpp X_numberWorld.Name=theWorld -ac x_HugeNumbers
1926               // ... gazillion of results
1927               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "x_HugeNumbers", 0, 0, 0);
1928           
1929               // validate response
1930               UT_ASSERT(s_results.size() == 1);
1931               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1932           
1933               UT_ASSERT(s_instances.size() == (
1934                   2 /* huge numbers */ 
1935                   ));
1936           
1937               // verify instances
1938               _ValidateNumberProvInstances(enumExpectHuge);
1939           }
1940           
1941           static void TestAssociatorsNumProv_AllEvenNumbersOfWorld()
1942           {
1943               // omicli a test/cpp X_numberWorld.Name=theWorld -ac X_EvenSmallNumbers
1944 mike  1.1     // ... gazillion of results
1945               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "X_EvenSmallNumbers", 0, 0, 0);
1946           
1947               // validate response
1948               UT_ASSERT(s_results.size() == 1);
1949               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1950           
1951               UT_ASSERT(s_instances.size() == (
1952                   5000 /* even small numbers */ 
1953                   ));
1954           
1955               // verify instances
1956               _ValidateNumberProvInstances(enumExpectSmallEven);
1957           }
1958           
1959           
1960           static void TestAssociatorsNumProv_AllOddNumbersOfWorld()
1961           {
1962               // omicli a test/cpp X_numberWorld.Name=theWorld -ac X_OddSmallNumbers
1963               // ... gazillion of results
1964               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "X_OddSmallNumbers", 0, 0, 0);
1965 mike  1.1 
1966               // validate response
1967               UT_ASSERT(s_results.size() == 1);
1968               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1969           
1970               UT_ASSERT(s_instances.size() == (
1971                   5000 /* small numbers */ 
1972                   ));
1973           
1974               // verify instances
1975               _ValidateNumberProvInstances(enumExpectSmallOdd);
1976           }
1977           
1978           static void TestAssociatorsNumProv_AllProfile()
1979           {
1980               // omicli a test/cpp X_Profile.InstanceID=number 
1981               
1982           
1983               _CallAssociators("test/cpp", "X_Profile.InstanceID=number", 0, 0, 0, 0);
1984           
1985               // validate response
1986 mike  1.1     UT_ASSERT(s_results.size() == 1);
1987               UT_ASSERT(s_results[0] == MI_RESULT_OK);
1988           
1989               UT_ASSERT(s_instances.size() == (
1990                   2 /* huge numbers */ 
1991                   ));
1992           
1993               // verify instances
1994               _ValidateNumberProvInstances(enumExpectHuge);
1995           }
1996           
1997           static void TestAssociatorsNumProv_AllOfSmallNumber()
1998           {
1999               //omicli a test/cpp X_smallNumber.Number=700
2000               //instance of X_SmallNumber
2001               //{
2002               //    Description=NULL
2003               //    Number=350
2004               //    SpelledNumber=three hundred fifty
2005               //}
2006               //instance of X_SmallNumber
2007 mike  1.1     //{
2008               //    Description=NULL
2009               //    Number=1400
2010               //    SpelledNumber=one thousand four hundred
2011               //}
2012               //instance of X_NumberWorld
2013               //{
2014               //    Description=NULL
2015               //    Name=theWorld
2016               //    Version=0.1
2017               //}
2018               
2019           
2020               _CallAssociators("test/cpp", "X_smallNumber.Number=700", 0, 0, 0, 0);
2021           
2022               // validate response
2023               UT_ASSERT(s_results.size() == 1);
2024               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2025           
2026               UT_ASSERT(s_instances.size() == (
2027                   3 
2028 mike  1.1         ));
2029           
2030               // verify instances
2031               _ValidateNumberProvInstances(enumExpectWorld | enumExpectSmallNumber1400 | enumExpectSmallNumber350 );
2032           }
2033           
2034           static void TestAssociatorsNumProv_AllOfSmallNumberByRoleNumber()
2035           {
2036               //omicli a test/cpp X_smallNumber.Number=700  -role number
2037               //instance of X_SmallNumber
2038               //{
2039               //    Description=NULL
2040               //    Number=350
2041               //    SpelledNumber=three hundred fifty
2042               //}
2043               //instance of X_NumberWorld
2044               //{
2045               //    Description=NULL
2046               //    Name=theWorld
2047               //    Version=0.1
2048               //}    
2049 mike  1.1 
2050               _CallAssociators("test/cpp", "X_smallNumber.Number=700", 0, 0, "number", 0);
2051           
2052               // validate response
2053               UT_ASSERT(s_results.size() == 1);
2054               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2055           
2056               UT_ASSERT(s_instances.size() == (
2057                   2 
2058                   ));
2059           
2060               // verify instances
2061               _ValidateNumberProvInstances(enumExpectWorld | enumExpectSmallNumber350 );
2062           }
2063           
2064           static void TestAssociatorsNumProv_AllOfSmallNumberByRoleHalf()
2065           {
2066               //omicli a test/cpp X_smallNumber.Number=700  -role half
2067               //instance of X_SmallNumber
2068               //{
2069               //    Description=NULL
2070 mike  1.1     //    Number=1400
2071               //    SpelledNumber=one thousand four hundred
2072               //}
2073           
2074               _CallAssociators("test/cpp", "X_smallNumber.Number=700", 0, 0, "half", 0);
2075           
2076               // validate response
2077               UT_ASSERT(s_results.size() == 1);
2078               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2079           
2080               UT_ASSERT(s_instances.size() == (
2081                   1
2082                   ));
2083           
2084               // verify instances
2085               _ValidateNumberProvInstances(enumExpectSmallNumber1400 );
2086           }
2087           
2088           static void TestAssociatorsNumProv_AllOfSmallNumberByAssocClassHalves()
2089           {
2090               //omicli a test/cpp X_smallNumber.Number=700  -ac x_halves
2091 mike  1.1     //instance of X_SmallNumber
2092               //{
2093               //    Description=NULL
2094               //    Number=350
2095               //    SpelledNumber=three hundred fifty
2096               //}
2097               //instance of X_SmallNumber
2098               //{
2099               //    Description=NULL
2100               //    Number=1400
2101               //    SpelledNumber=one thousand four hundred
2102               //}
2103           
2104               _CallAssociators("test/cpp", "X_smallNumber.Number=700", "x_halves", 0, 0, 0);
2105           
2106               // validate response
2107               UT_ASSERT(s_results.size() == 1);
2108               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2109           
2110               UT_ASSERT(s_instances.size() == (
2111                   2
2112 mike  1.1         ));
2113           
2114               // verify instances
2115               _ValidateNumberProvInstances( enumExpectSmallNumber350 | enumExpectSmallNumber1400 );
2116           }
2117           
2118           static void TestAssociatorsNumProv_DoubleZeroInstancesOfSmallNumberByAssocClassHalves()
2119           {
2120               //omicli a test/cpp X_smallNumber.Number=0 -ac x_halves
2121               //instance of X_SmallNumber
2122               //{
2123               //    Description=NULL
2124               //    Number=0
2125               //    SpelledNumber=zero
2126               //}
2127               //instance of X_SmallNumber
2128               //{
2129               //    Description=NULL
2130               //    Number=0
2131               //    SpelledNumber=zero
2132               //}
2133 mike  1.1 
2134           
2135               _CallAssociators("test/cpp", "X_smallNumber.Number=0", "x_halves", 0, 0, 0);
2136           
2137               // validate response
2138               UT_ASSERT(s_results.size() == 1);
2139               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2140           
2141               UT_ASSERT(s_instances.size() == (
2142                   2
2143                   ));
2144           
2145               // verify instances
2146               _ValidateNumberProvInstances( enumExpectSmallNumber0 );
2147           }
2148           
2149           static void TestAssociatorsNumProv_AllOfSmallNumberByAllFilters()
2150           {
2151               //omicli a test/cpp X_smallNumber.Number=0 -ac x_halves -rc x_number -role half -rrole number
2152               //instance of X_SmallNumber
2153               //{
2154 mike  1.1     //    Description=NULL
2155               //    Number=0
2156               //    SpelledNumber=zero
2157               //}
2158           
2159               _CallAssociators("test/cpp", "X_smallNumber.Number=0", "x_halves", "x_number", "half", "number");
2160           
2161               // validate response
2162               UT_ASSERT(s_results.size() == 1);
2163               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2164           
2165               UT_ASSERT(s_instances.size() == (
2166                   1
2167                   ));
2168           
2169               // verify instances
2170               _ValidateNumberProvInstances( enumExpectSmallNumber0 );
2171           }
2172           
2173           static void TestAssociatorsNumProv_ProfileOfWorldByRoleRRole()
2174           {
2175 mike  1.1     //omicli a test/cpp X_numberWorld.Name=theWorld -ac X_AllNumbers -rc X_Number -role Number -rrole Number
2176               // 
2177               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "X_AllNumbers", "X_Number", "Number", "Number");
2178           
2179               // validate response
2180               UT_ASSERT(s_results.size() == 1);
2181               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2182           
2183               UT_ASSERT(s_instances.size() == (0));
2184           }
2185           
2186           
2187           static void TestAssociatorsNumProv_ProfileOfWorldByInvalidAssocClass()
2188           {
2189               // omicli a test/cpp X_numberWorld.Name=theWorld -ac x_halves
2190               // 
2191               // this assoc class is not related to X_NumberWorld class
2192               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", "x_halves", 0, 0, 0);
2193           
2194               // validate response
2195               UT_ASSERT(s_results.size() == 1);
2196 mike  1.1     UT_ASSERT(s_results[0] == MI_RESULT_NOT_FOUND);
2197           
2198               UT_ASSERT(s_instances.size() == (0));
2199           }
2200           
2201           static void TestAssociatorsNumProv_ProfileOfWorldByInvalidResultClass()
2202           {
2203               // omicli a test/cpp X_numberWorld.Name=theWorld -rc SomeInvalidClass
2204               // 
2205               _CallAssociators("test/cpp", "X_numberWorld.Name=theWorld", 0, "SomeInvalidClass", 0, 0);
2206           
2207               // validate response
2208               UT_ASSERT(s_results.size() == 1);
2209               UT_ASSERT(s_results[0] == MI_RESULT_INVALID_CLASS);
2210           
2211               UT_ASSERT(s_instances.size() == (0));
2212           }
2213           
2214           static void TestAssociatorsNumProv_InvalidNameSpace()
2215           {
2216               // omicli a invalid/namespace X_numberWorld.Name=theWorld
2217 mike  1.1     // 
2218               _CallAssociators("invalid/namespace", "X_numberWorld.Name=theWorld", 0, 0, 0, 0);
2219           
2220               // validate response
2221               UT_ASSERT(s_results.size() == 1);
2222               UT_ASSERT(s_results[0] == MI_RESULT_INVALID_NAMESPACE);
2223           
2224               UT_ASSERT(s_instances.size() == (0));
2225           }
2226           
2227           static void TestAssociatorsNumProv_NoInstance()
2228           {
2229               // omicli a test/cpp X_numberWorld.UnknownProp=theWorld
2230               // 
2231               _CallAssociators("test/cpp", "X_numberWorld.UnknownProp=theWorld", 0, 0, 0, 0);
2232           
2233               // validate response
2234               UT_ASSERT(s_results.size() == 1);
2235           
2236               /*if (s_results[0] != MI_RESULT_NOT_FOUND)
2237                   cout << "res " << s_results[0] << endl;*/
2238 mike  1.1 
2239               //UT_ASSERT(s_results[0] == MI_RESULT_NOT_FOUND);
2240               UT_ASSERT(s_results[0] != MI_RESULT_OK);
2241           
2242               UT_ASSERT(s_instances.size() == (0));
2243           }
2244           
2245           static void TestReferencesNumProv_ProfileByAssocClass()
2246           {
2247               //omicli r test/cpp X_Profile.InstanceID=world -ac X_NumberWorldConformsToProfile
2248               //instance of X_NumberWorldConformsToProfile
2249               //{
2250               //    Profile=    instance of interop/X_Profile
2251               //    {
2252               //        InstanceID=world
2253               //        RegisteredName=World
2254               //    }
2255               //
2256               //    Element=    instance of test/cpp/X_NumberWorld
2257               //    {
2258               //        Description=NULL
2259 mike  1.1     //        Name=theWorld
2260               //        Version=0.1
2261               //    }
2262               //
2263               //}
2264             
2265               _CallReferences("test/cpp", "X_Profile.InstanceID=world", "X_NumberWorldConformsToProfile", 0);
2266           
2267               // validate response
2268               UT_ASSERT(s_results.size() == 1);
2269               UT_ASSERT(s_results[0] == MI_RESULT_OK);
2270           
2271               UT_ASSERT(s_instances.size() == (
2272                   1
2273                   ));
2274           
2275               // verify instances
2276               //_ValidateNumberProvInstances( enumExpectSmallNumber0 );
2277               // ATTN!: Add instance verification, once MI_InstanceCompare is ready
2278           }
2279           
2280 mike  1.1 static void TestNamespaceParameterUsingInvoke()
2281           {
2282           
2283               _CallInvoke("test/cpp", "x_numberWorld", "ReturnNamespace", 0);
2284           
2285               // validate response
2286               UT_ASSERT(s_results.size() == 1);
2287               UT_ASSERT_EQUAL(s_results[0], MI_RESULT_OK);
2288           
2289               UT_ASSERT(s_instances.size() == 1);
2290           
2291               MI_Value value;
2292               MI_Type type;
2293               MI_Uint32 flags = 0;
2294           
2295               UT_ASSERT(MI_RESULT_OK == MI_Instance_GetElement(s_instances[0]->instance, T("MIReturn"), &value, &type, &flags, 0));
2296               UT_ASSERT(type == MI_STRING);
2297               UT_ASSERT(!(flags & MI_FLAG_NULL));
2298               UT_ASSERT(value.string == ut::String(T("test/cpp")) || value.string == ut::String(T("oop/requestor/test/cpp")));
2299           }
2300           
2301 mike  1.1 static void TestNamespaceParameterUsingEnumerate()
2302           {
2303               _CallEnumerate("test/cpp", "x_numberWorld", MI_FALSE);
2304           
2305               // validate response
2306               UT_ASSERT(s_results.size() == 1);
2307               UT_ASSERT_EQUAL(s_results[0], MI_RESULT_OK);
2308           
2309               UT_ASSERT_EQUAL(s_instances.size(), 1);
2310           
2311               MI_Value value;
2312               MI_Type type;
2313               MI_Uint32 flags = 0;
2314           
2315               UT_ASSERT_EQUAL(MI_RESULT_OK, MI_Instance_GetElement(s_instances[0]->instance, T("ns"), &value, &type, &flags, 0));
2316               UT_ASSERT_EQUAL(type, MI_STRING);
2317               UT_ASSERT(!(flags & MI_FLAG_NULL));
2318               UT_ASSERT(value.string == ut::String(T("test/cpp")) || value.string == ut::String(T("oop/requestor/test/cpp")));
2319           }
2320           
2321           static void _RunAllTestsWithNSPrefix(const char* nsPrefix)
2322 mike  1.1 {
2323               s_nsPrefix = nsPrefix;
2324           
2325               // get
2326               UT_TEST(TestGetInstanceSmallNumber);
2327               UT_TEST(TestGetInstanceSmallNumberNotFound);
2328               UT_TEST(TestGetInstanceInvalidNameSpace);
2329               UT_TEST(TestGetInstanceHugeNumberWithEmbeddedInstance);
2330               UT_TEST(TestGetInstancePersonWithEmbeddedInstance_c);
2331               UT_TEST(TestGetInstancePersonWithEmbeddedInstance_cpp);
2332           
2333           
2334               // enumerate
2335               UT_TEST(TestEnumerateHugeNumber);
2336               UT_TEST(TestEnumerateNumberShallow_NotFound);
2337               UT_TEST(TestEnumerateNumberDeep);       // note! provider has two modes of enumeration to excersize both
2338               UT_TEST(TestEnumerateNumberDeep);       // sync and async APIs, so we have to call test twice
2339               UT_TEST(TestEnumerateHugeNumberConformsToProfile);       // enumerate assoc class
2340               UT_TEST(TestEnumerateInvalidClass);
2341               UT_TEST(TestEnumerateFailedToLoadProvider_c);
2342               UT_TEST(TestEnumerateFailedToLoadProvider_cpp);
2343 mike  1.1     UT_TEST(TestEnumerateX_Number1000001);
2344           
2345           
2346           
2347               // invoke
2348               UT_TEST(TestInvokeSmallNumberSpellNumber0);
2349               UT_TEST(TestInvokeSmallNumberSpellNumber120394);
2350               UT_TEST(TestInvokeSmallNumberGetFactors_NotFound);
2351               UT_TEST(TestInvokeSmallNumberGetFactors_InvalidParameter);
2352               UT_TEST(TestInvokeSmallNumber_InvalidFn);
2353               UT_TEST(TestInvokeSmallNumberGetFactors135);
2354               UT_TEST(TestInvokeHugeNumberSpellMagnitude);
2355               UT_TEST(TestInvokeHugeNumberTestEmbedded);
2356               UT_TEST(TestInvokePersonTestEmbeddedInstanceReturnKey20100609_c);
2357               UT_TEST(TestInvokePersonTestEmbeddedInstanceReturnKey20100609_cpp);
2358               UT_TEST(TestInvokePersonTestEmbeddedObjectReturnKey20100609_c);
2359               UT_TEST(TestInvokePersonTestEmbeddedObjectReturnKey20100609_cpp);
2360               UT_TEST(TestInvokePersonTestEmbeddedParameters_c);
2361               UT_TEST(TestInvokePersonTestEmbeddedParameters_cpp);
2362           
2363           
2364 mike  1.1     // associators
2365               // happy pass (return some instances)
2366               UT_TEST(TestAssociatorsFriends);
2367               UT_TEST(TestAssociatorsNumProv_AllOfWorld);
2368               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByAssocClass);
2369               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByResultClass);
2370               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByRole);
2371               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByResultRole);
2372           
2373               UT_TEST(TestAssociatorsNumProv_AllNumbersOfWorld);
2374               UT_TEST(TestAssociatorsNumProv_AllHugeNumbersOfWorld);
2375               UT_TEST(TestAssociatorsNumProv_AllEvenNumbersOfWorld);
2376               UT_TEST(TestAssociatorsNumProv_AllOddNumbersOfWorld);
2377           
2378               UT_TEST(TestAssociatorsNumProv_AllProfile);
2379               UT_TEST(TestAssociatorsNumProv_AllOfSmallNumber);
2380               UT_TEST(TestAssociatorsNumProv_AllOfSmallNumberByRoleNumber);
2381               UT_TEST(TestAssociatorsNumProv_AllOfSmallNumberByRoleHalf);
2382               UT_TEST(TestAssociatorsNumProv_AllOfSmallNumberByAssocClassHalves);
2383               UT_TEST(TestAssociatorsNumProv_DoubleZeroInstancesOfSmallNumberByAssocClassHalves);
2384               UT_TEST(TestAssociatorsNumProv_AllOfSmallNumberByAllFilters);
2385 mike  1.1 
2386               // empty pass (return ok/0 instances)
2387               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByRoleRRole);
2388           
2389               // negative (return error back)
2390               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByInvalidAssocClass);
2391               UT_TEST(TestAssociatorsNumProv_ProfileOfWorldByInvalidResultClass);
2392               UT_TEST(TestAssociatorsNumProv_InvalidNameSpace);
2393               UT_TEST(TestAssociatorsNumProv_NoInstance);
2394           
2395               // references
2396               UT_TEST(TestReferencesNumProv_ProfileByAssocClass);
2397           
2398           
2399               // bug 26591
2400               UT_TEST(TestNamespaceParameterUsingInvoke);
2401               UT_TEST(TestNamespaceParameterUsingEnumerate);
2402           }
2403           
2404           static void AllProviderTests()
2405           {
2406 mike  1.1     Sock_Start();
2407               StartServerAndConnect(true, _Callback, &s_protocol);
2408           
2409               // run tests with no prefix, so providers are hosted 'in-proc'
2410               _RunAllTestsWithNSPrefix("");
2411           
2412               // run tests with 'requestor' prefix, so providers are hosted 'as-requestor' in separate process
2413               _RunAllTestsWithNSPrefix("oop/requestor/");
2414           
2415           #if defined(CONFIG_POSIX)
2416               /* Special test for oop:  terminate running agent and verify that server returns error 'FAILED' for this request
2417                   and can restart agent for next request */
2418               s_nsPrefix = "oop/requestor/";
2419               UT_TEST(TestInvokeTerminate);
2420               UT_TEST(TestGetInstanceSmallNumber);
2421           #endif
2422           
2423               // WSMAN test (it also needs server running);
2424               // to speed up test execution, server started only once
2425               // and all tests that require server are called from this file
2426               WSMAN_Tests_With_Server();
2427 mike  1.1 
2428               StopServerAndDisconnect(&s_protocol);
2429               Sock_Stop();
2430           }
2431           
2432           UT_ENTRY_POINT(AllProviderTests);

ViewCVS 0.9.2