Ejemplo n.º 1
0
void callMethod(const CIMName& methodName)
{
    try
    {
        CIMClient client;
        client.connectLocal();

        Array<CIMParamValue> inParams;
        Array<CIMParamValue> outParams;

        CIMObjectPath instName =
            CIMObjectPath("Test_MethodProviderClass.Id=1");

        inParams.append(CIMParamValue("InParam1", Uint32(1)));
        inParams.append(CIMParamValue("InParam2", Uint32(2)));

        CIMValue returnValue = client.invokeMethod(
            NAMESPACE,
            instName,
            methodName,
            inParams,
            outParams);

        Uint32 rc;
        returnValue.get(rc);
        PEGASUS_TEST_ASSERT(rc == 10);

        PEGASUS_TEST_ASSERT(outParams.size() == 2);

        Uint32 outParam1 = 0;
        Uint32 outParam2 = 0;

        for (Uint32 i = 0; i < 2; i++)
        {
            if (outParams[i].getParameterName() == "OutParam1")
            {
                outParams[i].getValue().get(outParam1);
            }
            else if (outParams[i].getParameterName() == "OutParam2")
            {
                outParams[i].getValue().get(outParam2);
            }
            else
            {
                PEGASUS_TEST_ASSERT(0);
            }
        }
        PEGASUS_TEST_ASSERT(outParam1 == 21);
        PEGASUS_TEST_ASSERT(outParam2 == 32);
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }
}
Ejemplo n.º 2
0
void _sendTestIndication(
    CIMClient* client,
    const CIMName & methodName,
    Uint32 indicationSendCount)
{
    //
    //  Invoke method to send test indication
    //
    Array <CIMParamValue> inParams;
    Array <CIMParamValue> outParams;
    Array <CIMKeyBinding> keyBindings;
    Sint32 result;

    CIMObjectPath className (String::EMPTY, CIMNamespaceName (),
                             CIMName ("Test_IndicationProviderClass"), keyBindings);

    inParams.append(CIMParamValue(String("indicationSendCount"),
                                  CIMValue(indicationSendCount)));

    CIMValue retValue = client->invokeMethod
                        (SOURCE_NAMESPACE,
                         className,
                         methodName,
                         inParams,
                         outParams);

    retValue.get (result);
    PEGASUS_TEST_ASSERT (result == 0);
}
Ejemplo n.º 3
0
// get the current provider test parameters.
void tests::get(Uint64& instanceSize, Uint64& responseCount)
{
    Array<CIMParamValue> InParams;

    Array<CIMParamValue> outParams;

    InParams.append(CIMParamValue("ResponseInstanceSize", instanceSize));
    InParams.append(CIMParamValue("ResponseCount", responseCount));

    CIMValue returnValue = client.invokeMethod(
        testNamespaceName,
        CIMObjectPath(String::EMPTY,
                      CIMNamespaceName(),
                      CIMName(testClass)),
        CIMName("get"),
        InParams,
        outParams);

    Uint32 rc;
    returnValue.get(rc);
    CIMPLE_TEST_ASSERT(rc == 0);

    for(Uint32 i = 0; i < outParams.size(); ++i)
    {
        String paramName = outParams[i].getParameterName();
        CIMValue v = outParams[i].getValue();

        if(paramName =="ResponseCount")
        {
            v.get(responseCount);
        }
        else if(paramName =="ResponseInstanceSize")
        {
            v.get(instanceSize);
        }
        else
        {
            cout <<"Error: unknown parameter name = " << paramName << endl;
            CIMPLE_TEST_ASSERT(false);
        }
    }
}
Ejemplo n.º 4
0
void MethodProvider::invokeMethod(
    const OperationContext & context,
    const CIMObjectPath & objectReference,
    const CIMName & methodName,
    const Array<CIMParamValue> & inParameters,
    MethodResultResponseHandler & handler)
{
    // convert a fully qualified reference into a local reference
    // (class name and keys only).
    CIMObjectPath localReference = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        objectReference.getClassName(),
        objectReference.getKeyBindings());

    handler.processing();

    if (objectReference.getClassName().equal("Sample_MethodProviderClass"))
    {
        if (methodName.equal("SayHello"))
        {
            String outString = "Hello";
            if (inParameters.size() > 0)
            {
                CIMValue paramVal = inParameters[0].getValue();
                if (!paramVal.isNull())
                {
                    String replyName;
                    paramVal.get(replyName);
                    if (replyName != String::EMPTY)
                    {
                        outString.append(", " + replyName + "!");
                    }
                }

                handler.deliverParamValue(
                    CIMParamValue("Place",
                        CIMValue(String("From Neverland"))));
                handler.deliver(CIMValue(outString));
            }
            else
            {
                handler.deliver(CIMValue(outString));
            }
        }
    }
    
    handler.complete();
}
Ejemplo n.º 5
0
static void _generateIndications(CIMClient &client, Uint32 count)
{
    Array<CIMParamValue> outParams;
    Array<CIMParamValue> inParams;
    inParams.append(
        CIMParamValue(String("count"),
            CIMValue(count)));

    client.invokeMethod(
        NAMESPACE,
        CIMObjectPath("DeliveryRetryTestClass"),
        "generateIndications",
        inParams,
        outParams);
}
Ejemplo n.º 6
0
// set the instanceSize and response count parameters in the
// client
void tests::set(Uint64 instanceSize, Uint64 responseCount)
{
    Array<CIMParamValue> InParams;

    Array<CIMParamValue> outParams;

    InParams.append(CIMParamValue("ResponseCount", responseCount));
    InParams.append(CIMParamValue("ResponseInstanceSize", instanceSize));
    CIMValue returnValue = client.invokeMethod(
        testNamespaceName,
        CIMObjectPath(String::EMPTY,
                      CIMNamespaceName(),
                      CIMName(testClass)),
        CIMName("set"),
        InParams,
        outParams);

    CIMPLE_TEST_ASSERT(outParams.size() == 0);

    Uint32 rc;
    returnValue.get(rc);

    CIMPLE_TEST_ASSERT(rc == 0);
}
Ejemplo n.º 7
0
void
test08 (CIMClient & client)
{
  CIMObjectPath instanceName;
  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  inParams.append (CIMParamValue ("Operation", CIMValue (Uint64 (1))));
  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "TestCMPIBroker",
                       inParams,
                       outParams);
    _checkUint32Value (retValue, 1);
}
Ejemplo n.º 8
0
int signalIndication(CIMClient& client)
{
    AutoMutex a(*mut);
    Array<CIMParamValue> inParameters;
    Array<CIMParamValue> outParameters;

    try
    {
        inParameters.append(CIMParamValue("error", CIMValue(*errorInstance)));
        client.invokeMethod(
            TEST_NAMESPACE,
            errorPath,
            CIMName("PropagateError"),
            inParameters,
            outParameters);

        if (outParameters.size() != 1)
        {
            cout << "Expected to get 1 output parameter from PropagateError. "
                << "Received " << outParameters.size() << endl;
            return -1;
        }

        CIMInstance outParamInstance;
        outParameters[0].getValue().get(outParamInstance);
        outParamInstance.setPath(errorInstance->getPath());
        if (!errorInstance->identical(outParamInstance))
        {
            cout << "Output Instance differs from Input Instance" << endl;
            return -1;
        }
    }
    catch (Exception& e)
    {
        cout << "Exception caught during invoke method of PropagateError: "
            << e.getMessage() << endl;
        return -1;
    }

    return 0;
}
Ejemplo n.º 9
0
/* Test for method invoke and response that handles ref parameter arrays.
   This functions sends two ref array in parameters and expects exactly the 
   same reference arrays back in the two out parameters.
*/
void callMethodRefParamArray(const CIMName& methodName)
{
    try
    {
        CIMClient client;
        client.connectLocal();

        Array<CIMParamValue> inParams;
        Array<CIMParamValue> outParams;

        CIMObjectPath instName =
            CIMObjectPath("Test_MethodProviderClass.Id=1");

        CIMObjectPath inParamA1(
            String("//atp:77/root/cimv2:CIM_ComputerSystem."
                "last=\"Rafter\",first=\"Patrick\""));

        CIMObjectPath inParamA2(
            String("//atp:77/root/cimv2:CIM_ComputerSystem."
                "last=\"Rafter\",first=\"Rafter\""));

        CIMObjectPath inParamB1(
            String("//atp:77/root/cimv2:CIM_ComputerSystem."
                "last=\"Rafter\",first=\"Fred\""));

        CIMObjectPath inParamB2(
            String("//atp:77/root/cimv2:CIM_ComputerSystem."
                "last=\"Rafter\",first=\"John\""));

        Array<CIMObjectPath> InParamAArray;
        InParamAArray.append(inParamA1);
        InParamAArray.append(inParamA2);
        CIMValue inParam1(InParamAArray);

        Array<CIMObjectPath> InParamBArray;
        InParamBArray.append(inParamB1);
        InParamBArray.append(inParamB2);
        CIMValue inParam2(InParamBArray);

        inParams.append(CIMParamValue("InParam1", inParam1));
        inParams.append(CIMParamValue("InParam2", inParam2));

        CIMValue returnValue = client.invokeMethod(
            NAMESPACE,
            instName,
            methodName,
            inParams,
            outParams);

        Uint32 rc;
        returnValue.get(rc);
        PEGASUS_TEST_ASSERT(rc == 10);

        PEGASUS_TEST_ASSERT(outParams.size() == 2);

        Array<CIMObjectPath> outParam1;
        Array<CIMObjectPath> outParam2;

        for (Uint32 i = 0; i < 2; i++)
        {
            if (outParams[i].getParameterName() == "OutParam1")
            {
                outParams[i].getValue().get(outParam1);
            }
            else if (outParams[i].getParameterName() == "OutParam2")
            {
                outParams[i].getValue().get(outParam2);
            }
            else
            {
                PEGASUS_TEST_ASSERT(0);
            }
        }
        PEGASUS_TEST_ASSERT(outParam1 == inParam1);
        PEGASUS_TEST_ASSERT(outParam2 == inParam2);
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }
}
Ejemplo n.º 10
0
void test01()
{
    CIMParamValue pv;
    PEGASUS_TEST_ASSERT(pv.isUninitialized());

    String p1("message");
    CIMValue v1(String("argument_Test"));
    CIMParamValue a1(p1, v1);

//  Test call to CIMParamValue::setValue(CIMValue& value)
//  this test uses the above values for a1, p1 and v1.
    CIMParamValue a7(p1, v1);
    CIMValue v7(String("argument_Test7"));
    a7.setValue( v7);
    PEGASUS_TEST_ASSERT(a1.getValue().toString() != a7.getValue().toString());
    PEGASUS_TEST_ASSERT(a1.getParameterName() == a7.getParameterName());

//  Test call to CIMParamValue::setParameterName(String& parameterName)
//  this test uses the above values for a1, p1 and v1.
    CIMParamValue a8(p1, v1);
    String p8("message8");
    a8.setParameterName( p8);
    PEGASUS_TEST_ASSERT(a1.getValue().toString() == a8.getValue().toString());
    PEGASUS_TEST_ASSERT(a1.getParameterName() != a8.getParameterName());
    PEGASUS_TEST_ASSERT(a8.isTyped());
    a8.setIsTyped(false);
    PEGASUS_TEST_ASSERT(!a8.isTyped());

    String p2("message2");
    CIMValue v2(String("argument_Test2"));
    CIMParamValue a2(p2, v2);

    String p3("message3");
    CIMValue v3(String("argument_Test3"));
    CIMParamValue a3(p3, v3);

    String p4("message4");
    CIMValue v4(String("argument_Test4"));
    CIMParamValue a4(p4, v4);
    CIMParamValue a5 = a4;

    String p6("message6");
    CIMValue v6(String("argument_Test6"));
    CIMParamValue a6(p6, v6);

    Array<CIMParamValue> aa;
    aa.append(a1);
    aa.append(a2);

    aa.append(CIMParamValue("message3", CIMValue(200000)));

    aa.append(CIMParamValue("message4", CIMValue(String("test4"))));
    
    //
    // clone
    //
    CIMParamValue a4clone = a4.clone();
    aa.append(a4clone);

    if (verbose)
    {
        for (Uint32 i=0; i< aa.size(); i++)
        {
            XmlWriter::printParamValueElement(aa[i], cout);
        }
    }

    //
    // toXml
    //
    Buffer xmlOut;
    XmlWriter::appendParamValueElement(xmlOut, a4clone);
}
Ejemplo n.º 11
0
void DefaultPropertyOwner::_requestIndicationServiceStateChange(
    const String& userName,
    Boolean enable,
    Uint32 timeoutSeconds)
{
    MessageQueue *queue = MessageQueue::lookup(
        PEGASUS_QUEUENAME_INDICATIONSERVICE);
    // Return if indication service can not be found
    if (!queue)
    {
        return;
    }

    Uint32 queueId = queue->getQueueId();

    const String METHOD_NAME = "RequestStateChange";
    const String PARAMNAME_REQUESTEDSTATE = "RequestedState";
    const String PARAMNAME_TIMEOUTPERIOD = "TimeoutPeriod";
    const Uint16 STATE_ENABLED = 2;
    const Uint16 STATE_DISABLED = 3;

    String referenceStr("//", 2);
    referenceStr.append(System::getHostName());
    referenceStr.append("/");
    referenceStr.append(PEGASUS_NAMESPACENAME_INTEROP.getString());
    referenceStr.append(":");
    referenceStr.append(
        PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE.getString());
    CIMObjectPath reference(referenceStr);

    Array<CIMParamValue> inParams;
    Array<CIMParamValue> outParams;

    inParams.append(CIMParamValue(PARAMNAME_REQUESTEDSTATE,
        CIMValue(enable ? STATE_ENABLED : STATE_DISABLED)));

    inParams.append(CIMParamValue(PARAMNAME_TIMEOUTPERIOD,
        CIMValue(CIMDateTime(timeoutSeconds * 1000000, true))));

    MessageQueueService *controller = ModuleController::getModuleController();

    try
    {
        CIMInvokeMethodRequestMessage* request =
            new CIMInvokeMethodRequestMessage(
                XmlWriter::getNextMessageId(),
                PEGASUS_NAMESPACENAME_INTEROP,
                referenceStr,
                CIMNameCast(METHOD_NAME),
                inParams,
                QueueIdStack(queueId));

        request->operationContext.insert(
            IdentityContainer(userName));

        AsyncLegacyOperationStart *asyncRequest =
            new AsyncLegacyOperationStart(
                0,
                queueId,
                request);

        AsyncReply * asyncReply = controller->SendWait(asyncRequest);

        CIMInvokeMethodResponseMessage * response =
            reinterpret_cast<CIMInvokeMethodResponseMessage *>(
                (static_cast<AsyncLegacyOperationResult *>(
                    asyncReply))->get_result());

        CIMException e = response->cimException;

        delete response;
        delete asyncRequest;
        delete asyncReply;

        if (e.getCode() != CIM_ERR_SUCCESS)
        {
            throw e;
        }
    }
    catch(const Exception &e)
    {
        PEG_TRACE((TRC_CONFIG,Tracer::LEVEL1,
            "Exception caught while invoking CIM_IndicationService."
                "RequestStateChange()  method: %s",
        (const char*)e.getMessage().getCString()));
        throw;
    }
    catch(...)
    {
        PEG_TRACE_CSTRING(TRC_CONFIG,Tracer::LEVEL1,
            "Unknown exception caught while invoking CIM_IndicationService."
                "RequestStateChange()  method");
        throw;
    }
}
Ejemplo n.º 12
0
/**
    When the "PropagateError" method is invoked, this function
    will read a CIM_Error embedded instance from the inParameters and use
    that instance to create an InstMethodIndication populating the Error[]
    property with the CIM_Error parameter and errorInstance stored in this
    class (if it's been created already). The output parameter of this method
    will contain the embedded instance received as input, and the newly
    created InstMethodIndication will be sent by the provider to any
    registered listeners.
*/
void EmbeddedInstanceProvider::invokeMethod(
        const OperationContext& context,
        const CIMObjectPath& objectReference,
        const CIMName& methodName,
        const Array<CIMParamValue>& inParameters,
        MethodResultResponseHandler& handler)
{
    // This should start sending indications with the stored Job instance
    // embedded in the InstMethodIndication
    handler.processing();
    if (!methodName.equal(CIMName("PropagateError")))
        throw CIMException(CIM_ERR_METHOD_NOT_AVAILABLE);

    if (inParameters.size() != 1)
    {
        throw CIMException(
            CIM_ERR_INVALID_PARAMETER, "Did not receive exactly 1 parameter");
    }

    CIMParamValue errorParam = inParameters[0];
    if (!String::equal(errorParam.getParameterName(), String("error")))
    {
        throw CIMException(
            CIM_ERR_INVALID_PARAMETER, "Did not find \"error\" parameter");
    }

    CIMInstance errorParamInst;
    errorParam.getValue().get(errorParamInst);
    if (errorParamInst.getPath().getClassName() != "PG_EmbeddedError")
    {
        throw CIMException(CIM_ERR_INVALID_PARAMETER);
    }
    errorParamInst.setPath(errorInstance->getPath());
    Array<CIMName> propList;
    for (unsigned int i = 0, n = errorParamInst.getPropertyCount(); i < n; i++)
    {
        propList.append(errorParamInst.getProperty(i).getName());
    }
    CIMInstance tmpErrorInstance(errorInstance->clone());
    if (!tmpErrorInstance.identical(errorParamInst))
    {
        throw Exception("Did not receive expected ErrorInstance");
    }

    // Build new indication instance
    CIMObjectPath indicationPath(System::getHostName(),
        CIMNamespaceName("test/EmbeddedInstance/Dynamic"),
        CIMName("PG_InstMethodIndication"));
    indicationInstance.reset(new CIMInstance("PG_InstMethodIndication"));
    indicationInstance->setPath(indicationPath);
    indicationInstance->addProperty(CIMProperty("MethodName",
        CIMValue(String("PropagateError"))));
    indicationInstance->addProperty(CIMProperty("PreCall",
        CIMValue(Boolean(false))));
    indicationInstance->addProperty(CIMProperty("SourceInstance",
        CIMValue(CIMObject(*errorInstance))));
    Array<CIMInstance> errorInstances;
    errorInstances.append(*errorInstance);
    errorInstances.append(*errorInstance);
    indicationInstance->addProperty(CIMProperty("Error",
        CIMValue(errorInstances)));

    handler.deliverParamValue(CIMParamValue(String("sameError"),
        CIMValue(errorParamInst)));
    handler.deliver(CIMValue(Uint32(1)));
    handler.complete();

    indicationHandler->deliver(*indicationInstance);
}
Ejemplo n.º 13
0
int main(int argc, char** argv)
{
    try
    {
        CIMClient client;
        client.connectLocal();

        // Define instance name:

        CIMObjectPath instanceName("Methods.key=7777");

        // Define input arguments:

        Array<CIMParamValue> in;
        Array<CIMParamValue> out;

        // Invoke the method:

        const String NAMESPACE = "root/cimv2";
        const String methodName = "foo5";

        Uint32 in_arg = 234567;
        Uint32 in_out_arg = 123456;
        in.append(CIMParamValue("in_arg", in_arg));
        in.append(CIMParamValue("in_out_arg", in_out_arg));

        CIMValue value = client.invokeMethod(
            NAMESPACE,
            instanceName,
            methodName,
            in,
            out);

        {
            assert(value.getType() == CIMTYPE_UINT32);
            Uint32 t;
            value.get(t);
            assert(t == 1200);
        }

        // Check output argument:

        assert(out.size() == 2);
        {
            Uint32 pos = 0;
            assert((pos = findParam(out, "in_out_arg")) != -1);
            assert(out[pos].getParameterName() == "in_out_arg");
            CIMValue value = out[0].getValue();
            Uint32 in_out_arg_rtn;
            value.get(in_out_arg_rtn);
            assert(in_out_arg_rtn == in_out_arg);

            assert((pos = findParam(out, "out_arg")) != -1);
            assert(out[pos].getParameterName() == "out_arg");
            CIMValue value1 = out[1].getValue();
            Uint32 out_arg_rtn;
            value1.get(out_arg_rtn);
            assert(out_arg_rtn == in_arg);
        }

    }
    catch(Exception& e)
    {
        PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
        exit(1);
    }

    PEGASUS_STD(cout) << "+++++ passed all tests" << PEGASUS_STD(endl);

    return 0;
}
Ejemplo n.º 14
0
void test14 (CIMClient & client)
{
    CIMObjectPath instanceName;

    instanceName.setNameSpace (providerNamespace);
    instanceName.setClassName (CLASSNAME);

    Array < CIMParamValue > inParams;
    Array < CIMInstance> eObjs;
    Array < CIMParamValue > outParams;

    CIMValue retValue = client.invokeMethod (providerNamespace,
        instanceName,
        "returnInstance",
        inParams,
        outParams);

    PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT);
    PEGASUS_TEST_ASSERT (!retValue.isArray ());
    PEGASUS_TEST_ASSERT (!retValue.isNull ());

    CIMObject result;
    retValue.get (result);
    CIMObjectPath objPath  = result.getPath();
    CIMInstance inputInstance(result);
    CIMInstance outputInstance;
    eObjs.append(inputInstance);
    eObjs.append(inputInstance);
    eObjs.append(inputInstance);

    inParams.append (
        CIMParamValue(String("inputInstances"), CIMValue(eObjs)));

    retValue = client.invokeMethod (providerNamespace,
        instanceName,
        "processArrayEmbeddedInstance",
        inParams,
        outParams);

    // First test the return value
    PEGASUS_TEST_ASSERT(retValue.getType() == CIMTYPE_INSTANCE);
    PEGASUS_TEST_ASSERT(!retValue.isArray());
    PEGASUS_TEST_ASSERT(!retValue.isNull());
    retValue.get(outputInstance);
    PEGASUS_TEST_ASSERT(objPath.toString() ==
        outputInstance.getPath().toString());
    PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() ==
        inputInstance.getPropertyCount());

    for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i)
    {
        CIMProperty outputProp(outputInstance.getProperty(i));
        CIMProperty inputProp(inputInstance.getProperty(i));

        PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName());
        PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue());
    }

    // Now test the output parameters
    PEGASUS_TEST_ASSERT(outParams.size() == 3);
    CIMValue outParamValue = outParams[0].getValue();
    PEGASUS_TEST_ASSERT(outParamValue.isArray());
    PEGASUS_TEST_ASSERT(!outParamValue.isNull());

    Array<CIMInstance> instances;
    outParamValue.get(instances);

    for (unsigned int j = 0; j < instances.size () ; ++j)
    {
        outputInstance = instances[j];
        PEGASUS_TEST_ASSERT(objPath.toString() ==
            outputInstance.getPath().toString());
        PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() ==
            eObjs[j].getPropertyCount());
        for(unsigned int i = 0, n = outputInstance.getPropertyCount();
            i < n; ++i)
        {
            CIMProperty outputProp(outputInstance.getProperty(i));
            CIMProperty inputProp(eObjs[j].getProperty(i));
            PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName());
            PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue());
        }
    }

    outParamValue = outParams[1].getValue();
    PEGASUS_TEST_ASSERT(outParamValue.isArray());
    PEGASUS_TEST_ASSERT(!outParamValue.isNull());

    Array<CIMObject> objs;
    outParamValue.get(objs);

    for (unsigned int j = 0; j < objs.size () ; ++j)
    {
        outputInstance = CIMInstance(objs[j]);
        PEGASUS_TEST_ASSERT(objPath.toString() ==
            outputInstance.getPath().toString());
        PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() ==
            eObjs[j].getPropertyCount());
        for(unsigned int i = 0, n = outputInstance.getPropertyCount();
            i < n; ++i)
        {
            CIMProperty outputProp(outputInstance.getProperty(i));
            CIMProperty inputProp(eObjs[j].getProperty(i));
            PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName());
            PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue());
        }
    }

    outParamValue = outParams[2].getValue();
    PEGASUS_TEST_ASSERT(outParamValue.isArray());
    PEGASUS_TEST_ASSERT(!outParamValue.isNull());

    outParamValue.get(objs);

    for (Uint32 j = 0, m = objs.size(); j < m ; ++j)
    {
        outputInstance = CIMInstance(objs[j]);
        Uint32 id;
        CIMInstance emInstance;
        CIMObject emObject;
        outputInstance.getProperty(
            outputInstance.findProperty("id")).getValue().get(id);
        outputInstance.getProperty(
            outputInstance.findProperty("emInstance")).
                getValue().get(emInstance);
        outputInstance.getProperty(
            outputInstance.findProperty("emObject")).getValue().get(emObject);
        PEGASUS_TEST_ASSERT(eObjs[j].identical(emInstance));
        PEGASUS_TEST_ASSERT(eObjs[j].identical(CIMInstance(emObject)));
        PEGASUS_TEST_ASSERT(id == j+1);
    }

}
Ejemplo n.º 15
0
/**
 * This tests the embedded instance functionality through the CMPI Test
 * Method Provider. It first invokes the returnInstance() method to retrieve
 * an instance that can be used 
 */
