(file) Return to Test01.java CVS log (file) (dir) Up to [Pegasus] / pegasus-JavaCIMClient / cimclient / tests / ClientUnitTests

File: [Pegasus] / pegasus-JavaCIMClient / cimclient / tests / ClientUnitTests / Test01.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

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;
import org.snia.wbem.cim.CIMException;

class Test01 {

    private void runTest(String [] args)
        throws CIMException 
    {

        CIMProperty valProp;
        CIMInstance currentInstance;
        CIMObjectPath currentInstancePath;
        CIMValue value = null;
        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);
        }

        CIMNameSpace ns = cc.getNameSpace();
        System.out.println("----------------------------------------------------------------");
        System.out.println("Host      = " + ns.getHost());
        System.out.println("NameSpace = " + ns.getNameSpace());
        System.out.println("Protocol  = " + ns.getProtocol());
        System.out.println("Port      = " + ns.getPortNumber());
        System.out.println("Class     = " + ns.getClass());
        System.out.println("Host URL  = " + ns.getHostURL());
        System.out.println("----------------------------------------------------------------");
        System.err.println("Client created");

/*
        CIMObjectPath path = new CIMObjectPath("HP_NParPowerCoolingDomain");
        //CIMObjectPath path = new CIMObjectPath("PG_OperatingSystem");
        path.addKey("ID", new CIMValue( (Object)new Integer(0)));
        currentInstance = cc.getInstance(path, false);

        valProp = currentInstance.getProperty("SlotCount");
        value = valProp.getValue();
        if (value != null && value.getValue() != null) {
            System.out.println(value.toString());
        }
        else {
            System.out.println("null");
        }

*/
        // works..
        Enumeration instances = cc.enumInstances(new CIMObjectPath("PG_UnixProcess", nameSpace), CIMClient.DEEP);
        while( instances.hasMoreElements() ) {
            Object obj = instances.nextElement();
            System.out.println("Getting properties for " + obj.toString());
            currentInstancePath=(CIMObjectPath)obj;
            currentInstance=cc.getInstance(currentInstancePath,false);

            Vector props = currentInstance.getProperties();
            for( int i = 0; i < props.size(); ++i) {
                valProp = (CIMProperty)props.elementAt(i);
                value = valProp.getValue();
                if (value != null && value.getValue() != null) {
                    System.out.println(value.toString());
                }
                else {
                    System.out.println("null");
                }
            }
        }

        if( cc != null ) {
            cc.close();
        }
    }

    public static void main(String [] args) {
        Test01 t = new Test01();
        try {
            t.runTest(args);
        }
        catch (CIMException e) {
            e.printStackTrace();
            System.exit(1);
        }
    
        System.out.println("It Passed!");
    }
}

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2