⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g11ntest.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                   if (n == PEG_NOT_FOUND)                   {                      throw;                   }                   if (i == 0)                   {                      // Since we don't know the text of the server message in each                      // language, save the message on the first request                      expectedMsg = ce.getMessage();                      if (verboseTest)                          cout << "Note: Expecting message = " << expectedMsg                               << " from the server" << endl;              // Sanity check to make sure that the exception does not just have              // the class name (see bug 1686)              MYASSERT(expectedMsg.size() != CLASSNAME.getString().size());                   }                   // Verify the message and the content languages returned//                 if (verboseTest)//                    cout << "Checking the server error message." << endl;                   MYASSERT(expectedMsg == ce.getMessage());                   MYASSERT(expectedCL == client.getResponseContentLanguages());                   MYASSERT(expectedCL == ce.getContentLanguages());                }                else                {                   // Didn't get the expected error for "class not found"                   throw;                }            }  // end catch            //            // TEST 2 - Enumerate instances of the sample classes using different            // languages.            //            // Enumerate instances of the sample classes, alternating the Accept-Language            // used among the languages supported by the LocalizedProvider.  When            // multiple instance of this program are run simultaneously, this test            // will exercise multi-language support in the server.            //        switch (i % 3)            {               case 0://                 if (verboseTest)//                     cout << "Sending the enumerate instance request " << i <<//                              ". Lang = " << acceptLangsDE.toString() << endl;                   EnumerateSampleInstances(                                           client,                                           acceptLangsDE,                                           CL_DE,                                           expectedDEString,                                           false); // don't get too verbose                   break;               case 1://                 if (verboseTest)//                     cout << "Sending the enumerate instance request " << i <<//                              ". Lang = " << acceptLangsFR.toString() << endl;                   EnumerateSampleInstances(                                           client,                                           acceptLangsFR,                                           CL_FR,                                           expectedFRString,                                           false); // don't get too verbose                   break;               case 2://                 if (verboseTest)//                     cout << "Sending the enumerate instance request " << i <<//                              ". Lang = " << acceptLangsES.toString() << endl;                   EnumerateSampleInstances(                                           client,                                           acceptLangsES,                                           CL_ES,                                           expectedESString,                                           false); // don't get too verbose                   break;            }        } // endfor    }    catch (InvalidAcceptLanguageHeader& ialh)    {        PEGASUS_STD(cerr) << "Invalid lang parameter was entered: "            << ialh.getMessage() << PEGASUS_STD(endl);        throw;    }    catch (InvalidContentLanguageHeader& iclh)    {        PEGASUS_STD(cerr) << "Invalid expectlang parameter was entered: "            << iclh.getMessage() << PEGASUS_STD(endl);        throw;    }    catch(Exception& e)    {        PEGASUS_STD(cerr) << "Error in TestServerMessages: "            << e.getMessage() << PEGASUS_STD(endl);        throw;    }}/*   Builds a filter or handler object path*/static CIMObjectPath buildFilterOrHandlerPath    (const CIMName & className,     const String & name){    CIMObjectPath path;    Array <CIMKeyBinding> keyBindings;    keyBindings.append (CIMKeyBinding ("SystemCreationClassName",        System::getSystemCreationClassName (), CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("SystemName",        System::getFullyQualifiedHostName (), CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("CreationClassName",        className.getString(), CIMKeyBinding::STRING));    keyBindings.append (CIMKeyBinding ("Name", name,        CIMKeyBinding::STRING));    path.setClassName (className);    path.setKeyBindings (keyBindings);    return path;}/*   Builds a subscription object path*/static CIMObjectPath buildSubscriptionObjectPath    (const CIMObjectPath & filterPath,     const CIMObjectPath & handlerPath){    CIMObjectPath path;    Array <CIMKeyBinding> keyBindings;    keyBindings.append (CIMKeyBinding ("Filter", filterPath.toString (),        CIMKeyBinding::REFERENCE));    keyBindings.append (CIMKeyBinding ("Handler", handlerPath.toString (),        CIMKeyBinding::REFERENCE));    path.setClassName (PEGASUS_CLASSNAME_INDSUBSCRIPTION);    path.setKeyBindings (keyBindings);    return path;}/*   Creates the subscriptions, filters, and handlers for the indication tests*/static void createSubscriptions(CIMClient& client,                CIMObjectPath & g11ntestHandlerRef,                CIMObjectPath & providerHandlerRef,                CIMObjectPath & filterRef,                CIMObjectPath & g11ntestSubscriptionRef,                CIMObjectPath & providerSubscriptionRef,                String & listenerDest,                Boolean skipListener,                Boolean verboseTest){  const CIMNamespaceName SAMPLE_NAMESPACE = CIMNamespaceName ("root/SampleProvider");// Interop namespace used with PEGASUS_NAMESPACENAME_INTEROP in Constants.h  const CIMName METHOD = CIMName("getIndicationResult");  const CIMObjectPath REFERENCE = CIMObjectPath("Sample_LocalizedProviderClass.Identifier=0");  try  {    //---------------------------------------------------------    // Build the paths to the handlers, filter, and subscription    //---------------------------------------------------------    // The handler that will have program as the destination    CIMObjectPath g11ntestHandlerPath = buildFilterOrHandlerPath        (PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "g11ntest_Handler");    // The handler that will have LocalizedProvider as the destination    CIMObjectPath providerHandlerPath = buildFilterOrHandlerPath        (PEGASUS_CLASSNAME_INDHANDLER_CIMXML, "provider_Handler");    // The filter    CIMObjectPath filterPath = buildFilterOrHandlerPath        (PEGASUS_CLASSNAME_INDFILTER, "g11ntest_Filter");    // The subscription that will have this program as the destination    CIMObjectPath g11ntestSubscriptionPath = buildSubscriptionObjectPath        (filterPath, g11ntestHandlerPath);    // The subscription that will have LocalizedProvider as the destination    CIMObjectPath providerSubscriptionPath = buildSubscriptionObjectPath        (filterPath, providerHandlerPath);    // Need to delete the old subscription and handler that have this program as the    // destination.  This is done in case the port changed since the last time.    if (verboseTest)      cout << "Deleting the old subscription" << endl;    try    {      client.deleteInstance(PEGASUS_NAMESPACENAME_INTEROP, CIMObjectPath(g11ntestSubscriptionPath));    }    catch (CIMException & ce)    {      if (ce.getCode() != CIM_ERR_NOT_FOUND)      {        throw;      }    }    if (verboseTest)      cout << "Deleting the old handler" << endl;    try    {      client.deleteInstance(PEGASUS_NAMESPACENAME_INTEROP, CIMObjectPath(g11ntestHandlerPath));    }    catch (CIMException & ce)    {      if (ce.getCode() != CIM_ERR_NOT_FOUND)      {        throw;      }    }    // Create the new handler instance with this program as the destination    if (verboseTest)      cout << "Creating the handlers" << endl;    if (!skipListener)    {      CIMInstance g11ntestHandlerInstance(PEGASUS_CLASSNAME_INDHANDLER_CIMXML);      g11ntestHandlerInstance.addProperty(CIMProperty (CIMName("SystemCreationClassName"),          System::getSystemCreationClassName ()));      g11ntestHandlerInstance.addProperty(CIMProperty(CIMName ("SystemName"),          System::getFullyQualifiedHostName ()));      g11ntestHandlerInstance.addProperty(CIMProperty(CIMName ("CreationClassName"),                          PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString()));      g11ntestHandlerInstance.addProperty(CIMProperty(CIMName ("Name"),                              String("g11ntest_Handler")));      g11ntestHandlerInstance.addProperty(CIMProperty(CIMName ("Destination"), listenerDest));      g11ntestHandlerRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, g11ntestHandlerInstance);    }    // Create the new handler instance with LocalizedProvider as the destination    CIMInstance providerHandlerInstance(PEGASUS_CLASSNAME_INDHANDLER_CIMXML);    providerHandlerInstance.addProperty(CIMProperty (CIMName("SystemCreationClassName"),        System::getSystemCreationClassName ()));    providerHandlerInstance.addProperty(CIMProperty(CIMName ("SystemName"),        System::getFullyQualifiedHostName ()));    providerHandlerInstance.addProperty(CIMProperty(CIMName ("CreationClassName"),        PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString()));    providerHandlerInstance.addProperty(CIMProperty(CIMName ("Name"),        String("provider_Handler")));    providerHandlerInstance.addProperty(CIMProperty(CIMName ("Destination"),        String("http://localhost:5988/CIMListener/localizedprovider")));    try    {      providerHandlerRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, providerHandlerInstance);    }    catch (CIMException& ce)    {      if (ce.getCode() != CIM_ERR_ALREADY_EXISTS)        throw;      providerHandlerRef = CIMObjectPath(providerHandlerPath);    }    // Create the filter instance    if (verboseTest)      cout << "Creating the filter" << endl;    CIMInstance filterInstance(PEGASUS_CLASSNAME_INDFILTER);    filterInstance.addProperty(CIMProperty (CIMName ("SystemCreationClassName"),        System::getSystemCreationClassName ()));    filterInstance.addProperty(CIMProperty(CIMName ("SystemName"),        System::getFullyQualifiedHostName ()));    filterInstance.addProperty(CIMProperty(CIMName ("CreationClassName"),        PEGASUS_CLASSNAME_INDFILTER.getString()));    filterInstance.addProperty(CIMProperty(CIMName ("Name"),        String("g11ntest_Filter")));    filterInstance.addProperty (CIMProperty(CIMName ("SourceNamespace"),        String("root/SampleProvider")));    filterInstance.addProperty (CIMProperty(CIMName ("Query"),    String("SELECT * FROM LocalizedProvider_TestIndication")));    filterInstance.addProperty (CIMProperty(CIMName ("QueryLanguage"),        String("WQL")));    try    {      filterRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP, filterInstance);    }    catch (CIMException& ce)    {      if (ce.getCode() != CIM_ERR_ALREADY_EXISTS)        throw;      filterRef = CIMObjectPath(filterPath);    }    // Create the subscription    if (verboseTest)      cout << "Creating the subscription" << endl;    if (!skipListener)    {      // The subscription with this program as the destination      CIMInstance g11ntestSubscriptionInstance(PEGASUS_CLASSNAME_INDSUBSCRIPTION);      g11ntestSubscriptionInstance.addProperty(CIMProperty(CIMName ("Filter"),                   filterRef, 0, PEGASUS_CLASSNAME_INDFILTER));      g11ntestSubscriptionInstance.addProperty(CIMProperty(CIMName ("Handler"),                   g11ntestHandlerRef, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML));      g11ntestSubscriptionInstance.addProperty (CIMProperty                (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));      try    {      g11ntestSubscriptionRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP,                              g11ntestSubscriptionInstance);    }      catch (CIMException& ce)    {      if (ce.getCode() != CIM_ERR_ALREADY_EXISTS)        throw;      g11ntestSubscriptionRef = CIMObjectPath(g11ntestSubscriptionPath);    }    }    // The subscription with LocalizedProvider as the destination    CIMInstance providerSubscriptionInstance(PEGASUS_CLASSNAME_INDSUBSCRIPTION);    providerSubscriptionInstance.addProperty(CIMProperty(CIMName ("Filter"),        filterRef, 0, PEGASUS_CLASSNAME_INDFILTER));    providerSubscriptionInstance.addProperty(CIMProperty(CIMName ("Handler"),        providerHandlerRef, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML));    providerSubscriptionInstance.addProperty (CIMProperty        (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2)));    try    {        providerSubscriptionRef = client.createInstance(PEGASUS_NAMESPACENAME_INTEROP,            providerSubscriptionInstance);    }    catch (CIMException& ce)    {        if (ce.getCode() != CIM_ERR_ALREADY_EXISTS)            throw;        providerSubscriptionRef = CIMObjectPath(providerSubscriptionPath);    }  }  catch (Exception& e)  {      PEGASUS_STD(cerr) << "Error in createSubscriptions " <<          e.getMessage() << PEGASUS_STD(endl);      throw;  }}/*   Tests the globalization support for indications.*/static void TestLocalizedIndications( CIMClient& client,                

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -