Exemple #1
0
/* 
   testGetInstance of the OS provider. 
*/
void OSTestClient::testGetInstance (CIMClient &client,
                                    Boolean verboseTest)
{
  CIMObjectPath  getTestRef;    //  will need an instance for Get
  
  try
    {
      Boolean deepInheritance = true;
      Boolean localOnly = true;
   
      testLog("OS Provider Test GetInstance");
     
      // first do an EnumerateInstanceNames - select one to play with 
      // doesn't hurt to keep testing enumerate :-)
 
      Array<CIMObjectPath> cimReferences = 
	    client.enumerateInstanceNames(NAMESPACE, CLASSNAME);
 
      Uint32 numberInstances = cimReferences.size();
      if (verboseTest)
	cout << numberInstances << " instances of PG_OperatingSystem" <<endl;

      for (Uint32 i = 0; i < cimReferences.size(); i++)
      {
         CIMName className = cimReferences[i].getClassName();
         if (!className.equal (CLASSNAME))
         {
	    errorExit("EnumInstanceNames failed - wrong class");
	 }
         // add in some content checks on the keys returned

         _validateKeys(cimReferences[i], verboseTest);

         // let's just take the first instance found
         getTestRef = cimReferences[i];

    }   // end for looping through instances
    
    if (verboseTest)
       cout<<"EnumerateInstanceNames for Get Instance completed"<<endl; 
   
    // now call GetInstance with the appropriate references
    CIMInstance getTestInstance = client.getInstance(NAMESPACE,
                                                     getTestRef);

    // now validate the properties returned
    _validateProperties(getTestInstance, verboseTest);

    testLog("OS Provider Test Get Instance passed ");
    }  // end try 
   
    catch(Exception& e)
    {
      errorExit(e.getMessage());
    }
}
/*
   testEnumerateInstances of the NIS provider.
*/
void NISTestClient::testEnumerateInstances(
    CIMClient &client,
    Boolean verboseTest)
{
    try
    {
        Boolean deepInheritance = true;
        Boolean localOnly = true;
        Boolean includeQualifiers = false;
        Boolean includeClassOrigin = false;
        Uint32 numberInstances;

        testLog("NIS Provider Test EnumerateInstances");

        Array<CIMInstance> cimNInstances = client.enumerateInstances(
            NAMESPACE,
            CLASS_NAME,
            deepInheritance,
            localOnly,
            includeQualifiers,
            includeClassOrigin);

        numberInstances = cimNInstances.size();
        if (verboseTest)
            cout << numberInstances << " instances of PG_NISServerService" <<
                endl;

        for (Uint32 i = 0; i < cimNInstances.size(); i++)
        {
            CIMObjectPath instanceRef = cimNInstances[i].getPath ();
            if (verboseTest)
                cout << "Instance ClassName is " <<
                    instanceRef.getClassName().getString() << endl;
            if(!instanceRef.getClassName().equal(CLASS_NAME))
            {
                errorExit("EnumInstances failed");
            }

            // now validate the properties
            _validateProperties(cimNInstances[i], verboseTest);
        }       // end for looping through instances

        testLog("NIS Provider Test EnumInstances Passed");
    }
    catch(Exception& e)
    {
        errorExit(e.getMessage());
    }
}