//
// Test09Invalid.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 Test09Invalid.java
//
// The Initial Developers of the Original Code are Bapu Patil
//
//
// Revision 1.1  2002/05/15 09Invalid: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;
import org.snia.wbem.cim.*;

public class Test09Invalid {

    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, "xxxguest", "guest", CIMClient.XML);
	} catch (CIMException e) {
	    System.err.println("Failed to access CIMOM: "+e);
	    System.exit(1);
	}
	
	System.err.println("Client created");

    
    //
     // returns a sample QualifierType ("association")
     //
     //CIMNameSpace localNameSpace = new CIMNameSpace(hostURL, nameSpace);
     //Enumeration enumQl = cc.enumQualifierTypes(globalNamespace);
     //while (enumQl.hasMoreElements())
     //

System.err.println("\n **********Enumerate QualifierType on association");
     try
     {
          CIMObjectPath pa9 = new CIMObjectPath("Association");
          Enumeration enumQl = cc.enumQualifierTypes(pa9);
          while (enumQl.hasMoreElements())
          {
             CIMQualifierType qt =(CIMQualifierType)(enumQl.nextElement());
             if (qt !=null)  
             {
               System.out.println("\npa 09Invalid: " + (String)(qt.toXml()));
               //System.out.println("\npa 09Invalid: " + qt);
               //System.out.println("\npa 09Invalid: " + qt.getType());
               //System.out.println("\npa 09Invalid: " + qt.getType().toString());
             }
           }
     }
     catch (MalformedURLException me) { }
     catch (CIMException ce)
     {
         System.err.println("Failed to fetch enumeration of qualifier types:"+ce);
         ce.printStackTrace();
         System.exit(1);
     } 

System.err.println("\n **********Test getQualifiers() on CIM_Process");
     try
     {
          CIMObjectPath pa10 = new CIMObjectPath("CIM_Process");

          CIMClass  cclass = cc.getClass(pa10, true);
          Vector qualifiers=  cclass.getQualifiers();     // CIMQualifier
          for(int i=0;i<qualifiers.size();i++) 
          {
             CIMQualifier qt= (CIMQualifier)qualifiers.elementAt(i);
             System.err.println("Loaded qualifier:"+qt.getName());
          }
     }
     catch (CIMException ce)
     {
         System.err.println("Failed to fetch enumeration of qualifier types:"+ce);
         ce.printStackTrace();
         System.exit(1);
     } 

     System.out.println("done:");
   }

   
   public Test09Invalid() {
   }
   
    public static void main(String args[]){
	Test09Invalid ea=new Test09Invalid();
	ea.example(args);
    }
}
