📄 testobjectnormalizer.cpp
字号:
// complete object path CIMObjectPath cimObjectPath; cimObjectPath.setClassName(cimInstance.getClassName()); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("property1", CIMValue(Uint32(1)))); keys.append(CIMKeyBinding("property2", CIMValue(String("Test Instance #005b")))); keys.append(CIMKeyBinding("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); // slightly differnt value than property. who wins? cimObjectPath.setKeyBindings(keys); cimInstance.setPath(cimObjectPath); _stopwatch.start(); CIMInstance normalizedInstance = normalizer.processInstance(cimInstance); _stopwatch.stop(); if(verbose) { cout << normalizedInstance.getPath().toString() << endl; XmlWriter::printInstanceElement(normalizedInstance); } PRINT("*** " << _stopwatch.getElapsed() << " milliseconds.");}// include with properties containing class originvoid Test005d(void){ PRINT("Test005d"); _stopwatch.reset(); Boolean includeQualifiers = true; Boolean includeClassOrigin = false; CIMClass cimClass = repository->getClass( "test_namespace", "ClassC", true, includeClassOrigin, CIMPropertyList()); AutoPtr<NormalizerContext> nullContext(0); ObjectNormalizer normalizer( cimClass, includeQualifiers, includeClassOrigin, CIMNamespaceName("test_namespace"), nullContext); CIMInstance cimInstance(cimClass.getClassName()); // all properties cimInstance.addProperty(CIMProperty("property1", CIMValue(Uint32(1)))); cimInstance.addProperty(CIMProperty("property2", CIMValue(String("Test Instance #005c")))); cimInstance.addProperty(CIMProperty("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); cimInstance.addProperty(CIMProperty("property4", CIMValue(String("Pegasus TestObjectNormalizer")))); // complete object path CIMObjectPath cimObjectPath; cimObjectPath.setClassName(cimInstance.getClassName()); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("property1", CIMValue(Uint32(1)))); keys.append(CIMKeyBinding("property2", CIMValue(String("Test Instance #005b")))); keys.append(CIMKeyBinding("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); // slightly differnt value than property. who wins? cimObjectPath.setKeyBindings(keys); cimInstance.setPath(cimObjectPath); _stopwatch.start(); CIMInstance normalizedInstance = normalizer.processInstance(cimInstance); _stopwatch.stop(); if(verbose) { cout << normalizedInstance.getPath().toString() << endl; XmlWriter::printInstanceElement(normalizedInstance); } PRINT("*** " << _stopwatch.getElapsed() << " milliseconds.");}//// Test100a()//void Test100a(void){ PRINT("Test100a"); _stopwatch.reset(); Boolean includeQualifiers = false; Boolean includeClassOrigin = false; CIMClass cimClass = repository->getClass( "test_namespace", "ClassC", true, includeClassOrigin, CIMPropertyList()); AutoPtr<NormalizerContext> nullContext(0); ObjectNormalizer normalizer( cimClass, includeQualifiers, includeClassOrigin, CIMNamespaceName("test_namespace"), nullContext); for(Uint32 i = 0, n = 100; i < n; i++) { CIMObjectPath cimObjectPath; cimObjectPath.setClassName(cimClass.getClassName()); // simple keys Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("property1", CIMValue(Uint32(1)))); keys.append(CIMKeyBinding("property2", CIMValue(String("Test Instance #005b")))); keys.append(CIMKeyBinding("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); cimObjectPath.setKeyBindings(keys); _stopwatch.start(); CIMObjectPath normalizedObjectPath = normalizer.processInstanceObjectPath(cimObjectPath); _stopwatch.stop(); PRINT(normalizedObjectPath.toString()); } PRINT("*** " << _stopwatch.getElapsed() << " milliseconds.");}// large instance set without qualifiers and without class originvoid Test101a(void){ PRINT("Test101a"); _stopwatch.reset(); Boolean includeQualifiers = false; Boolean includeClassOrigin = false; CIMClass cimClass = repository->getClass( "test_namespace", "ClassC", true, includeClassOrigin, CIMPropertyList()); AutoPtr<NormalizerContext> nullContext(0); ObjectNormalizer normalizer( cimClass, includeQualifiers, includeClassOrigin, CIMNamespaceName("test_namespace"), nullContext); for(Uint32 i = 0, n = 1000; i < n; i++) { CIMInstance cimInstance(cimClass.getClassName()); // all properties cimInstance.addProperty(CIMProperty("property1", CIMValue(Uint32(i)))); cimInstance.addProperty(CIMProperty("property2", CIMValue(String("Test Instance #101a")))); cimInstance.addProperty(CIMProperty("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); cimInstance.addProperty(CIMProperty("property4", CIMValue(String("Pegasus TestObjectNormalizer")))); // complete object path CIMObjectPath cimObjectPath; cimObjectPath.setClassName(cimInstance.getClassName()); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("property1", CIMValue(Uint32(i)))); keys.append(CIMKeyBinding("property2", CIMValue(String("Test Instance #101a")))); keys.append(CIMKeyBinding("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); // slightly differnt value than property. who wins? cimObjectPath.setKeyBindings(keys); cimInstance.setPath(cimObjectPath); _stopwatch.start(); CIMInstance normalizedInstance = normalizer.processInstance(cimInstance); _stopwatch.stop(); if(verbose) { cout << normalizedInstance.getPath().toString() << endl; XmlWriter::printInstanceElement(normalizedInstance); } } PRINT("*** " << _stopwatch.getElapsed() << " milliseconds.")}// large instance set without qualifiers and with class originvoid Test101b(void){ PRINT("Test101b"); _stopwatch.reset(); Boolean includeQualifiers = false; Boolean includeClassOrigin = true; CIMClass cimClass = repository->getClass( "test_namespace", "ClassC", true, includeClassOrigin, CIMPropertyList()); AutoPtr<NormalizerContext> nullContext(0); ObjectNormalizer normalizer( cimClass, includeQualifiers, includeClassOrigin, CIMNamespaceName("test_namespace"), nullContext); for(Uint32 i = 0, n = 1000; i < n; i++) { CIMInstance cimInstance(cimClass.getClassName()); // only populate keys, let the normalizer do the rest cimInstance.addProperty(CIMProperty("property1", CIMValue(Uint32(i)))); cimInstance.addProperty(CIMProperty("property2", CIMValue(String("Test Instance #101b")))); cimInstance.addProperty(CIMProperty("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); cimInstance.addProperty(CIMProperty("property4", CIMValue(String("Pegasus TestObjectNormalizer")))); // complete object path CIMObjectPath cimObjectPath; cimObjectPath.setClassName(cimInstance.getClassName()); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("property1", CIMValue(Uint32(i)))); keys.append(CIMKeyBinding("property2", CIMValue(String("Test Instance #101b")))); keys.append(CIMKeyBinding("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); // slightly differnt value than property. who wins? cimObjectPath.setKeyBindings(keys); cimInstance.setPath(cimObjectPath); _stopwatch.start(); CIMInstance normalizedInstance = normalizer.processInstance(cimInstance); _stopwatch.stop(); if(verbose) { cout << normalizedInstance.getPath().toString() << endl; XmlWriter::printInstanceElement(normalizedInstance); } } PRINT("*** " << _stopwatch.getElapsed() << " milliseconds.");}// large instance set with qualifiers and with class originvoid Test101c(void){ PRINT("Test101c"); _stopwatch.reset(); Boolean includeQualifiers = true; Boolean includeClassOrigin = true; CIMClass cimClass = repository->getClass( "test_namespace", "ClassC", true, includeClassOrigin, CIMPropertyList()); AutoPtr<NormalizerContext> nullContext(0); ObjectNormalizer normalizer( cimClass, includeQualifiers, includeClassOrigin, CIMNamespaceName("test_namespace"), nullContext); for(Uint32 i = 0, n = 1000; i < n; i++) { CIMInstance cimInstance(cimClass.getClassName()); // only populate keys, let the normalizer do the rest cimInstance.addProperty(CIMProperty("property1", CIMValue(Uint32(i)))); cimInstance.addProperty(CIMProperty("property2", CIMValue(String("Test Instance #101b")))); cimInstance.addProperty(CIMProperty("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); cimInstance.addProperty(CIMProperty("property4", CIMValue(String("Pegasus TestObjectNormalizer")))); // complete object path CIMObjectPath cimObjectPath; cimObjectPath.setClassName(cimInstance.getClassName()); Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding("property1", CIMValue(Uint32(i)))); keys.append(CIMKeyBinding("property2", CIMValue(String("Test Instance #101c")))); keys.append(CIMKeyBinding("property3", CIMValue(CIMDateTime::getCurrentDateTime()))); // slightly differnt value than property. who wins? cimObjectPath.setKeyBindings(keys); cimInstance.setPath(cimObjectPath); _stopwatch.start(); CIMInstance normalizedInstance = normalizer.processInstance(cimInstance); _stopwatch.stop(); if(verbose) { cout << normalizedInstance.getPath().toString() << endl; XmlWriter::printInstanceElement(normalizedInstance); } } PRINT("*** " << _stopwatch.getElapsed() << " milliseconds.");}int main(int argc, char** argv){ verbose = getenv("PEGASUS_TEST_VERBOSE"); repository = new LocalRepository(); if(verbose) { CIMClass cimClass = repository->getClass( "test_namespace", "ClassC", true, true, CIMPropertyList()); cout << "using the following classes for tests:" << endl; XmlWriter::printClassElement(cimClass); } try { // basic object tests Test001a(); Test001b(); // object path failures Test002a(); Test002b(); Test002c(); Test002d(); // object path successes Test003a(); Test003b(); Test003c(); Test003d(); Test003e(); // instance object failures Test004a(); Test004b(); // instance object successes Test005a(); Test005b(); Test005c(); Test005d(); // object path processing performance tests Test100a(); // instance processing performance tests Test101a(); Test101b(); Test101c(); } catch(CIMException & e) { cout << "CIMException: " << e.getCode() << " " << e.getMessage() << endl; return(1); } catch(Exception & e) { cout << "Exception: " << e.getMessage() << endl; return(1); } catch(...) { cout << "unknown exception" << endl; return(1); } cout << argv[0] << " +++++ passed all tests" << endl; delete repository; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -