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

📄 testcimclient.java

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("ci            = " + ci);            System.err.println ("Set instance: setInstance");         }         cimClient.setInstance (cop, ci);         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------/*         ci.setProperty ("PropertyUint8", new CIMValue (new UnsignedInt8 ((short)33)));         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("ci            = " + ci);            System.err.println ("Set instance: modifyInstance");         }         cimClient.modifyInstance (cop,                                   ci,                                   true,  // includeQualifiers                                   null); // propertyList*/         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         if (DEBUG)         {            System.err.println ("copCreated    = " + copCreated);            System.err.println ("Delete instance");         }         cimClient.deleteInstance (copCreated);         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         kvp = new Vector ();         kvp.addElement (new CIMProperty ("CreationClassName",                                          new CIMValue (classNamePropertyChild)));         kvp.addElement (new CIMProperty ("InstanceId",                                          new CIMValue (new UnsignedInt64 ("1"))));         cop = new CIMObjectPath (classNamePropertyChild, kvp);         cop.setNameSpace (nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("Set property");         }         String newString = "a new string";         cimClient.setProperty (cop, "PropertyString", new CIMValue (newString));         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         kvp = new Vector ();         kvp.addElement (new CIMProperty ("CreationClassName",                                          new CIMValue (classNamePropertyChild)));/////////                                 new CIMValue (classNameInstanceChild)));         kvp.addElement (new CIMProperty ("InstanceId",                                          new CIMValue (new UnsignedInt64 ("1"))));         cop = new CIMObjectPath (classNamePropertyChild, kvp);/////////cop = new CIMObjectPath (classNameInstanceChild, kvp);         cop.setNameSpace (nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("Get property");         }         cv = cimClient.getProperty (cop, "PropertyString");         if (DEBUG)         {            System.err.println ("cv            = " + cv);         }         if (!((String)cv.getValue ()).equals (newString))         {            System.out.println ("FAIL (24): testCIMClient: setProperty/getProperty");            return false;         }         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         String stringQuery         = "SELECT InstanceId FROM " + classNameInstanceChild + " WHERE InstanceId = 1";         String stringQueryLanguage = "WQL";         cop = new CIMObjectPath (classNameInstanceChild, nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("Exec query");         }         try         {            enm = cimClient.execQuery (cop, stringQuery, stringQueryLanguage);            if (DEBUG)            {               System.err.println ("enm           = " + enm);            }            if (  enm == null               || !enm.hasMoreElements ()               )            {               System.out.println ("FAIL (25): testCIMClient: execQuery");               return false;            }            ci = (CIMInstance)enm.nextElement ();            if (DEBUG)            {               System.err.println ("ci            = " + ci);            }            // There should be only one class            if (enm.hasMoreElements ())            {               System.out.println ("FAIL (26): testCIMClient: execQuery");               return false;            }         }         catch (CIMException e)         {            if (e.getID () != CIMException.CIM_ERR_NOT_SUPPORTED)            {               throw e;            }            else            {               System.out.println ("IGNORE: testCIMClient: execQuery CIM_ERR_NOT_SUPPORTED");            }         }         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         String assocClass  = "";         String resultClass = "";         String role        = "Teaches";         String resultRole  = "";         kvp = new Vector ();         kvp.addElement (new CIMProperty ("Name",                                          new CIMValue ("Teacher1")));         kvp.addElement (new CIMProperty ("Identifier",                                          new CIMValue (new UnsignedInt8 ("1"))));         cop = new CIMObjectPath (classNameAssociationTeacher, kvp);         cop.setNameSpace (nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("Associator Names");         }         enm = cimClient.associatorNames (cop,                                          assocClass,                                          resultClass,                                          role,                                          resultRole);         if (DEBUG)         {            System.err.println ("enm           = " + enm);         }         if (  enm == null            || !enm.hasMoreElements ()            )         {            System.out.println ("FAIL (27): testCIMClient: associatorNames");            return false;         }         while (enm.hasMoreElements ())         {            cop = (CIMObjectPath)enm.nextElement ();            if (DEBUG)            {               System.err.println ("cop           = " + cop);            }         }         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         assocClass  = "";         resultClass = "";         role        = "Teaches";         resultRole  = "";         kvp = new Vector ();         kvp.addElement (new CIMProperty ("Name",                                          new CIMValue ("Teacher1")));         kvp.addElement (new CIMProperty ("Identifier",                                          new CIMValue (new UnsignedInt8 ("1"))));         cop = new CIMObjectPath (classNameAssociationTeacher, kvp);         cop.setNameSpace (nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("Associators");         }         enm = cimClient.associators (cop,                                      assocClass,                                      resultClass,                                      role,                                      resultRole,                                      true,       // includeQualifiers                                      true,       // includeClassOrigin                                      null);      // propertyList         if (DEBUG)         {            System.err.println ("enm           = " + enm);         }         if (  enm == null            || !enm.hasMoreElements ()            )         {            System.out.println ("FAIL (28): testCIMClient: associators");            return false;         }         while (enm.hasMoreElements ())         {            ci = (CIMInstance)enm.nextElement ();            if (DEBUG)            {               System.err.println ("ci            = " + ci);            }         }         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         resultClass = "";         role        = "Teaches";         kvp = new Vector ();         kvp.addElement (new CIMProperty ("Name",                                          new CIMValue ("Teacher1")));         kvp.addElement (new CIMProperty ("Identifier",                                          new CIMValue (new UnsignedInt8 ("1"))));         cop = new CIMObjectPath (classNameAssociationTeacher, kvp);         cop.setNameSpace (nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("Reference Names");         }         enm = cimClient.referenceNames (cop,                                         resultClass,                                         role);         if (DEBUG)         {            System.err.println ("enm           = " + enm);         }         if (  enm == null            || !enm.hasMoreElements ()            )         {            System.out.println ("FAIL (29): testCIMClient: referenceNames");            return false;         }         while (enm.hasMoreElements ())         {            cop = (CIMObjectPath)enm.nextElement ();            if (DEBUG)            {               System.err.println ("cop           = " + cop);            }         }         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         resultClass = "";         role        = "Teaches";         kvp = new Vector ();         kvp.addElement (new CIMProperty ("Name",                                          new CIMValue ("Teacher1")));         kvp.addElement (new CIMProperty ("Identifier",                                          new CIMValue (new UnsignedInt8 ("1"))));         cop = new CIMObjectPath (classNameAssociationTeacher, kvp);         cop.setNameSpace (nameSpaceClass);         if (DEBUG)         {            System.err.println ("cop           = " + cop);            System.err.println ("References");         }         enm = cimClient.references (cop,                                     resultClass,                                     role,                                     true,       // includeQualifiers                                     true,       // includeClassOrigin                                     null);      // propertyList         if (DEBUG)         {            System.err.println ("enm           = " + enm);         }         if (  enm == null            || !enm.hasMoreElements ()            )         {            System.out.println ("FAIL (30): testCIMClient: references");            return false;         }         while (enm.hasMoreElements ())         {            ci = (CIMInstance)enm.nextElement ();            if (DEBUG)            {               System.err.println ("ci            = " + ci);            }         }         //8<--------8<--------8<--------8<--------8<--------8<--------8<--------         System.out.println ("SUCCESS: testCIMClient");         return true;      }      catch (CIMException e)      {          System.err.println ("Error: Exception: " + e);          e.printStackTrace ();      }      return false;   }}

⌨️ 快捷键说明

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