Beispiel #1
0
int main(int argc, char** argv)
{
    pid_t pid;    
    try
    {
        CIMClient client;

        client.connect("localhost", 5988, "", "");

        if ((pid = fork()) < 0)
        {
                cout << "Fork Error\n" << endl;
                exit(0);
        }
        else if (pid == 0) 
        {   // child
            sleep(10);
            EnumerateInstancesTiming(client, CLASSONE);
            _exit(0);
        }
		// parent
        sleep(10);
        EnumerateInstancesTiming(client, CLASSTWO);
       	sleep(5); 
        EnumerateClassesTiming(client, "TimingSampleClass");
    }
    catch(Exception& e)
    {
        PEGASUS_STD(cerr) << "Error: " << e.getMessage() << 
            PEGASUS_STD(endl);
        exit(1);
    }
    return 0;
}
Beispiel #2
0
int main (int argc, char* argv [])
{
    MTTestClient    command = MTTestClient ();
    int                rc;

    try
    {
        command.setCommand (argc, argv);
    }
    catch (const CommandFormatException& cfe)
    {
        cerr << MTTestClient::COMMAND_NAME << ": " << cfe.getMessage ()
             << endl;
        cerr << command.getUsage () << endl;
        exit (Command::RC_ERROR);
    }
    catch (const Exception& e)
    {
        cerr << MTTestClient::COMMAND_NAME << ": " << e.getMessage ()
             << endl;
    }

    rc = command.execute (cout, cerr);

    PEGASUS_STD(cout) <<  "+++++ passed all tests" << PEGASUS_STD(endl);
    exit (rc);
    return 0;
}
int main (int argc, char** argv)
{
    CIMClient client;
    try
    {
        client.connectLocal ();
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << e.getMessage () << PEGASUS_STD (endl);
        return -1;
    }

    if (argc != 3)
    {
        _usage ();
        return 1;
    }

    const char* opt = argv[1];
    const char* optLang = argv[2];
    String qlang(optLang);

#ifndef PEGASUS_ENABLE_CQL
    if (qlang == "DMTF:CQL")
    {
        PEGASUS_STD(cout) << "+++++ cql test disabled" << PEGASUS_STD(endl);
        return 0;
    }
#endif

    return _test(client, opt, qlang);
}
int main (int argc, char** argv)
{
    String stringVal;
    verbose = (getenv("PEGASUS_TEST_VERBOSE")) ? true : false;

    CIMClient client;
    try
    {
        client.connectLocal ();
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << e.getMessage () << PEGASUS_STD (endl);
        return -1;
    }

    _enumerateInstanceNames(client);
    _getInstance(client);
    _setProperty(client, 7890);
    _getProperty(client);
    // getProperty() only returns CIMValues of type String.
    value.get(stringVal);
    PEGASUS_TEST_ASSERT(atoi((const char*)stringVal.getCString())==7890);
    _setProperty(client,1234);
    _getProperty(client);
    // getProperty() only returns CIMValues of type String.
    // Verify that setProperty worked as expected.
    value.get(stringVal);
    PEGASUS_TEST_ASSERT(atoi((const char*)stringVal.getCString())==1234);

    return 0;
}
void _usage ()
{
    PEGASUS_STD (cerr) 
        << "Usage: TestDisableEnable2 "
        << "{setup | setup2 | create | create2 "
        << "| sendSucceed | sendFail | sendBlock "
        << "| delete | delete2 | cleanup | cleanup2} {WQL | DMTF:CQL}" 
        << PEGASUS_STD (endl);
}
Beispiel #6
0
int main(int argc, char** argv)
{
    try
    {
        CIMClient client;
        client.connect("localhost", 5988, String::EMPTY, String::EMPTY);
        
        Array<CIMInstance> ia;
        try
        {
          ia = client.enumerateInstances(NAMESPACE,CIMName("PG_WBEMSLPTemplate"));
        }
        catch (Exception& e)
        {
           cout<<e.getMessage()<<endl;
        }

      // There should be one instance
       if (ia.size() == 0)
       {
         cout << "+++++ Error: enumerateInstances on WBEMSLPTemplate" << endl;
         cout << "+++++ Test failed" << endl;
         return 1;
       }
       else
       {
	      
       Array<CIMObjectPath> instanceNames = client.enumerateInstanceNames(NAMESPACE,CIMName("CIM_WBEMSLPTemplate"));

            

       for (Uint32 i = 0; i < instanceNames.size(); i++)
       {
          CIMInstance i1 = client.getInstance(NAMESPACE,instanceNames[i]);
          Uint32 NumProperties;
          cout << "Getting all properties for WBEMSLPTemplate instance .....  " << i+1 <<"\n";

          NumProperties = i1.getPropertyCount();
          for(Uint32 i=0;i<NumProperties;i++)
          {
            CIMProperty p1=i1.getProperty(i);
            CIMValue v1=p1.getValue();
            CIMName n1=p1.getName();
			cout << n1.getString() << " is "  << v1.toString() << "\n";
          }
      }
      }
    }
    catch(Exception& e)
    {
       PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
       exit(1);
    }

     cout << "Client Execution finished"<< endl;
     return 0;
}
Beispiel #7
0
void RT_IndicationProvider::_checkOperationContext(const OperationContext& context,
                                                  const String &  funcName)
{
	 //
	 // Test the filter query container
	 //
	 SubscriptionFilterQueryContainer qContainer = context.get(SubscriptionFilterQueryContainer::NAME);
    if (qContainer.getFilterQuery() == String::EMPTY)
    {
      PEGASUS_STD(cout) << funcName << "- empty filter query" << PEGASUS_STD(endl);
      throw CIMOperationFailedException(funcName + "- empty filter query");
    }
    if (qContainer.getQueryLanguage() == String::EMPTY)
    {
      PEGASUS_STD(cout) << funcName << "- empty filter query lang" << PEGASUS_STD(endl);
      throw CIMOperationFailedException(funcName + "- empty filter query lang");
    }

    CIMNamespaceName tst("root/SampleProvider");
    if (!qContainer.getSourceNameSpace().equal(tst))
    {
      PEGASUS_STD(cout) << funcName << "- incorrect source namespace" << PEGASUS_STD(endl);
      throw CIMOperationFailedException(funcName + "- incorrect source namespace");
    }

    try
    {
      //
      // Try to parse the filter query from the filter query container
      //
      CIMOMHandleQueryContext ctx(qContainer.getSourceNameSpace(), _cimom);
      QueryExpression qe(qContainer.getQueryLanguage(),
                         qContainer.getFilterQuery(),
                         ctx);

      // Exercise the QueryExpression...this will cause repository access through
      // the CIMOMHandleQueryContext.
      qe.validate();
    }
    catch (Exception & e)
    {
      PEGASUS_STD(cout) << funcName << "- parse error: " << e.getMessage() << PEGASUS_STD(endl);
      throw CIMOperationFailedException(funcName + "- parse error: " + e.getMessage());
    }

    //
    // Test the filter condition container.
    // Note:  since this only contains the WHERE clause, the condition could be empty (and will
    // be for some testcases)
    //
    SubscriptionFilterConditionContainer cContainer = context.get(SubscriptionFilterConditionContainer::NAME);
	 if (cContainer.getQueryLanguage() == String::EMPTY)
    {
      PEGASUS_STD(cout) << funcName << "- empty filter condition lang" << PEGASUS_STD(endl);
      throw CIMOperationFailedException(funcName + "- empty filter condition lang");
    }
}
int _test(CIMClient& client, const char* opt, String& qlang)
{
  if (String::equalNoCase (opt, "setup"))
  {
    _setup (client, qlang);
  }
  else if (String::equalNoCase (opt, "setup2"))
  {
    _setup2 (client, qlang);
  }
  else if (String::equalNoCase (opt, "create"))
  {
    _create (client);
  }
  else if (String::equalNoCase (opt, "create2"))
  {
    _create2 (client);
  }
  else if (String::equalNoCase (opt, "sendSucceed"))
  {
    _sendSucceed (client);
  }
  else if (String::equalNoCase (opt, "sendFail"))
  {
    _sendFail (client);
  }
  else if (String::equalNoCase (opt, "sendBlock"))
  {
    _sendBlock (client);
  }
  else if (String::equalNoCase (opt, "delete"))
  {
    _delete (client);
  }
  else if (String::equalNoCase (opt, "delete2"))
  {
    _delete2 (client);
  }
  else if (String::equalNoCase (opt, "cleanup"))
  {
    _cleanup (client);
  }
  else if (String::equalNoCase (opt, "cleanup2"))
  {
    _cleanup2 (client);
  }
  else
  {
    PEGASUS_STD (cerr) << "Invalid option: " << opt 
                       << PEGASUS_STD (endl);
    _usage ();
    return -1;
  }
  
  return 0;
}
void MessageQueueService::handle_CimServiceStop(CimServiceStop *req)
{
#ifdef MESSAGEQUEUESERVICE_DEBUG
   PEGASUS_STD(cout) << getQueueName() << "received STOP" << PEGASUS_STD(endl);
#endif
   // set the stopeed bit and update
   _capabilities |= module_capabilities::stopped;
   _make_response(req, async_results::CIM_STOPPED);
   // now tell the meta dispatcher we are stopped
   update_service(_capabilities, _mask);
}
void OOPModuleFailureTestProvider::invokeMethod (
    const OperationContext & context,
    const CIMObjectPath & objectReference,
    const CIMName & methodName,
    const Array <CIMParamValue> & inParameters,
    MethodResultResponseHandler & handler)
{
    Boolean sendIndication = false;
    String identifier;
    handler.processing ();

    if (objectReference.getClassName ().equal ("FailureTestIndication") &&
        _enabled)
    {
        if (methodName.equal ("SendTestIndication"))
        {
            if ((inParameters.size() > 0) &&
                (inParameters[0].getParameterName () == "identifier"))
            {
                inParameters[0].getValue().get(identifier);
            }
            sendIndication = true;
            handler.deliver (CIMValue (0));
        }
    }
    else
    {
         handler.deliver (CIMValue (1));
         PEGASUS_STD (cout) << "Provider is not enabled." <<
         PEGASUS_STD (endl);
    }

    handler.complete ();

    if (sendIndication)
    {
        _generateIndication (_handler, identifier);
    }

    //
    //  If I am the OOPModuleInvokeFailureTestProvider, fail (i.e. exit)
    //
    if (String::equalNoCase (_providerName,
        "OOPModuleInvokeFailureTestProvider"))
    {
        if (methodName.equal ("Fail"))
        {
            exit (-1);
        }
    }
}
int removeErrorInstance(CIMClient& client)
{
    try
    {
        client.deleteInstance(TEST_NAMESPACE, errorPath);
    }
    catch (Exception & e)
    {
        PEGASUS_STD(cout)
            << "Exception encountered while removing Error Instance: "
            << e.getMessage() << PEGASUS_STD(endl);
    }
    return 0;
}
int retrieveIndicationInstance(CIMClient& client)
{
    // Approximates a timeout, each loop is roughly 1 second
    Uint32 loopCount = 0;
    while ((receivedIndications == 0) && (loopCount < MAX_COUNT))
    {
        Thread::sleep(1000);
        loopCount++;
    }

    AutoMutex a(*mut);
    Array<CIMInstance> indications;
    try
    {
        indications = client.enumerateInstances(
            TEST_NAMESPACE, "PG_InstMethodIndication");
    }
    catch (Exception& e)
    {
        cout << "Exception caught while enumerating indications: "
            << e.getMessage() << endl;
        return -1;
    }

    if (indications.size() != 5)
    {
        cout << "Expected to get one instance. Received "
            << indications.size() << endl;
        return -1;
    }

    indicationInstance.reset(new CIMInstance(indications[0]));

    if (receivedIndication.get() == 0)
    {
        PEGASUS_STD(cout) << "Did not receive indication via listener" <<
            PEGASUS_STD(endl);
        return -1;
    }

    if (!indicationInstance->identical(*receivedIndication))
    {
        PEGASUS_STD(cout)
            << "Indication instance retrieved via listener does not match "
            << "instance retrieved via enumeration" << PEGASUS_STD(endl);
        return -1;
    }

    return 0;
}
void MessageQueueService::handle_CimServiceStart(CimServiceStart *req)
{

#ifdef MESSAGEQUEUESERVICE_DEBUG
   PEGASUS_STD(cout) << getQueueName() << "received START" << PEGASUS_STD(endl);
#endif

   // clear the stoped bit and update
   _capabilities &= (~(module_capabilities::stopped));
   _make_response(req, async_results::OK);
   // now tell the meta dispatcher we are stopped
   update_service(_capabilities, _mask);

}
int main(int argc, char** argv)
{
    verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false;

    const char* _pegHome = getenv ("PEGASUS_HOME");
    if (_pegHome == NULL)
    {
        PEGASUS_STD (cout) << argv[0] << " +++++ tests failed: "
            << "PEGASUS_HOME environment variable must be set"
                           << PEGASUS_STD (endl);
        return -1;
    }
    ConfigManager::setPegasusHome(_pegHome);

    try
    {
        String name;
        String ver;

        name = "C++Default";
        ver = "2.1.0";
        PEGASUS_TEST_ASSERT(
            ProviderManagerMap::instance().isValidProvMgrIfc(name, ver));
        ver = "2.6.0";
        PEGASUS_TEST_ASSERT(
            ProviderManagerMap::instance().isValidProvMgrIfc(name, ver));
        name = "Junk";
        PEGASUS_TEST_ASSERT(
            !ProviderManagerMap::instance().isValidProvMgrIfc(name, ver));
#ifdef PEGASUS_ENABLE_CMPI_PROVIDER_MANAGER
        name = "CMPI";
        ver = "2.0.0";
        PEGASUS_TEST_ASSERT(
            ProviderManagerMap::instance().isValidProvMgrIfc(name, ver));
        ver = "1.2.3";
        PEGASUS_TEST_ASSERT(
            !ProviderManagerMap::instance().isValidProvMgrIfc(name, ver));
#endif
#ifdef PEGASUS_ENABLE_JMPI_PROVIDER_MANAGER
        name = "JMPI";
        ver = "2.2.0";
        PEGASUS_TEST_ASSERT(
            ProviderManagerMap::instance().isValidProvMgrIfc(name, ver));
#endif
    }
    catch(Exception& e)
    {
    PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
    PEGASUS_STD (cout) << argv[0] << " +++++ tests failed"
                       << PEGASUS_STD (endl);
    exit(-1);
    }


    PEGASUS_STD(cout) << argv[0] << " +++++ passed all tests"
                      << PEGASUS_STD(endl);

    return 0;
}
void _sendBlock (CIMClient & client)
{
    try
    {
        _sendIndicationShouldBeBlocked (client);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "sendBlock failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }

    PEGASUS_STD (cout) << "+++++ sendBlock completed successfully"
                       << PEGASUS_STD (endl);
}
Beispiel #16
0
void RT_IndicationProvider::invokeMethod(
        const OperationContext & context,
        const CIMObjectPath & objectReference,
        const CIMName & methodName,
        const Array<CIMParamValue> & inParameters,
        MethodResultResponseHandler & handler)
{
        Boolean sendIndication = false;
        handler.processing();

        if (objectReference.getClassName().equal ("RT_TestIndication") &&
	    _enabled)
        {
            if ((methodName.equal ("SendTestIndication")) ||
                (methodName.equal ("SendTestIndicationNormal")) ||
                (methodName.equal ("SendTestIndicationMissingProperty")) ||
                (methodName.equal ("SendTestIndicationExtraProperty")) ||
                (methodName.equal ("SendTestIndicationMatchingInstance")) ||
                (methodName.equal ("SendTestIndicationUnmatchingNamespace")) ||
                (methodName.equal ("SendTestIndicationUnmatchingClassName")))
            {
                sendIndication = true;
                handler.deliver( CIMValue( 0 ) );
            }
        }

        else if ((objectReference.getClassName ().equal
            ("RT_TestIndicationSubclass")) && _enabled)
        {
            if (methodName.equal ("SendTestIndicationSubclass"))
            {
                sendIndication = true;
                handler.deliver( CIMValue( 0 ) );
            }
        }

        else
        {
             handler.deliver( CIMValue( 1 ) );
	     PEGASUS_STD(cout) << "Provider is not enabled." << PEGASUS_STD(endl);
        }

        handler.complete();

        if (sendIndication)
           _generateIndication(_handler, methodName);
}
void _cleanup2 (CIMClient & client)
{
    try
    {
        _deleteHandlerInstance (client, String ("DEHandler02"), NAMESPACE2);
        _deleteFilterInstance (client, String ("DEFilter02"), NAMESPACE1);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "cleanup2 failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }

    PEGASUS_STD (cout) << "+++++ cleanup2 completed successfully"
                       << PEGASUS_STD (endl);
}
void _delete2 (CIMClient & client)
{
    try
    {
        _deleteSubscriptionInstance (client, String ("DEFilter02"),
            String ("DEHandler02"), NAMESPACE1, NAMESPACE2, NAMESPACE3);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "delete2 failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }

    PEGASUS_STD (cout) << "+++++ delete2 completed successfully"
                       << PEGASUS_STD (endl);
}
void _testDuplicate(CIMClient &client)
{
    CIMObjectPath filterPath;
    CIMObjectPath handlerPath;
    CIMObjectPath subscriptionPath;

    try
    {
        handlerPath = CreateHandler1Instance(client,
            PEGASUS_NAMESPACENAME_INTEROP);
        filterPath = CreateFilterInstance(client,
            QUERY1, "WQL", "Filter1",
            PEGASUS_NAMESPACENAME_INTEROP);
        subscriptionPath = CreateSbscriptionInstance(client, handlerPath,
            filterPath, PEGASUS_NAMESPACENAME_INTEROP);

        _createDuplicate(client, String::EMPTY, CIMNamespaceName(),
            filterPath, String::EMPTY, CIMNamespaceName(), handlerPath);

        _createDuplicate(client, String::EMPTY,
            PEGASUS_NAMESPACENAME_INTEROP, filterPath,
            String::EMPTY,PEGASUS_NAMESPACENAME_INTEROP, handlerPath);

        _createDuplicate(client, "127.0.0.1",
            PEGASUS_NAMESPACENAME_INTEROP, filterPath,
            String::EMPTY, CIMNamespaceName(), handlerPath);

        _createDuplicate(client, "127.0.0.1",PEGASUS_NAMESPACENAME_INTEROP,
            filterPath, "127.0.0.1", PEGASUS_NAMESPACENAME_INTEROP,
            handlerPath);

        _createDuplicate(client, String::EMPTY, CIMNamespaceName(),
            filterPath, "127.0.0.1", PEGASUS_NAMESPACENAME_INTEROP,
            handlerPath);
        _checkSubscriptionCount(client);
        DeleteInstance(client, subscriptionPath, PEGASUS_NAMESPACENAME_INTEROP);
        DeleteInstance(client, filterPath, PEGASUS_NAMESPACENAME_INTEROP);
        DeleteInstance(client, handlerPath, PEGASUS_NAMESPACENAME_INTEROP);
    }
    catch (const CIMException &e)
    {
        PEGASUS_STD(cerr) << "Exception: " << e.getMessage()
                          << PEGASUS_STD (endl);
        PEGASUS_TEST_ASSERT(0);
    }
}
Beispiel #20
0
static Boolean verifyCertificate(SSLCertificateInfo &certInfo)
{

#ifdef DEBUG
    PEGASUS_STD(cout) << certInfo.getSubjectName() << endl;
#endif
    //ATTN-NB-03-05132002: Add code to handle server certificate verification.
    return true;
}
Beispiel #21
0
int ServerProcess::cimserver_fork(void) 
{ 
    getSigHandle()->registerHandler(PEGASUS_SIGUSR1, sigUsr1Handler);
    getSigHandle()->activate(PEGASUS_SIGUSR1);
    getSigHandle()->registerHandler(SIGTERM, sigTermHandler);
    getSigHandle()->activate(SIGTERM);
 
  pid_t pid;
  if( (pid = fork() ) < 0) 
  {
      getSigHandle()->deactivate(PEGASUS_SIGUSR1);
      getSigHandle()->deactivate(SIGTERM);
      return(-1);
  }
  else if (pid != 0)
  {
      //
      // parent wait for child
      // if there is a problem with signal, parent process terminates
      // when waitTime expires
      //
      Uint32 waitTime = MAX_WAIT_TIME;

      while(!handleSigUsr1 && waitTime > 0)
      {
        sleep(1);
        waitTime--;
      }
      if( !handleSigUsr1 )
        {
        MessageLoaderParms parms("src.Service.ServerProcessUnix.CIMSERVER_START_TIMEOUT",
          "The cimserver command timed out waiting for the CIM server to start.");
        PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
      }
      exit(graveError);
  }
  
  setsid();
  umask(0);

  // get the pid of the cimserver process
  server_pid = getpid();
  return(0);
}
void _getInstance(CIMClient & client)
{
    try
    {
        instance = client.getInstance(SOURCE_NAMESPACE, objectNames[0]);
        if (verbose)
        {
            XmlWriter::printInstanceElement(instance, PEGASUS_STD(cout));
            PEGASUS_STD (cout) << "+++++ getInstance completed successfully"
                               << PEGASUS_STD (endl);
        }
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "getInstance failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }
}
//
// Tests subscription creation by sending the similar concurrent subscription
// creation requests .
//
void _testConcurrent(CIMClient &client)
{
    CIMObjectPath filterPath;
    CIMObjectPath handlerPath;
    CIMObjectPath subscriptionPath;
    try
    {
        HandlerPath = CreateHandler1Instance(client,
            PEGASUS_NAMESPACENAME_INTEROP);
        FilterPath = CreateFilterInstance(client,
            QUERY1, "WQL", "Filter1",
            PEGASUS_NAMESPACENAME_INTEROP);

        Thread thread1(createSubscriptionFunc, (void *)0, false);
        Thread thread2(createSubscriptionFunc, (void *)0, false);
        Thread thread3(createSubscriptionFunc, (void *)0, false);
        Thread thread4(createSubscriptionFunc, (void *)0, false);

        thread1.run();
        thread2.run();
        thread3.run();
        thread4.run();

        thread1.join();
        thread2.join();
        thread3.join();
        thread4.join();

        _checkSubscriptionCount(client);

        PEGASUS_TEST_ASSERT(exceptionCount.get() == 3);

        DeleteInstance(client, SubscriptionPath, PEGASUS_NAMESPACENAME_INTEROP);
        DeleteInstance(client, FilterPath, PEGASUS_NAMESPACENAME_INTEROP);
        DeleteInstance(client, HandlerPath, PEGASUS_NAMESPACENAME_INTEROP);
   }
   catch(const CIMException &e)
   {
      PEGASUS_STD(cerr) << "Exception: " << e.getMessage()
                        << PEGASUS_STD (endl);
      PEGASUS_TEST_ASSERT(0);
   }
}
Beispiel #24
0
int main (int argc, char** argv)
{
    verbose = getenv ("PEGASUS_TEST_VERBOSE") ? true : false;

    try
    {
        test01 ();

        PEGASUS_STD (cout) << argv [0] << " +++++ passed all tests"
                           << PEGASUS_STD (endl);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << argv [0] << " Exception " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (1);
    }
    return 0;
}
void _create2 (CIMClient & client)
{
    try
    {
        _createSubscriptionInstance (client, 
            _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDFILTER, 
                "DEFilter02", NAMESPACE1),
            _buildFilterOrHandlerPath (PEGASUS_CLASSNAME_INDHANDLER_CIMXML,
                "DEHandler02", NAMESPACE2), NAMESPACE3);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "create2 failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }

    PEGASUS_STD (cout) << "+++++ create2 completed successfully"
                       << PEGASUS_STD (endl);
}
void MessageQueueService::handle_AsyncIoctl(AsyncIoctl *req)
{
   switch (req->ctl)
   {
      case AsyncIoctl::IO_CLOSE:
      {
         MessageQueueService *service = static_cast<MessageQueueService *>(req->op->_service_ptr);

#ifdef MESSAGEQUEUESERVICE_DEBUG
         PEGASUS_STD(cout) << service->getQueueName() << " Received AsyncIoctl::IO_CLOSE " << PEGASUS_STD(endl);
#endif

         // respond to this message. this is fire and forget, so we don't need to delete anything.
         // this takes care of two problems that were being found
         // << Thu Oct  9 10:52:48 2003 mdd >>
          _make_response(req, async_results::OK);
         // ensure we do not accept any further messages

         // ensure we don't recurse on IO_CLOSE
         if (_incoming_queue_shutdown.value() > 0)
            break;

         // set the closing flag
         service->_incoming_queue_shutdown = 1;
         // empty out the queue
         while (1)
         {
            AsyncOpNode *operation;
            try
            {
               operation = service->_incoming.remove_first();
            }
            catch(IPCException &)
            {
               break;
            }
            if (operation)
            {
               operation->_service_ptr = service;
               service->_handle_incoming_operation(operation);
            }
            else
               break;
         } // message processing loop

         // shutdown the AsyncDQueue
         service->_incoming.shutdown_queue();
         return;
      }

      default:
         _make_response(req, async_results::CIM_NAK);
   }
}
void _setup2 (CIMClient & client, String& qlang)
{
    try
    {
        _createFilterInstance (client, String ("DEFilter02"),
            String ("SELECT MethodName FROM Test_IndicationProviderClass"),
            qlang, NAMESPACE1);
        _createHandlerInstance (client, String ("DEHandler02"), 
            String ("localhost/CIMListener/Pegasus_SimpleDisplayConsumer"),
            NAMESPACE2);
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "setup2 failed: " << e.getMessage ()
                           << PEGASUS_STD (endl);
        exit (-1);
    }

    PEGASUS_STD (cout) << "+++++ setup2 completed successfully"
                       << PEGASUS_STD (endl);
}
int main(int, char** argv)
{
    try
    {
        TestProviderManager myPM;
        myPM.unloadIdleProviders();
        PEGASUS_TEST_ASSERT(myPM.supportsRemoteNameSpaces() == false);
        PEGASUS_TEST_ASSERT(myPM.hasActiveProviders() == true);
        PEGASUS_TEST_ASSERT(myPM.processMessage(0) == 0);
    }
    catch (Exception& e)
    {
        PEGASUS_STD(cout) << "Exception: " << e.getMessage() <<
            PEGASUS_STD(endl);
        exit(1);
    }

    PEGASUS_STD(cout) << argv[0] << " +++++ passed all tests" <<
        PEGASUS_STD(endl);
    return 0;
}
Beispiel #29
0
static inline BufferRep* _reallocate(BufferRep* rep, Uint32 cap)
{
    // Allocate an extra byte for null-termination performed by getData().
    rep = (BufferRep*)realloc(rep, sizeof(BufferRep) + cap + 1);

    if (!rep)
    {
        throw PEGASUS_STD(bad_alloc)();
    }
    rep->cap = cap;
    return rep;
}
void _enumerateInstanceNames(CIMClient & client)
{
    try
    {
        objectNames = client.enumerateInstanceNames(
                                 SOURCE_NAMESPACE,
                                 SAMPLE_CLASSNAME);
        if (verbose)
        {
            PEGASUS_STD (cout) << "+++++ enumerateInstanceNames "
                                      "completed successfully"
                               << PEGASUS_STD (endl);
        }
    }
    catch (Exception & e)
    {
        PEGASUS_STD (cerr) << "enumerateInstanceNames failed: "
                           << e.getMessage() << PEGASUS_STD (endl);
        exit (-1);
    }
}