![]() ![]() |
![]() |
File: [Pegasus] / pegasus-JavaCIMClient / cimclient / tests / ClientUnitTests / Test07.java
(download)
Revision: 1.1, Thu Jul 17 17:32:55 2003 UTC (20 years, 11 months ago) by kumpf Branch: MAIN CVS Tags: test, pegasus25BeforeLicenseUpdate, local, TEST, SLPPERFINST-root, SLPPERFINST-branch, RELEASE_2_4_FC_CANDIDATE_1, RELEASE_2_4_1-BETA3, RELEASE_2_4_1-BETA2, RELEASE_2_4_1-BETA1, RELEASE_2_4_1, RELEASE_2_4_0-RC3, RELEASE_2_4_0-RC2, RELEASE_2_4_0, RELEASE_2_4-root, RELEASE_2_4-branch, RELEASE_2_3_2-testfreeze, RELEASE_2_3_2-root, RELEASE_2_3_2-releasesnapshot, RELEASE_2_3_2-branch-freeze, RELEASE_2_3_2-branch, RELEASE_2_3_1-root, RELEASE_2_3_1-branch, RELEASE_2_3_0-root, RELEASE_2_3_0-msg-freeze, RELEASE_2_3_0-branch, PRE_LICENSE_UPDATE_2003, POST_LICENSE_UPDATE_2003, PEP217_PRE_BRANCH, PEP217_POST_BRANCH, PEP217_BRANCH, PEP214ROOT, PEP214BRANCH, PEP214-root, PEP214-branch, PEP213_SIZE_OPTIMIZATIONS, PEP-214B-root, PEG25_IBM_5_16_05, MONITOR_CONSOLIDATION_2_5_BRANCH, IBM_241_April1405, HPUX_TEST, HEAD, CQL_2_5_BRANCH, CHUNKTESTDONE_PEP140, BUG2493_BINREP-root, BUG2493_BINREP-branch Branch point for: pep_88 HP-BAPU: PEP-64 CIM Client and CIM Listener Java Interface |
// // Test07.java // // The contents of this file are subject to the SNIA Public License Version 1.0 // (the "License"); you may not use this file except in compliance with the // License. You may obtain a copy of the License at // // http://www.snia.org/resources/openSource.html // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations // under the License. // // The Original Code is Test07.java // // The Initial Developers of the Original Code are Bapu Patil // // // Revision 1.1 2002/05/15 09:36:59 bpatil // Initial revision // package tests.ClientUnitTests; import java.util.Enumeration; import java.util.Vector; import java.rmi.*; import java.rmi.server.*; import java.rmi.Naming; import java.rmi.Remote; import java.net.*; import org.snia.wbemcmd.utils.SimpleEnum; import org.snia.wbem.client.CIMClient; import org.snia.wbem.cim.CIMNameSpace; import org.snia.wbem.cim.CIMObjectPath; import org.snia.wbem.cim.CIMClass; import org.snia.wbem.cim.CIMProperty; import org.snia.wbem.cim.CIMInstance; import org.snia.wbem.cim.CIMValue; import org.snia.wbem.cim.CIMQualifierType; import org.snia.wbem.cim.CIMException; public class Test07 { public void example(String args[]){ CIMNameSpace clientNameSpace; String hostName = "localhost"; // host for cimom String nameSpace = "root/cimv2"; // namespace CIMClient cc=null; int portNo=CIMNameSpace.DEFAULT_PORT; String hostURL; if (args.length==3) { hostName=args[0]; nameSpace=args[1]; portNo=Integer.parseInt(args[2]); } else if (args.length!=0) { System.err.println("SetClass [hostname namespace portNo]"); System.exit(1); } System.err.println("Connecting to "+hostName+ " for namespace "+nameSpace); hostURL="http://"+hostName+":"+portNo; try { clientNameSpace = new CIMNameSpace(hostURL, nameSpace); cc = new CIMClient(clientNameSpace, "guest", "guest", CIMClient.XML); } catch (CIMException e) { System.err.println("Failed to access CIMOM: "+e); System.exit(1); } System.err.println("Client created"); // // should return an instance // - Gets an instance for the specified object path // // System.err.println("\n **********Get instance of CIM_Process"); CIMObjectPath pa7=new CIMObjectPath("CIM_Process"); try { pa7.addKey("CreationClassName", new CIMValue("CIM_Process")); pa7.addKey("Name", new CIMValue("Test0")); //pa7.addKey("PrimaryOwnerName", new CIMValue("Test0")); //pa7.addKey("PrimaryOwnerContact", new CIMValue("Bapu Patil")); CIMInstance in=cc.getInstance(pa7, false); System.err.println("Loaded the instance :"+pa7.toString()); } catch (CIMException ce) { System.err.println("Failed to fetch specified instance:"+ce); ce.printStackTrace(); // BAPU System.exit(1); } // // returns a sample QualifierType ("association") // System.err.println("\n **********return a sample QualifierType association"); CIMObjectPath pa8=new CIMObjectPath("association"); try { CIMQualifierType qt=cc.getQualifierType(pa8); System.err.println("Loaded qualifier:"+qt.getName()); } catch (CIMException ce) { System.err.println("Failed to fetch enumeration of qualifier types:"+ce); ce.printStackTrace(); // BAPU //System.exit(1); } // // should return a property // System.err.println("\n **********return a property CIM_ComputerSystem"); CIMObjectPath pa9=new CIMObjectPath("CIM_ComputerSystem"); try { pa9.addKey("CreationClassName", new CIMValue("CIM_ComputerSystem")); pa9.addKey("Name", new CIMValue("Test0")); CIMValue va1=cc.getProperty(pa9, "Name"); CIMValue va2=cc.getProperty(pa9, "PrimaryOwnerContact"); System.err.println("Loaded the instance :"+pa9.toString()+" : Values are Name="+va1.toString()+", PrimaryOwnerContact="+va2.toString()); } catch (CIMException ce) { System.err.println("Failed to get properties:"+ce); System.exit(1); } // // return associatorNames // // // Note at the moment associators requires a path to an instance and won't // operate on a class (and its unclear what a class would return...) // try { Enumeration en6=cc.associatorNames(pa9, "CIM_UnitaryComputerSystem", null, null, null); System.err.println("Fetched associator names"); if (en6!=null) { while (en6.hasMoreElements()) { CIMObjectPath obj=(CIMObjectPath)(en6.nextElement()); System.err.println("Associated path:"+obj.toString()); } } } catch (CIMException ce) { System.err.println("Failed to get associator names:"+ce); System.exit(1); } // // return associated objects // try { Enumeration en6=cc.associators(pa9, "CIM_UnitaryComputerSystem", null, null, null, true, true, null); System.err.println("Fetched associated objects"); if (en6!=null) { while (en6.hasMoreElements()) { CIMInstance obj=(CIMInstance)(en6.nextElement()); System.err.println("Associated object:"+obj.toString()); } } } catch (CIMException ce) { System.err.println("Failed to get associated objects:"+ce); System.exit(1); } // // return Referencenames // try { Enumeration en6=cc.referenceNames(pa9, null, null); System.err.println("Fetched reference names"); if (en6!=null) { while (en6.hasMoreElements()) { CIMObjectPath obj=(CIMObjectPath)(en6.nextElement()); System.err.println("reference name:"+obj.toString()); } } } catch (CIMException ce) { System.err.println("Failed to get reference names:"+ce); System.exit(1); } // // return references Objects // try { Enumeration en6=cc.references(pa9, null, null,true, true, null); System.err.println("Fetched reference objects"); if (en6!=null) { while (en6.hasMoreElements()) { CIMInstance obj=(CIMInstance)(en6.nextElement()); System.err.println("reference object:"+obj.toString()); } } } catch (CIMException ce) { System.err.println("Failed to get reference names:"+ce); System.exit(1); } System.out.println("done:"); } public Test07() { } public static void main(String args[]){ Test07 ea=new Test07(); ea.example(args); } }
No CVS admin address has been configured |
Powered by ViewCVS 0.9.2 |