📄 testcimclient.java
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////%/////////////////////////////////////////////////////////////////////////////package Client;import java.util.Enumeration;import java.util.Vector;import org.pegasus.jmpi.CIMArgument;import org.pegasus.jmpi.CIMClass;import org.pegasus.jmpi.CIMClient;import org.pegasus.jmpi.CIMDateTime;import org.pegasus.jmpi.CIMException;import org.pegasus.jmpi.CIMInstance;import org.pegasus.jmpi.CIMNameSpace;import org.pegasus.jmpi.CIMObjectPath;import org.pegasus.jmpi.CIMProperty;import org.pegasus.jmpi.CIMQualifierType;import org.pegasus.jmpi.CIMValue;import org.pegasus.jmpi.UnsignedInt8;import org.pegasus.jmpi.UnsignedInt16;import org.pegasus.jmpi.UnsignedInt32;import org.pegasus.jmpi.UnsignedInt64;// cimcli dq -n root/SampleProvider JMPINewQualifierTypepublic class testCIMClient{ final String classNameInstanceParent = "JMPIExpInstance_TestElement"; final String classNameInstanceChild = "JMPIExpInstance_TestPropertyTypes"; final String classNamePropertyChild = "JMPIProperty_TestPropertyTypes"; final String classNameAssociationTeacher = "JMPIExpAssociation_Teacher"; final String nameSpaceClass = "root/SampleProvider"; final String hostName = "localhost"; private static boolean DEBUG = false; /** * This returns the group name. * * @return String "class" testcase belongs in. */ public String getGroup () { return "CIMClient"; } public void setDebug (boolean fDebug) { DEBUG = fDebug; } public boolean main (String args[], CIMClient cimClient) { boolean fExecuted = false; boolean fRet = true; for (int i = 0; i < args.length; i++) { if (args[i].equalsIgnoreCase ("debug")) { setDebug (true); } } if (!fExecuted) { fRet = testCIMClient (cimClient); } return fRet; } private boolean testCIMClient (CIMClient cimClient) { try { if (DEBUG) { System.err.println ("Get name space"); } CIMNameSpace cns = cimClient.getNameSpace (); if (DEBUG) { System.err.println ("cns = " + cns); } try { cns = new CIMNameSpace (); if (DEBUG) { System.err.println ("cns = " + cns); System.err.println ("Set name space"); } cns.setNameSpace ("test/newnamespace"); if (DEBUG) { System.err.println ("Create name space"); } cimClient.createNameSpace (cns); } catch (CIMException e) { if (e.getID () != CIMException.CIM_ERR_NOT_FOUND) { System.err.println ("Error: Exception: " + e); e.printStackTrace (); System.out.println ("FAIL (1): testCIMClient: createNameSpace"); return false; } } //8<--------8<--------8<--------8<--------8<--------8<--------8<-------- cns = new CIMNameSpace (); if (DEBUG) { System.err.println ("cns = " + cns); System.err.println ("Set name space"); } cns.setNameSpace ("root/newnamespace"); if (DEBUG) { System.err.println ("Create name space"); } cimClient.createNameSpace (cns); if (DEBUG) { System.err.println ("Delete name space"); } cimClient.deleteNameSpace (cns); //8<--------8<--------8<--------8<--------8<--------8<--------8<-------- Enumeration enm; CIMObjectPath cop; cop = new CIMObjectPath (classNameInstanceChild, "root"); if (DEBUG) { System.err.println ("cop = " + cop); System.err.println ("Enumerate name space: enumNameSpace"); } // NOTE: This call only cares about the name space within cop. // This is confusing and should be changed. enm = cimClient.enumNameSpace (cop, true); if (DEBUG) { System.err.println ("enm = " + enm); } if ( enm == null || !enm.hasMoreElements () ) { System.out.println ("FAIL (2): testCIMClient: enumNameSpace"); return false; } while (enm.hasMoreElements ()) { String nameSpace = (String)enm.nextElement (); if (DEBUG) { System.err.println ("nameSpace = " + nameSpace); } } //8<--------8<--------8<--------8<--------8<--------8<--------8<-------- if (DEBUG) { System.err.println ("cop = " + cop); System.err.println ("Enumerate name space: enumerateNameSpaces"); } // NOTE: This call only cares about the name space within cop. // This is confusing and should be changed. enm = cimClient.enumerateNameSpaces (cop, true); if (DEBUG) { System.err.println ("enm = " + enm); } if ( enm == null || !enm.hasMoreElements () ) { System.out.println ("FAIL (3): testCIMClient: enumNameSpace"); return false; } while (enm.hasMoreElements ()) { String nameSpace = (String)enm.nextElement (); if (DEBUG) { System.err.println ("nameSpace = " + nameSpace); } } //8<--------8<--------8<--------8<--------8<--------8<--------8<-------- cop = new CIMObjectPath (classNameInstanceParent, nameSpaceClass); if (DEBUG) { System.err.println ("cop = " + cop); System.err.println ("Enumerate class: enumClass"); } enm = cimClient.enumClass (cop, true, // deepInheritance false); // localOnly if (DEBUG) { System.err.println ("enm = " + enm); } if ( enm == null || !enm.hasMoreElements () ) { System.out.println ("FAIL (4): testCIMClient: enumClass"); return false; } CIMClass cc = (CIMClass)enm.nextElement (); if (DEBUG) { System.err.println ("cc = " + cc); } // There should be only one class if (enm.hasMoreElements ()) { System.out.println ("FAIL (5): testCIMClient: enumClass"); return false; } //8<--------8<--------8<--------8<--------8<--------8<--------8<-------- if (DEBUG) { System.err.println ("cop = " + cop); System.err.println ("Enumerate class: enumerateClasses"); } enm = cimClient.enumerateClasses (cop, true, // deepInheritance false, // localOnly true, // includeQualifiers true); // includeClassOrigin if (DEBUG) { System.err.println ("enm = " + enm); } if ( enm == null || !enm.hasMoreElements () ) { System.out.println ("FAIL (6): testCIMClient: enumerateClasses"); return false; } cc = (CIMClass)enm.nextElement (); if (DEBUG) { System.err.println ("cc = " + cc); } // There should be only one class if (enm.hasMoreElements ()) { System.out.println ("FAIL (7): testCIMClient: enumerateClasses"); return false; } //8<--------8<--------8<--------8<--------8<--------8<--------8<-------- if (DEBUG) { System.err.println ("cop = " + cop); System.err.println ("Enumerate class: enumClass"); } enm = cimClient.enumClass (cop, true); // deepInheritance if (DEBUG) { System.err.println ("enm = " + enm); } if ( enm == null || !enm.hasMoreElements () ) { System.out.println ("FAIL (8): testCIMClient: enumClass"); return false; } CIMObjectPath copRet = (CIMObjectPath)enm.nextElement (); if (DEBUG) { System.err.println ("copRet = " + copRet); } // There should be only one class if (enm.hasMoreElements ()) { System.out.println ("FAIL (9): testCIMClient: enumClass"); return false; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -