Boolean _getPropertyList(QueryExpression& qe,
                         Array<CIMInstance>& _instances,
                         CIMNamespaceName ns,
                         String testOption,
                         String lang)
{
    if(testOption == String::EMPTY || testOption == "3")
    {
        for(Uint32 j = 0; j < _instances.size(); j++)
        {
            cout << endl << lang << " ========Get Property List Results=======" << endl;
            cout << qe.getQuery() << endl;

            try
            {
                cout << endl << "Get Class Path List" << endl;
                Array<CIMObjectPath> fromPaths = qe.getClassPathList();
                for (Uint32 k = 0; k < fromPaths.size(); k++)
                {
                    cout << "-----" << fromPaths[k].toString() << endl;
                }
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

            CIMName className = _instances[j].getClassName();
            CIMObjectPath classPath (String::EMPTY,
                                     ns,
                                     className);

            CIMPropertyList propList;
            try
            {
                cout << "Property List for the FROM class" << endl;
                propList = qe.getPropertyList();
                _printPropertyList(propList);
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

            try
            {
                cout << "Property List for " << className.getString() << endl;
                propList = qe.getPropertyList(classPath);
                _printPropertyList(propList);
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

            try
            {
                propList.clear();
                cout << "SELECT Property List for the FROM class" << endl;
                propList = qe.getSelectPropertyList();
                _printPropertyList(propList);
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

            try
            {
                propList.clear();
                cout << "SELECT Property List for " << className.getString() << endl;
                propList = qe.getSelectPropertyList(classPath);
                _printPropertyList(propList);
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

            try
            {
                propList.clear();
                cout << "WHERE Property List for the FROM class" << endl;
                propList = qe.getWherePropertyList();
                _printPropertyList(propList);
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }

            try
            {
                propList.clear();
                cout << "WHERE Property List for " << className.getString() << endl;
                propList = qe.getWherePropertyList(classPath);
                _printPropertyList(propList);
            }
            catch(Exception& e) {
                cout << "-----" << e.getMessage() << endl;
            }
            catch(...) {
                cout << "Unknown Exception" << endl;
            }
        }
    }

    return true;
}
Exemple #2
0
// ===========================================================================
// Main
// Options:
//  Test or show - TBD
// ===========================================================================
int main()
{

  //verbose = getenv("PEGASUS_TEST_VERBOSE");
  verbose = "test";
  cout << "+++++ Testing AssociationTest Provider" << endl;

  // Build array of classes
  Array<CIMName> Classes;
  Classes.append("TST_ClassA");
  Classes.append("TST_ClassB");
  Classes.append("TST_ClassC");
  Classes.append("TST_ClassD");
  Classes.append("TSTDY_ClassA");
  Classes.append("TSTDY_ClassB");
  Classes.append("TSTDY_ClassC");
  Classes.append("TSTDY_ClassD");



  Array<CIMName> AssocClasses;
  AssocClasses.append("TST_AssocI1");
  AssocClasses.append("TST_AssocI2");
  AssocClasses.append("TST_AssocI3");
  AssocClasses.append("TST_AssocI4");
  AssocClasses.append("TST_AssocI5");
  AssocClasses.append("TST_AssocI6");

  AssocClasses.append("TST_AssocNI1");
  AssocClasses.append("TST_AssocNI2");
  AssocClasses.append("TST_AssocNI3");
  AssocClasses.append("TST_AssocNI4");
  AssocClasses.append("TST_AssocNI5");
  AssocClasses.append("TST_AssocNI6");

  // Connect
  try
  {
    c.connect (HOST, PORTNUMBER, String::EMPTY, String::EMPTY);
  }
  catch (Exception& e)
  {
    errorExit(e);
  }

  int rc;
  // Start by confirming the existence of the classes, etc.
  if ((rc = testClassList(Classes)) != 0) return rc;
  if ((rc = testClassList(AssocClasses)) != 0) return rc;
  // Now start the association tests.
  // Reference Names Test

  // Class A Refrence Names Test


  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName(), "", 2));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName(), "to", 2));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName(), "from", 2));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI1"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI1"), "to", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI1"), "from", 1));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI3"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI3"), "to", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI3"), "from", 1));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI5"), "", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI5"), "to", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA"),CIMName("TST_AssocI5"), "from", 0));

  // Class B Refrence Names Test
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName(), "", 4));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName(), "to", 2));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName(), "from", 4));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI2"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI2"), "to", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI2"), "from", 1));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI2"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI2"), "to", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI2"), "from", 1));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI5"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI5"), "to", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassB"),CIMName("TST_AssocI5"), "from", 1));


  // TODO TestReferences for class c and class d

  // testRefernceName Instances from static store
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName(), "", 2));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName(), "to", 2));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName(), "from", 2));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI1"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI1"), "to", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI1"), "from", 1));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI3"), "", 1));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI3"), "to", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI3"), "from", 1));

  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI5"), "", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI5"), "to", 0));
  ASRT(testReferenceNames(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName("TST_AssocI5"), "from", 0));

  // Lets make the previous a common test between ref and ref names.

  // References
  // Limited test since we learned most in the previous test of reference names
  CIMPropertyList NullPL;
  NullPL.clear();

  CIMPropertyList emptyPL;

  CIMPropertyList fullPL;
  Array<CIMName> fullPLinput;
  fullPLinput.append("name");
  fullPL.set(fullPLinput);


  CIMPropertyList errorPL ;
  Array<CIMName> errorPLinput;
  errorPLinput.append("junk");
  errorPL.set(errorPLinput);

  ASRT(testReferences(CIMObjectPath("TST_ClassA"),CIMName(), "", emptyPL,2));

  ASRT(testReferences(CIMObjectPath("TST_ClassA.name=\"InstanceA1\""),CIMName(), "", fullPL,2));

  // Testing associators and and associator names functions.

  ASRT(testAssocNames(CIMObjectPath("TST_ClassA"),CIMName(),CIMName(),"", "", 3));

  cout << "+++++ passed all tests" << endl;
  return 0;
}