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

📄 testindications.java

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
         // returns: CIM_ERR_NOT_SUPPORTED (CIM_ERR_NOT_SUPPORTED: The requested operation is not supported: "The specified class is not served by the Indication Service")      }      else if (false)      {         // PG_ListenerDestinationEmail         ccHandler = cc.getClass (new CIMObjectPath ("PG_ListenerDestinationEmail",                                                     nameSpaceInterOp),                                  false);         ciHandler = ccHandler.newInstance ();         ciHandler.setProperty ("CreationClassName",                                new CIMValue ("PG_ListenerDestinationEmail"));         Vector vectorMailTo = new Vector ();         vectorMailTo.addElement ("root@" + getHostname ());         ciHandler.setProperty ("MailTo",                                new CIMValue (vectorMailTo));         ciHandler.setProperty ("MailSubject",                                new CIMValue ("Hello Indication"));         // terminate called after throwing an instance of 'Pegasus::TypeMismatchException'      }      ciHandler.setProperty ("Name",                             new CIMValue ("classCreationHandler"));      ciHandler.setProperty ("SystemCreationClassName",                             new CIMValue ("CIM_ComputerSystem"));      try      {         copHandler = createInstance (cc,                                      ciHandler,                                      nameSpaceInterOp);      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("testIndications::testCreateClassIndicationHandler: Exception: " + e);            e.printStackTrace ();         }      }      if (DEBUG)      {         System.err.println ("testIndications::testCreateClassIndicationHandler: copHandler = " + copHandler);      }      if (copHandler != null)      {         System.out.println ("SUCCESS: testCreateClassIndicationHandler");      }      else      {         System.out.println ("FAIL: testCreateClassIndicationHandler");      }      return copHandler;   }   private static CIMObjectPath testCreateClassIndicationSubscription (CIMClient     cc,                                                                       CIMObjectPath copFilter,                                                                       CIMObjectPath copHandler)      throws Exception   {      CIMClass      ccSubscription  = cc.getClass (new CIMObjectPath ("CIM_IndicationSubscription",                                                                      nameSpaceInterOp),                                                   false);      CIMInstance   ciSubscription  = ccSubscription.newInstance ();      CIMObjectPath copSubscription = null;      ciSubscription.setProperty ("Filter", new CIMValue (copFilter));      ciSubscription.setProperty ("Handler", new CIMValue (copHandler));      ciSubscription.setProperty ("SubscriptionState", new CIMValue (new UnsignedInt16 ("2")));      try      {         copSubscription = createInstance (cc,                                           ciSubscription,                                           nameSpaceInterOp);      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("testIndications::testCreateClassIndicationHandler: Exception: " + e);            e.printStackTrace ();         }      }      if (DEBUG)      {         System.err.println ("testIndications::testCreateClassIndicationHandler: copSubscription = " + copSubscription);      }      if (copSubscription != null)      {         System.out.println ("SUCCESS: testCreateClassIndicationSubscription");      }      else      {         System.out.println ("FAIL: testCreateClassIndicationSubscription");      }      return copSubscription;   }   private static boolean testCreateIndication (CIMClient cc,                                                int       iInstanceId)      throws Exception   {      CIMObjectPath copTestIndication    = new CIMObjectPath (className,                                                              nameSpaceClass);      String        methodName           = "SendTestIndicationNormal";      UnsignedInt64 ui64IndicationNumber = findNextIndicationNumber (cc);      Vector        inArgs               = new Vector ();      Vector        outArgs              = new Vector ();      CIMValue      cvRet                = null;      inArgs.addElement (new CIMProperty ("indicationSendCount",                                          new CIMValue (ui64IndicationNumber)));      if (DEBUG)      {         System.err.println ("testIndications::testCreateIndication: Calling " + methodName + " (" + inArgs + ", " + outArgs + ")");      }      try      {         cvRet = cc.invokeMethod (copTestIndication,                                  methodName,                                  inArgs,                                  outArgs);      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("Caught " + e);            e.printStackTrace ();         }      }      if (cvRet == null)      {         System.out.println ("FAIL: testCreateIndication: ret == null");         return false;      }      else if (((UnsignedInt32)cvRet.getValue ()).intValue () != 0)      {         System.out.println ("FAIL: testCreateIndication: ret (" + cvRet.getValue () + ") != 0");         return false;      }      else      {         System.out.println ("SUCCESS: testCreateIndication (" + ui64IndicationNumber + ")");         return true;      }   }   private static boolean testExecQueryIndication (CIMClient cc)   {      CIMObjectPath copTestIndication  = new CIMObjectPath (className,                                                            nameSpaceClass);      Enumeration   enm                = null;      int           iInstancesReturned = 0;      try      {         enm = cc.execQuery (copTestIndication,                             "SELECT InstanceId FROM " + className + " WHERE InstanceId = 1",                             "WQL");      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("Caught " + e);            e.printStackTrace ();         }      }      if (enm == null)      {         if (fBugExistsExecQuery)         {            System.out.println ("IGNORE: testExecQueryIndication: enm == null");            return true;         }         else         {            System.out.println ("FAIL: testExecQueryIndication: enm == null");            return false;         }      }      if (DEBUG)      {         System.err.println ("enm.hasMoreElements () = " + enm.hasMoreElements ());      }      while (enm.hasMoreElements ())      {         CIMInstance elm = (CIMInstance)enm.nextElement ();         if (DEBUG)         {            System.err.println ("elm = " + elm);         }         iInstancesReturned++;      }      if (iInstancesReturned == 1)      {         System.out.println ("SUCCESS: testExecQueryIndication = 1");      }      else      {         System.out.println ("FAIL: testExecQueryIndication iInstancesReturned != 1 (" + iInstancesReturned + ")");         return false;      }      iInstancesReturned = 0;      try      {         enm = cc.execQuery (copTestIndication,                             "SELECT InstanceId FROM " + className + " WHERE InstanceId <= 5",                             "WQL");      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("Caught " + e);            e.printStackTrace ();         }      }      if (enm == null)      {         System.out.println ("FAIL: testExecQueryIndication: enm == null");         return false;      }      if (DEBUG)      {         System.err.println ("enm.hasMoreElements () = " + enm.hasMoreElements ());      }      while (enm.hasMoreElements ())      {         CIMInstance elm = (CIMInstance)enm.nextElement ();         if (DEBUG)         {            System.err.println ("elm = " + elm);         }         iInstancesReturned++;      }      if (iInstancesReturned == 5)      {         System.out.println ("SUCCESS: testExecQueryIndication <= 5");      }      else      {         System.out.println ("FAIL: testExecQueryIndication iInstancesReturned != 5 (" + iInstancesReturned + ")");         return false;      }      return true;   }   private static boolean testDeleteClassIndicationSubscription (CIMClient     cc,                                                                 CIMObjectPath copSubscription)   {      try      {         cc.deleteInstance (copSubscription);         System.out.println ("SUCCESS: testDeleteClassIndicationSubscription");         return true;      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("Caught " + e);            e.printStackTrace ();         }      }      System.out.println ("FAIL: testDeleteClassIndicationSubscription");      return false;   }   private static boolean testDeleteClassIndicationHandler (CIMClient     cc,                                                            CIMObjectPath copHandler)   {      try      {         cc.deleteInstance (copHandler);         System.out.println ("SUCCESS: testDeleteClassIndicationHandler");         return true;      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("Caught " + e);            e.printStackTrace ();         }      }      System.out.println ("FAIL: testDeleteClassIndicationHandler");      return false;   }   private static boolean testDeleteClassIndicationFilter (CIMClient     cc,                                                           CIMObjectPath copFilter)   {      try      {         cc.deleteInstance (copFilter);         System.out.println ("SUCCESS: testDeleteClassIndicationFilter");         return true;      }      catch (Exception e)      {         if (DEBUG)         {            System.err.println ("Caught " + e);            e.printStackTrace ();         }      }      System.out.println ("FAIL: testDeleteClassIndicationFilter");      return false;   }   private static boolean runTests (CIMClient cc)   {      CIMObjectPath copFilter       = null;      CIMObjectPath copHandler      = null;      CIMObjectPath copSubscription = null;      try      {         copFilter = testCreateClassIndicationFilter (cc);         if (copFilter == null)         {            return false;         }         copHandler = testCreateClassIndicationHandler (cc);         if (copHandler == null)         {            return false;         }         copSubscription = testCreateClassIndicationSubscription (cc, copFilter, copHandler);         if (copSubscription == null)         {            return false;         }         for (int i = 1; i <= iNumIndications; i++)         {            if (!testCreateIndication (cc, i))            {               return false;            }         }         testExecQueryIndication (cc);         if (DELETE)         {            testDeleteClassIndicationSubscription (cc, copSubscription);            testDeleteClassIndicationHandler (cc, copHandler);            testDeleteClassIndicationFilter (cc, copFilter);         }         return true;      }      catch (Exception e)      {         if (DEBUG)         {            System.out.println ("Caught " + e);            e.printStackTrace ();         }      }      return false;   }}

⌨️ 快捷键说明

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