package tests.ClientUnitTests;

import org.snia.wbem.cim.*;
import org.snia.wbem.client.*;
import java.net.*;
import java.util.*;

public class TestMultiConnections
{
  private final static int m_portNum = 5989;
  private final static String m_namespace = "root/cimv2";


  public static void main(String[] args)
  {
      try
      {
          String m_serverPath = "http://sequoia.cup.hp.com:" + m_portNum;

          CIMNameSpace cnamespace = new CIMNameSpace( m_serverPath, m_namespace );
          CIMClient m_clientObj=null;

          //good user/password
          m_clientObj = new CIMClient( cnamespace,"guest","guest", CIMClient.XML);


          CIMObjectPath cimPath = new CIMObjectPath("PG_OperatingSystem",m_namespace);

          CIMClass cc=null;

          try
          {
              cc = m_clientObj.getClass(cimPath,false);
              System.out.println("CIMOM login success");
          }
          catch(CIMException cxe)
          {
              System.out.println("CIMOM login failed");
          }

          m_clientObj.close();
    }
    catch(CIMException ce)
    {
       //String msg = ce.getMessage();
       //System.out.println("CIMEXception msg " + msg);
       System.out.println("here is the excep");
       ce.printStackTrace();

    }
    catch(Exception ue)
    {
        System.out.println(ue.getMessage());
    }

    //second time with a different password
    try
    {

        String m_serverPath = "http://sequoia.cup.hp.com:" + m_portNum;

        CIMNameSpace cnamespace = new CIMNameSpace( m_serverPath, m_namespace );
        CIMClient m_clientObj=null;

        // bad username/password
        m_clientObj = new CIMClient( cnamespace,"abc","abc", CIMClient.XML);

        CIMObjectPath cimPath = new CIMObjectPath("PG_OperatingSystem",m_namespace);

        CIMClass cc=null;

        try
        {
            cc = m_clientObj.getClass(cimPath,false);
            System.out.println("CIMOM login success");
        }
        catch(CIMException cxe)
        {
            System.out.println("CIMOM login failed");
        }

        m_clientObj.close();
    }
    catch(CIMException ce)
    {
       //String msg = ce.getMessage();
       //System.out.println("CIMEXception msg " + msg);
       System.out.println("here is the excep");
       ce.printStackTrace();

    }
    catch(Exception ue)
    {
        System.out.println(ue.getMessage());
    }
  }

}