void test09 (CIMClient & client)
{
  CIMObjectPath instanceName;

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     [EmbeddedObject] String returnInstance(); */

  CIMValue retValue = client.invokeMethod (providerNamespace,
                       instanceName,
                       "returnInstance",
                       inParams,
                       outParams);

  PEGASUS_TEST_ASSERT (retValue.getType () == CIMTYPE_OBJECT);
  PEGASUS_TEST_ASSERT (!retValue.isArray ());
  PEGASUS_TEST_ASSERT (!retValue.isNull ());

  CIMObject result;
  retValue.get (result);

  CIMObjectPath objPath  = result.getPath();

  CIMInstance inputInstance(result);
  CIMInstance outputInstance;

  inParams.append(
      CIMParamValue(String("inputInstance"), CIMValue(inputInstance)));

  retValue = client.invokeMethod (providerNamespace,
      instanceName,
      "processEmbeddedInstance",
      inParams,
      outParams);

  // First test the return value
  PEGASUS_TEST_ASSERT(retValue.getType() == CIMTYPE_INSTANCE);
  PEGASUS_TEST_ASSERT(!retValue.isArray());
  PEGASUS_TEST_ASSERT(!retValue.isNull());
  retValue.get(outputInstance);
  PEGASUS_TEST_ASSERT(objPath.toString() ==
    outputInstance.getPath().toString());
  PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() ==
    inputInstance.getPropertyCount());
  for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i)
  {
    CIMProperty outputProp(outputInstance.getProperty(i));
    CIMProperty inputProp(inputInstance.getProperty(i));

    PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName());
    PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue());
  }

  // Now test the output parameter
  PEGASUS_TEST_ASSERT(outParams.size() == 1);
  retValue = outParams[0].getValue();

  PEGASUS_TEST_ASSERT(retValue.getType() == CIMTYPE_INSTANCE);
  PEGASUS_TEST_ASSERT(!retValue.isArray());
  PEGASUS_TEST_ASSERT(!retValue.isNull());
  retValue.get(outputInstance);
  PEGASUS_TEST_ASSERT(objPath.toString() ==
    outputInstance.getPath().toString());
  PEGASUS_TEST_ASSERT(outputInstance.getPropertyCount() ==
    inputInstance.getPropertyCount());
  for(unsigned int i = 0, n = outputInstance.getPropertyCount(); i < n; ++i)
  {
    CIMProperty outputProp(outputInstance.getProperty(i));
    CIMProperty inputProp(inputInstance.getProperty(i));

    PEGASUS_TEST_ASSERT(outputProp.getName() == inputProp.getName());
    PEGASUS_TEST_ASSERT(outputProp.getValue() == inputProp.getValue());
  }
}
Ejemplo n.º 16
0
void
test03 (CIMClient & client)
{
  CIMObjectPath instanceName;

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName (CLASSNAME);

  Array < CIMParamValue > inParams;
  Array < CIMParamValue > outParams;

  /*     uint32 TestCMPIBroker (
   *          [IN, Description (
   *          "The requested are to test different 
   *          CMPI data structure operations."),
   *          ValueMap { "1", "2", "3", "4", "5", "6"},
   *          Values {"CDGetType", "CDToString", "CDIsOfType",
   *                  "CMGetMessage",  "CMLogMessage","CDTraceMessage"}]
   *          uint32 Operation,
   *          [OUT, Description (
   *          " The result of what the operation carried out.")]
   *          string Result);
   *
   */
  {
    /* CDGetType */
    inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (1))));
    CIMValue retValue = client.invokeMethod (providerNamespace,
                         instanceName,
                         "TestCMPIBroker",
                         inParams,
                         outParams);
    // Check the return value. Make sure it is 0.
    _checkUint32Value (retValue, 0);

    PEGASUS_TEST_ASSERT (outParams.size () == 1);
    CIMValue paramValue = outParams[0].getValue ();
    _checkStringValue (paramValue, "CMPIArgs");
  }
  inParams.clear ();
  outParams.clear ();
  {
    /* CDToString */
    inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (2))));
    CIMValue retValue = client.invokeMethod (providerNamespace,
                         instanceName,
                         "TestCMPIBroker",
                         inParams,
                         outParams);
    // Check the return value. Make sure it is 0.
    _checkUint32Value (retValue, 0);

    PEGASUS_TEST_ASSERT (outParams.size () == 1);
    CIMValue paramValue = outParams[0].getValue ();
    _checkStringValue (paramValue, " Operation:2\n");
  }
  inParams.clear ();
  outParams.clear ();
  {
    /* CDIsOfType */
    inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (3))));
    CIMValue retValue = client.invokeMethod (providerNamespace,
                         instanceName,
                         "TestCMPIBroker",
                         inParams,
                         outParams);
    // Check the return value. Make sure it is 0.
    _checkUint32Value (retValue, 0);

    PEGASUS_TEST_ASSERT (outParams.size () == 1);
    CIMValue paramValue = outParams[0].getValue ();
    _checkStringValue (paramValue, "++++ CMPIArgs = Yes");
  }
  inParams.clear ();
  outParams.clear ();
  {
    /* CMGetMessage */
    inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (4))));
    CIMValue retValue = client.invokeMethod (providerNamespace,
                         instanceName,
                         "TestCMPIBroker",
                         inParams,
                         outParams);
    // Check the return value. Make sure it is 0.
    _checkUint32Value (retValue, 0);

    PEGASUS_TEST_ASSERT (outParams.size () == 1);
    CIMValue paramValue = outParams[0].getValue ();
    // If PEGASUS_USE_DEFAULT_MESSAGES is not set, we can't make an
    // assumption about what the value of the msg will be.
    if (useDefaultMsg)
    {
        _checkStringValue (paramValue, "CIM_ERR_SUCCESS: Successful.");
    }
  }
  inParams.clear ();
  outParams.clear ();
  {
    /* CMLogMessage */
    inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (5))));
    CIMValue retValue = client.invokeMethod (providerNamespace,
                         instanceName,
                         "TestCMPIBroker",
                         inParams,
                         outParams);
    // Check the return value. Make sure it is 0.
    _checkUint32Value (retValue, 0);
    // Nothing is returned
    PEGASUS_TEST_ASSERT (outParams.size () == 1);

    CIMValue paramValue = outParams[0].getValue ();
    PEGASUS_TEST_ASSERT (paramValue.isNull ());

  }
  inParams.clear ();
  outParams.clear ();
  {
    /* CMTraceMessage */
    inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (6))));
    CIMValue retValue = client.invokeMethod (providerNamespace,
                         instanceName,
                         "TestCMPIBroker",
                         inParams,
                         outParams);
    // Check the return value. Make sure it is 0.
    _checkUint32Value (retValue, 0);
    // Nothing is returned
    PEGASUS_TEST_ASSERT (outParams.size () == 1);

    CIMValue paramValue = outParams[0].getValue ();
    PEGASUS_TEST_ASSERT (paramValue.isNull ());

  }
  inParams.clear ();
  outParams.clear ();
  {
//       CMGetMessage2 
      inParams.append(CIMParamValue(
                          "Operation",
                          CIMValue(Uint32(7))));
      inParams.append(CIMParamValue(
                          "msgFile",
                          CIMValue(String("test/pegasusTest"))));
      inParams.append(CIMParamValue(
                          "msgId",
                          CIMValue(String("CIMStatusCode.CIM_ERR_SUCCESS"))));
      inParams.append(CIMParamValue(
                          "insert1",
                          CIMValue(String("rab oof is foo bar backwards"))));
      inParams.append(CIMParamValue(
                          "insert2",
                          CIMValue(Uint32(64001))));

      AcceptLanguageList accLangs;
      accLangs.insert(LanguageTag("en-US"),Real32(1.0));
      accLangs.insert(LanguageTag("fr"),Real32(0.8));
      client.setRequestAcceptLanguages(accLangs);

      CIMValue retValue = client.invokeMethod (providerNamespace,
          instanceName,
          "TestCMPIBroker",
          inParams,
          outParams);
      // Check the return value. Make sure it is 0.
      _checkUint32Value (retValue, 0);

      PEGASUS_TEST_ASSERT (outParams.size () == 1);
      CIMValue paramValue = outParams[0].getValue ();
      // If PEGASUS_USE_DEFAULT_MESSAGES is not set, we can't make an
      // assumption about what the value of the msg will be, or the
      // ContentLanguage.
#ifdef PEGASUS_HAS_MESSAGES
      if (useDefaultMsg)
      {
#endif
          _checkStringValue (paramValue, "CIM_ERR_SUCCESS: Successful.");
#ifdef PEGASUS_HAS_MESSAGES
      }
      else
      {
          ContentLanguageList contLangs;
          contLangs = client.getResponseContentLanguages();
          cout << "ContentLanguage size == " << contLangs.size() << endl;
          PEGASUS_TEST_ASSERT(contLangs.size() == 1);
          cout << "ContentLanguage == "
               << contLangs.getLanguageTag(0).toString();
          PEGASUS_TEST_ASSERT(
              contLangs.getLanguageTag(0).toString() == "en-US");
      }
#endif
      // Reset client
      accLangs.clear();
      client.setRequestAcceptLanguages(accLangs);
  }


    inParams.clear();
    outParams.clear();
    {
        // _testCMPIEnumeration
        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (8))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);

        PEGASUS_TEST_ASSERT (outParams.size () == 1);
        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    
    inParams.clear();
    outParams.clear();
    {
        // _testCMPIArray
        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (9))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);

        PEGASUS_TEST_ASSERT (outParams.size () == 1);
        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
        // _testCMPIcontext

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (10))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                             instanceName,
                             "TestCMPIBroker",
                             inParams,
                             outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);

        PEGASUS_TEST_ASSERT (outParams.size () == 1);
        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
        // _testCMPIDateTime

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (11))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);

        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
      //   _testCMPIInstance

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (12))));

        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);
        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
    //     _testCMPIObjectPath

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (13))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);

        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
        //  _testCMPIResult

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (14))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);

        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
        //  _testCMPIString

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (15))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        // Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);

        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

    inParams.clear();
    outParams.clear();
    {
        //_testCMPIArgs

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (16))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        //Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);

        CIMValue paramValue = outParams[0].getValue ();
        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }
    inParams.clear();
    outParams.clear();
    {
         //_testCMPIBroker

        inParams.append (CIMParamValue ("Operation", CIMValue (Uint32 (17))));
        CIMValue retValue = client.invokeMethod (providerNamespace,
                                                 instanceName,
                                                 "TestCMPIBroker",
                                                 inParams,
                                                 outParams);
        //Check the return value. Make sure it is 0.
        _checkUint32Value (retValue, 0);
        // Nothing is returned
        PEGASUS_TEST_ASSERT (outParams.size () == 1);

        CIMValue paramValue = outParams[0].getValue ();

        PEGASUS_TEST_ASSERT (paramValue.isNull ());
    }

}