summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkarl <karl>2005-08-17 20:43:08 +0000
committerkarl <karl>2005-08-17 20:43:08 +0000
commit8aaf4925918dbbe8d91bea0ed764a457005f0977 (patch)
treef3f052a70ffbcce28822f78286162ddf7ab37c2b /src
parent7e36ba2bcd84b5b4f1bee20f171a89713580636b (diff)
downloadtog-pegasus-8aaf4925918dbbe8d91bea0ed764a457005f0977.zip
tog-pegasus-8aaf4925918dbbe8d91bea0ed764a457005f0977.tar.gz
tog-pegasus-8aaf4925918dbbe8d91bea0ed764a457005f0977.tar.xz
BUG#: 2118
TITLE: Interopo Ignores keys DESCRIPTION: Added tests to InteropProvider and interop tests on getInstance and modifyInstance to assure we only pass correct requests.
Diffstat (limited to 'src')
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp218
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/InteropProvider.h10
-rw-r--r--src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp275
3 files changed, 368 insertions, 135 deletions
diff --git a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
index 0b43773..482f442 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
+++ b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.cpp
@@ -139,7 +139,13 @@ PEGASUS_NAMESPACE_BEGIN
const char * thisProvider = "InteropProvider";
-
+// This Mutex serializes access to the instance change CIM requests. Keeps from mixing
+// instance creates, modifications, and deletes. This keeps the provider from
+// simultaneously execute creates, modifications, and deletes of instances. While
+// these operations are largely protected by the locking mechanisms of the
+// repository this mutex guarantees that the provider will not simultaneously
+// execute the instance change operations.
+Mutex changeControlMutex;
/**
The constants representing the class names we process
*/
@@ -345,7 +351,7 @@ void _isNamespaceAllowed(const CIMObjectPath & path)
// return;
if (path.getNameSpace().getString() != PEGASUS_NAMESPACENAME_INTEROP)
{
- throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
+ throw CIMNotSupportedException(
path.getClassName().getString());
}
else
@@ -436,6 +442,9 @@ Boolean _getPropertyValue(const CIMInstance& instance, const CIMName& propertyNa
if (!v1.isNull())
v1.get(output);
}
+ else
+ throw CIMInvalidParameterException(
+ "Incorrect Property Type for Property " + propertyName.getString());
}
return(output);
}
@@ -610,7 +619,7 @@ Boolean _validateRequiredProperty(const CIMInstance& instance,
return(false);
}
-/* _CheckRequiredProperty
+/* _CheckRequiredProperty
Note validate does about the same thing.
*/
Boolean _checkRequiredProperty(CIMInstance& instance,
@@ -651,7 +660,6 @@ Boolean _checkRequiredProperty(CIMInstance& instance,
if ((theValue.getType ()) != expectedType)
propertyError = true;
}
-
}
PEG_METHOD_EXIT ();
return(propertyError);
@@ -1233,6 +1241,7 @@ CIMInstance InteropProvider::_getInstanceCIMObjectManager(
}
instance.setPath(instancePath);
}
+
PEG_METHOD_EXIT();
return(instance);
}
@@ -1472,7 +1481,7 @@ CIMInstance InteropProvider::_buildInstancePGNamespace(const CIMObjectPath& obje
{
PEG_METHOD_EXIT();
// This is poor exception since it reflects internal error. Do error log
- throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
+ throw CIMNotSupportedException(
"Namespace attribute rtnd error for key " + key + "expected " +
nameSpace.getString()+ value + " in " + String(thisProvider));
}
@@ -1601,7 +1610,6 @@ Boolean _completeProperty(CIMInstance& instance,
}
Boolean _completeCIMNamespaceKeys(CIMInstance& instance)
{
-
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::_completeCIMNamespaceKeys");
@@ -1612,7 +1620,6 @@ Boolean _completeCIMNamespaceKeys(CIMInstance& instance)
CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
System::getSystemCreationClassName ()))
{
-
propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
valid = false;
}
@@ -1925,6 +1932,8 @@ void InteropProvider::createInstance(
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()");
+ AutoMutex autoMut(changeControlMutex);
+
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
"%s createInstance. InstanceReference= %s",
thisProvider,
@@ -2090,6 +2099,8 @@ void InteropProvider::deleteInstance(
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance");
+ AutoMutex autoMut(changeControlMutex);
+
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
"%s deleteInstance. instanceName= %s",
thisProvider,
@@ -2190,6 +2201,7 @@ CIMInstance InteropProvider::localGetInstance(
// create reference from host, namespace, class components of
// instance name
+
CIMObjectPath ref;
ref.setHost(instanceName.getHost());
ref.setClassName(instanceName.getClassName());
@@ -2208,6 +2220,7 @@ CIMInstance InteropProvider::localGetInstance(
// deliver a single instance if found.
CIMInstance rtnInstance;
+
for (Uint32 i = 0 ; i < instances.size() ; i++)
{
if (instanceName == instances[i].getPath())
@@ -2251,6 +2264,8 @@ void InteropProvider::getInstance(
if (!myInstance.isUninitialized())
handler.deliver(myInstance);
+ else
+ throw CIMObjectNotFoundException(instanceName.toString());
handler.complete();
}
@@ -2293,7 +2308,6 @@ Array<CIMInstance> InteropProvider::localEnumerateInstances(
includeQualifiers,
includeClassOrigin,
propertyList);
-
instances.append(instance);
}
@@ -2385,69 +2399,166 @@ void InteropProvider::enumerateInstances(
PEG_METHOD_EXIT();
}
-void InteropProvider::modifyObjectManagerInstance(const OperationContext & context,
+/** Determies if an instance modification is to be allowed. This includes
+ tests to determine the validity of the modified instance, the property
+ list provided, if qualifier modification was requested.
+ @param context
+ @param instanceReference CIMObjectPath defining the path of the instance
+ to be modified.
+ @param modifiedIns CIMInstance containing the modifications
+ @param includeQualifiers Boolean defining if qualifiers are to be modified.
+ @param propertyList CIMPropertyList provided with the request
+ @param allowedModifyProperties CIMPropertyList defining properties that
+ are allowed to be modified by the provider
+ @return true if there are modifications that can be made. Note that there
+ is an additional decision to be made by the user whether the modifiedIns
+ includes all of the properties or they are to be set to default.
+ @exception CIM_ERR_NOT_SUPPORTED if the specified modification is not supported
+ @exception CIM_ERR_INVALID_PARAMETER if the modifiedInstance is invalid
+ */
+Boolean InteropProvider::isModifyAllowed(const OperationContext & context,
const CIMObjectPath & instanceReference,
const CIMInstance& modifiedIns,
const Boolean includeQualifiers,
const CIMPropertyList& propertyList,
- ResponseHandler & handler)
+ const CIMPropertyList& allowedModifyProperties)
+{
+ // if property list size does not match allowed list.
+ if ((propertyList.size() > allowedModifyProperties.size())
+ || (propertyList.isNull())
+ )
+ {
+ throw CIMNotSupportedException(
+ "Only Modification of " + _toStringPropertyList(allowedModifyProperties)
+ + " allowed");
+ }
+ // property list indicates nothing to modify return false
+ if (propertyList.size() == 0)
+ {
+ return(false);
+ }
+
+ // DO NOT allow any qualifier modifications.
+ if (includeQualifiers)
+ {
+ throw CIMNotSupportedException(
+ "Qualifier Modification not allowed");
+ }
+
+ // Assure that nothing is in the propertylist and NOT in
+ // the allowed list.
+ Array<CIMName> allowedArray = allowedModifyProperties.getPropertyNameArray();
+ for (Uint32 i = 0 ; i < propertyList.size() ; i++)
+ {
+ if (!Contains(allowedArray, propertyList[i]))
+ {
+ throw CIMNotSupportedException(
+ "Only Modification of " + _toStringPropertyList(allowedModifyProperties)
+ + " allowed");
+ }
+ }
+ // We have something to modify. Property List is valid
+ return(true);
+}
+/** Modify the existing object Manager Object. Only a single property modification
+ is allowed, the statistical data setting. Any other change is rejected
+ with an exception
+ @param instanceReference - Reference for the instance to be modified.
+ @param modifiedIns CIMInstance defining the change. If this includes more than
+ a single property, the propertyList must specify modification only of the
+ statisticaldata property.
+ @includeQualifiers Boolean which must be false unless there are no qualifiers
+ in the modifiedIns.
+ @propertyList CIMPropertyList defining the property to be modified if there
+ is more than one property in the modifiedIns.
+ @Exceptions CIMInvalidParameterException if the parameters are not valid for
+ the modification.
+ */
+void InteropProvider::modifyObjectManagerInstance(const OperationContext & context,
+ const CIMObjectPath & instanceReference,
+ const CIMInstance& modifiedIns,
+ const Boolean includeQualifiers,
+ const CIMPropertyList& propertyList)
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::modifyObjectManagerInstance");
- // the only allowed modification is this one property, statistical data
+ // Modification only allowed when Performance staticistics are active
+#ifndef PEGASUS_DISABLE_PERFINST
+ // the only allowed modification is one property, statistical data
+ Array<CIMName> plA;
+ plA.append(CIMName(OM_GATHERSTATISTICALDATA));
+ CIMPropertyList allowedModifyPropertyList(plA);
- if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND)
+ // returns only if no exception and there is property to modify.
+ if (isModifyAllowed(context, instanceReference, modifiedIns,
+ includeQualifiers, propertyList, allowedModifyPropertyList))
{
- // the following is a temporary hack to set the value of the statistics
- // gathering function dynamically. We simply get the value from input
- // and call the internal method to set it each time this object is
- // built.
-#ifndef PEGASUS_DISABLE_PERFINST
- Boolean statisticsFlag = _getPropertyValue(modifiedIns,
- OM_GATHERSTATISTICALDATA, false);
CIMInstance instance;
instance = _getInstanceCIMObjectManager(instanceReference,
true, true, CIMPropertyList());
- if (statisticsFlag != _getPropertyValue(instance, OM_GATHERSTATISTICALDATA, false))
- {
- // set the changed property into the
- _setPropertyValue(instance, OM_GATHERSTATISTICALDATA, statisticsFlag);
- // Modify the object on disk
- try
- {
- _repository->modifyInstance(instanceReference.getNameSpace(),
- instance );
- }
- catch(const CIMException&)
- {
- // ATTN: KS generate log error if this not possible
- PEG_METHOD_EXIT();
- throw;
- }
- catch(const Exception&)
- {
- // ATTN: Generate log error.
- PEG_METHOD_EXIT();
- throw;
- }
- Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
- "Interop Provider Set Statistics gathering in CIM_ObjectManager: $0",
- (statisticsFlag? "true" : "false"));
- StatisticalData* sd = StatisticalData::current();
- sd->setCopyGSD(statisticsFlag);
- }
+ CIMObjectPath tmpPath;
+ tmpPath.setClassName(instanceReference.getClassName());
+ tmpPath.setKeyBindings(instanceReference.getKeyBindings());
+ if (!(tmpPath == instance.getPath()) )
+ throw CIMObjectNotFoundException(instanceReference.toString());
+ }
+ else // nothing to modify. return
+ {
return;
-#endif
+ }
+ Boolean statisticsFlag;
+ CIMInstance myInstance;
+ // We modify only if this property exists.
+ // could either use the property from modifiedIns or simply replace
+ // value in property from object manager.
+ if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND)
+ {
+ myInstance = _getInstanceCIMObjectManager(instanceReference,
+ false, false, propertyList);
+ statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false);
+ // set the changed property into the instance
+ _setPropertyValue(myInstance, OM_GATHERSTATISTICALDATA, statisticsFlag);
+ }
+ else
+ {
+ // if statistics property not in place, simply exit. Nothing to do
+ // not considered an error
+ PEG_METHOD_EXIT();
+ return;
+ }
+ // Modify the instance on disk
+ try
+ {
+ _repository->modifyInstance(instanceReference.getNameSpace(),
+ myInstance, false, propertyList);
+ }
+ catch(const CIMException&)
+ {
+ PEG_METHOD_EXIT();
+ throw;
+ }
+ catch(const Exception&)
+ {
+ PEG_METHOD_EXIT();
+ throw;
}
+ Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
+ "Interop Provider Set Statistics gathering in CIM_ObjectManager: $0",
+ (statisticsFlag? "true" : "false"));
+ StatisticalData* sd = StatisticalData::current();
+ sd->setCopyGSD(statisticsFlag);
+ PEG_METHOD_EXIT();
+ return;
+
+#else
PEG_METHOD_EXIT();
- // ATTN Expand this definition to be more precise since it allows only mod of
- // one property and that property MUST be in the instance to be modifiable.
throw CIMNotSupportedException
(OM_GATHERSTATISTICALDATA.getString() +
" modify operation not supported by Interop Provider");
+#endif
}
//***************************************************************************
//***************************************************************************
@@ -2464,6 +2575,8 @@ void InteropProvider::modifyInstance(const OperationContext & context,
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::modifyInstance");
+ AutoMutex autoMut(changeControlMutex);
+
Tracer::trace(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
"%s modifyInstance. instanceReference= %s, includeQualifiers= %s, PropertyList= %s",
thisProvider,
@@ -2486,16 +2599,15 @@ void InteropProvider::modifyInstance(const OperationContext & context,
if (classEnum == CIM_OBJECTMANAGER)
{
modifyObjectManagerInstance(context, instanceReference,modifiedIns,
- includeQualifiers, propertyList, handler);
+ includeQualifiers, propertyList);
// for the moment allow modification of the statistics property only
}
else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
{
-
PEG_METHOD_EXIT();
throw CIMNotSupportedException
- (className.getString() + " not supported by Interop Provider");
+ (" Modification of " + className.getString() + " not supported by Interop Provider");
}
else if (classEnum == PG_NAMESPACE)
{
diff --git a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.h b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.h
index 0ee337a..993cbb1 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.h
+++ b/src/Pegasus/ControlProviders/InteropProvider/InteropProvider.h
@@ -259,12 +259,18 @@ private:
const Boolean includeClassOrigin,
const CIMPropertyList& propertyList);
- void modifyObjectManagerInstance(const OperationContext & context,
+ Boolean InteropProvider::isModifyAllowed(const OperationContext & context,
const CIMObjectPath & instanceReference,
const CIMInstance& modifiedIns,
const Boolean includeQualifiers,
const CIMPropertyList& propertyList,
- ResponseHandler & handler);
+ const CIMPropertyList& allowedModifyProperties);
+
+ void modifyObjectManagerInstance(const OperationContext & context,
+ const CIMObjectPath & instanceReference,
+ const CIMInstance& modifiedIns,
+ const Boolean includeQualifiers,
+ const CIMPropertyList& propertyList);
// The following are internal equivalents of the operations
// allowing the operations to call one another internally within
diff --git a/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp b/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
index 69b3479..1087d1c 100644
--- a/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
+++ b/src/Pegasus/ControlProviders/InteropProvider/tests/interop.cpp
@@ -168,6 +168,25 @@ Boolean _containsObjectPath(const CIMObjectPath& path,
return false;
}
+Boolean _checkExceptionCode
+ (const CIMException & e,
+ const CIMStatusCode expectedCode)
+{
+ if (verbose)
+ {
+ if (e.getCode () != expectedCode)
+ {
+ cerr << "CIMException comparison failed. ";
+ cerr << "Expected " << cimStatusCodeToString (expectedCode) << "; ";
+ cerr << "Actual exception was " << e.getMessage () << "." << endl;
+ }
+ }
+
+ if (e.getCode () == expectedCode)
+ return(true);
+ else
+ return(false);
+}
/* Class created to provide cover for all of the tests in this
test program.
*/
@@ -239,8 +258,16 @@ public:
CIMObjectPath getObjMgrPath();
void testObjectManagerClass();
+
void setStatisticsState(const Boolean flag);
+ Boolean InteropTest::testStatisticsSetOperationError(
+ const CIMInstance & instance,
+ const CIMPropertyList& list,
+ Boolean shouldRespondGood,
+ Boolean includeQualifiers,
+ const CIMStatusCode expectedCode);
+
Boolean getStatisticsPropertyState(
CIMInstance & objMgrInstance);
@@ -2104,26 +2131,40 @@ void InteropTest::testObjectManagerClass()
cout << "ObjectManagerClass Tests passed" << endl;
}
+/* Set the CIM_ObjectManager gatherStatisticaldata property in the
+ server to the state defined by flag.
+ @flag Boolean - state to set.
+*/
void InteropTest::setStatisticsState(const Boolean flag)
{
CIMInstance instanceObjectManagr = getInstanceObjMgr();
CIMInstance sendInstance = instanceObjectManagr.clone();
- Uint32 pos;
- if ((pos = sendInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
- sendInstance.getProperty(pos).setValue(CIMValue(flag));
-
- // What is this for?????
- // We are appending property????
+ // Filter out everything but our property.
Array<CIMName> plA;
plA.append(CIMName("gatherstatisticaldata"));
CIMPropertyList myPropertyList(plA);
+ sendInstance.filter(false, false, myPropertyList);
+ Uint32 pos;
+ if ((pos = sendInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
+ sendInstance.getProperty(pos).setValue(CIMValue(flag));
+ else
+ {
+ TERMINATE("gatherstatisticaldata property not found in setStatisticsState function");
+ }
+ try
+ {
_client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP,
sendInstance,
false,
- CIMPropertyList());
+ myPropertyList);
+ }
+ catch(CIMException& e)
+ {
+ cout <<" setStatistics CIMException: " << e.getMessage() << endl;
+ }
}
Boolean InteropTest::getStatisticsPropertyState(CIMInstance & objMgrInstance)
@@ -2160,111 +2201,185 @@ void InteropTest::showStatisticsState()
cout << "Statistics State = " << (getStatisticsState()? "on" : "off") << endl;
}
+
+/** try the modify operation. Will return true if it passes and false if
+ it fails with any error code other than the one defined. This function
+ is used to test primarily the error functions of modify instance.
+ @param modifiedIns CIMInstance with modifications
+ @param list CIMPropertyList of properties to modify
+ @param includeQualifiers Boolean that defines whether qualifiers
+ are to be modified
+ @expectedCode CIMStatusCode defining expected error code.
+ @return True if the modification fails AND the expected error is received.
+*/
+Boolean InteropTest::testStatisticsSetOperationError(
+ const CIMInstance & modifiedIns,
+ const CIMPropertyList& list,
+ Boolean shouldRespondGood,
+ Boolean includeQualifiers,
+ const CIMStatusCode expectedCode)
+{
+ try
+ {
+ // modify with full instance but propertylist set to mod
+ // only this property.
+ _client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP,
+ modifiedIns,
+ includeQualifiers,
+ list);
+ if (shouldRespondGood)
+ {
+ return(true);
+ }
+ else
+ return(false); // return false. modification was made
+ }
+ catch(CIMException& e)
+ {
+ if (shouldRespondGood)
+ {
+ // unexpected Error hit.
+ return(false);
+ }
+ else
+ {
+ if (_checkExceptionCode(e, expectedCode))
+ return (true);
+ else
+ return(false);
+ }
+ }
+}
+/** test of the function to enable and disable the boolean statistics
+ property in CIMObjectManager using modify instance.
+ This tests both correct modification and error cases.
+*/
void InteropTest::testStatisticsEnable()
{
try
{
+ //
+ // Test normal set to true and set to false operations
+ //
+ setStatisticsState(true);
+ // Get Object Manager instance and confirm property changed.
+ assert(getStatisticsState());
+ setStatisticsState(false);
+ // Get Object Manager instance and confirm property changed.
+ assert(!getStatisticsState());
+
+ //
+ // Test modify with multiple properties in modifiedIns.
+ //
+ // Get original instance for following tests
CIMInstance instanceObjectManager = getInstanceObjMgr();
- CIMInstance sendInstance = instanceObjectManager.clone();
- Uint32 pos;
- if ((pos = sendInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
- sendInstance.getProperty(pos).setValue(CIMValue(true));
- else
- assert(false);
- CDEBUG("testStats. pos = " << pos);
+ // Create property list that represents correct request
Array<CIMName> plA;
plA.append(CIMName("gatherstatisticaldata"));
CIMPropertyList myPropertyList(plA);
- // Don't need this.
- //sendInstance.filter(false, false, CIMPropertyList());
-
- CDEBUG("testStats. filtered");
- //??? Error here since we only have the one property in the instance.
- try
- {
- if (verbose)
- {
- cout << "Instance to be modified" << endl;
- XmlWriter::printInstanceElement(sendInstance);
- }
- _client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP,
- sendInstance,
- false,
- CIMPropertyList());
- }
- catch(CIMException& e)
- {
- cout <<" CIM_ObjectManager Test Modify Instance CIMException: " << e.getMessage() << endl;
- assert(false);
- }
-
-
- CDEBUG("testStats. modified");
- // Get Object Manager instance and confirm property changed.
- CIMInstance localInstance = getInstanceObjMgr();
+ // Get Object Manager instance as basis for following tests
+ CIMInstance sendInstance = instanceObjectManager.clone();
- if ((pos = localInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
- {
- CIMConstProperty p1 = localInstance.getProperty(pos);
- if (p1.getType() == CIMTYPE_BOOLEAN)
- {
- CIMValue v1 = p1.getValue();
- Boolean output;
- if (!v1.isNull())
- v1.get(output);
- assert(output);
- }
- }
+ Uint32 pos;
+ if ((pos = sendInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
+ sendInstance.getProperty(pos).setValue(CIMValue(true));
else
assert(false);
- // Now we must set it back to false.
+ // Test with Multiple Properties in instance and qualifiers removed
+ sendInstance.filter(false, false, CIMPropertyList());
+ // try modify with multiple properties . Should set statistics true
+ if(!testStatisticsSetOperationError(sendInstance, myPropertyList,
+ true, false, CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Failed to Set Statistics true");
+ assert(getStatisticsState());
- CDEBUG("testStats. second get");
+ // test with multiple properties in instance and qualifiers in instance
+ sendInstance = instanceObjectManager.clone();
if ((pos = sendInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
sendInstance.getProperty(pos).setValue(CIMValue(false));
else
assert(false);
+ // following should turn statistics off
+ if(!testStatisticsSetOperationError(sendInstance, myPropertyList,
+ true, false, CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Failed to Set Statistics false");
+ assert(!getStatisticsState());
- _client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP,
- sendInstance,
- false,
- CIMPropertyList());
+ // now assure ourselves that the instances are the same.
+ //CIMInstance newInstanceObjectManager = getInstanceObjMgr();
+ assert(instanceObjectManager.identical(getInstanceObjMgr()));
- // Get instance and confirm property changed once again.
- CIMInstance newInstanceObjectManager = getInstanceObjMgr();
+ //
+ // Now test possible modify operations that should fail.
+ //
+ sendInstance = instanceObjectManager.clone();
- if ((pos = newInstanceObjectManager.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
- {
- CIMConstProperty p1 = newInstanceObjectManager.getProperty(pos);
- if (p1.getType() == CIMTYPE_BOOLEAN)
- {
- CIMValue v1 = p1.getValue();
- Boolean output;
- if (!v1.isNull())
- v1.get(output);
- else
- assert(false);
- assert(output == false);
- }
- }
+ if ((pos = sendInstance.findProperty("gatherstatisticaldata")) != PEG_NOT_FOUND)
+ sendInstance.getProperty(pos).setValue(CIMValue(true));
else
assert(false);
- }
- // Catch block for all of the CIM_ObjectManager Tests.
+
+ // Should fail because property list is null
+ if(!testStatisticsSetOperationError(sendInstance, CIMPropertyList(),
+ false, false, CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Set Should fail. CIMPropertyList Null not allowed");
+ assert(!getStatisticsState());
+
+ // PropertyList contains one property but NOT statistics. It should fail
+ Array<CIMName> plA2;
+ plA2.append(CIMName("RequestStateChange"));
+ CIMPropertyList myPropertyList2(plA2);
+ CIMInstance sendInstance2 = sendInstance.clone();
+ sendInstance2.filter(false, false, myPropertyList2);
+ if(!testStatisticsSetOperationError(sendInstance, myPropertyList2,
+ false, false, CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Set Should fail. Bad Property in modifiedInstance");
+ assert(!getStatisticsState());
+
+ // Try with MyProperty list empty. This should return good but
+ // no change
+ Array<CIMName> plA3;
+ myPropertyList2.set(plA3);
+ sendInstance2 = sendInstance.clone();
+ sendInstance2.filter(false, false, myPropertyList);
+ if(!testStatisticsSetOperationError(sendInstance, myPropertyList2,
+ true, false, CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Set with propertylist empty should pass");
+ assert(!getStatisticsState());
+
+ // Try with includequalifiers and include qualifiers. Should fail
+ if(!testStatisticsSetOperationError(sendInstance, myPropertyList,
+ false, true, CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Set Should fail. includeQualifiers = true");
+ assert(!getStatisticsState());
+
+ // try with propertylist that has extra properties.
+ plA.append(CIMName("RequestStateChange"));
+ myPropertyList.set(plA);
+ if(!testStatisticsSetOperationError(sendInstance, myPropertyList,
+ false, false,CIM_ERR_NOT_SUPPORTED))
+ TERMINATE("Set Should fail. Bad Property in modifiedInstance");
+
+ // Confrim that instance is unchanged from original.
+ assert(!getStatisticsState());
+ //newInstanceObjectManager = getInstanceObjMgr();
+ assert(instanceObjectManager.identical(getInstanceObjMgr()));
+ }
+ // Catch block for all of the Statistics Modification Tests.
catch(CIMException& e)
{
- TERMINATE(" CIM_ObjectManager Test CIMException: " << e.getMessage());
+ TERMINATE(" testStatisticsEnable Test CIMException: " << e.getMessage());
}
catch(Exception& e)
{
- TERMINATE(" CIM_ObjectManager Test Pegasus Exception: " << e.getMessage());
+ TERMINATE(" testStatisticsEnable Test Pegasus Exception: " << e.getMessage());
}
catch(...)
{
- TERMINATE(" CIM_ObjectManager Test Caught General Exception:");
+ TERMINATE(" testStatisticsEnable Test Caught General Exception:");
}
if (verbose)
{