BUG#: 5023
authormark.hamzy <mark.hamzy>
Tue, 9 May 2006 16:59:52 +0000 (16:59 +0000)
committermark.hamzy <mark.hamzy>
Tue, 9 May 2006 16:59:52 +0000 (16:59 +0000)
TITLE: Add AssociationProvider testcases to JMPI

DESCRIPTION:
Add AssociationProvider testcases to JMPI

src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProvider.java [new file with mode: 0644]
src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProvider.mof [new file with mode: 0644]
src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProviderR.mof [new file with mode: 0644]
src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProvider.java [new file with mode: 0644]
src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProvider.mof [new file with mode: 0644]
src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProviderR.mof [new file with mode: 0644]
src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/Makefile [new file with mode: 0644]

diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProvider.java b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProvider.java
new file mode 100644 (file)
index 0000000..23235dd
--- /dev/null
@@ -0,0 +1,1021 @@
+//%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.
+//
+//==============================================================================
+//
+// Author:      Mark Hamzy,    hamzy@us.ibm.com
+//
+// Modified By: Mark Hamzy,    hamzy@us.ibm.com
+//
+//%/////////////////////////////////////////////////////////////////////////////
+package Associations;
+
+import java.util.Iterator;
+import java.util.Vector;
+import org.pegasus.jmpi.AssociatorProvider;
+import org.pegasus.jmpi.CIMClass;
+import org.pegasus.jmpi.CIMDataType;
+import org.pegasus.jmpi.CIMException;
+import org.pegasus.jmpi.CIMInstance;
+import org.pegasus.jmpi.CIMObjectPath;
+import org.pegasus.jmpi.CIMOMHandle;
+import org.pegasus.jmpi.CIMProperty;
+import org.pegasus.jmpi.CIMValue;
+import org.pegasus.jmpi.InstanceProvider;
+import org.pegasus.jmpi.OperationContext;
+import org.pegasus.jmpi.UnsignedInt8;
+import org.pegasus.jmpi.UnsignedInt64;
+
+public class JMPIAssociationProvider
+       implements InstanceProvider,
+                  AssociatorProvider
+{
+   private CIMOMHandle    handle                 = null;
+   private Vector         paths                  = new Vector ();
+   private Vector         instances              = new Vector ();
+   private boolean        fEnableModifications   = true;
+   private final boolean  DEBUG                  = false;
+
+   public void initialize (CIMOMHandle handle)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::initialize: handle = " + handle);
+      }
+
+      this.handle = handle;
+
+      createDefaultInstances ();
+   }
+
+   public void cleanup ()
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::cleanup");
+      }
+   }
+
+   public CIMObjectPath createInstance (CIMObjectPath    cop,
+                                        CIMInstance      cimInstance)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::createInstance: cop         = " + cop);
+         System.err.println ("JMPIAssociationProvider::createInstance: cimInstance = " + cimInstance);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public void deleteInstance (CIMObjectPath    cop)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::deleteInstance: cop  = " + cop);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   // enumerateInstanceNames
+   public Vector enumInstances (CIMObjectPath    cop,
+                                boolean          deepInheritance,
+                                CIMClass         cimClass)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::enumerateInstanceNames: cop             = " + cop);
+         System.err.println ("JMPIAssociationProvider::enumerateInstanceNames: deepInheritance = " + deepInheritance);
+         System.err.println ("JMPIAssociationProvider::enumerateInstanceNames: cimClass        = " + cimClass);
+      }
+
+      // Enusre that the namespace is valid
+      if (!cop.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      // Ensure that the class exists in the specified namespace
+      if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER))
+      {
+         return _enumerateInstanceNames (teacherInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT))
+      {
+         return _enumerateInstanceNames (studentInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         return _enumerateInstanceNames (TSassociationInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         return _enumerateInstanceNames (ASassociationInstances);
+      }
+      else
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);
+      }
+   }
+
+   public Vector enumInstances (CIMObjectPath    cop,
+                                boolean          deepInheritance,
+                                CIMClass         cimClass,
+                                boolean          localOnly)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::enumerateInstances: cop             = " + cop);
+         System.err.println ("JMPIAssociationProvider::enumerateInstances: deepInheritance = " + deepInheritance);
+         System.err.println ("JMPIAssociationProvider::enumerateInstances: cimClass        = " + cimClass);
+         System.err.println ("JMPIAssociationProvider::enumerateInstances: localOnly       = " + localOnly);
+      }
+
+      // Enusre that the namespace is valid
+      if (!cop.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      Vector vectorReturn = null;
+
+      // Ensure that the class exists in the specified namespace
+      if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER))
+      {
+         vectorReturn = _enumerateInstances (teacherInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT))
+      {
+         vectorReturn = _enumerateInstances (studentInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         vectorReturn = _enumerateInstances (TSassociationInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         vectorReturn = _enumerateInstances (ASassociationInstances);
+      }
+      else
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::enumerateInstances: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public CIMInstance getInstance (CIMObjectPath    cop,
+                                   CIMClass         cimClass,
+                                   boolean          localOnly)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::getInstance: cop       = " + cop);
+         System.err.println ("JMPIAssociationProvider::getInstance: cimClass  = " + cimClass);
+         System.err.println ("JMPIAssociationProvider::getInstance: localOnly = " + localOnly);
+      }
+
+      CIMObjectPath localObjectPath = (CIMObjectPath)cop.clone ();
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      // Ensure that the class exists in the specified namespace
+      if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER))
+      {
+         return _getInstance (teacherInstances, localObjectPath);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT))
+      {
+         return _getInstance (studentInstances, localObjectPath);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         return _getInstance (TSassociationInstances, localObjectPath);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         return _getInstance (ASassociationInstances, localObjectPath);
+      }
+      else
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);
+      }
+   }
+
+   public void setInstance (CIMObjectPath    cop,
+                            CIMInstance      cimInstance)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::modifyInstance: cop          = " + cop);
+         System.err.println ("JMPIAssociationProvider::modifyInstance: cimInstance  = " + cimInstance);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public Vector execQuery (CIMObjectPath    cop,
+                            String           queryStatement,
+                            int              queryLanguage,
+                            CIMClass         cimClass)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::execQuery: cop            = " + cop);
+         System.err.println ("JMPIAssociationProvider::execQuery: queryStatement = " + queryStatement);
+         System.err.println ("JMPIAssociationProvider::execQuery: queryLanguage  = " + queryLanguage);
+         System.err.println ("JMPIAssociationProvider::execQuery: cimClass       = " + cimClass);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public Vector associatorNames (CIMObjectPath    assocName,
+                                  CIMObjectPath    objectName,
+                                  String           resultClass,
+                                  String           role,
+                                  String           resultRole)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::associatorNames: assocName   = " + assocName);
+         System.err.println ("JMPIAssociationProvider::associatorNames: objectName  = " + objectName);
+         System.err.println ("JMPIAssociationProvider::associatorNames: resultClass = " + resultClass);
+         System.err.println ("JMPIAssociationProvider::associatorNames: role        = " + role);
+         System.err.println ("JMPIAssociationProvider::associatorNames: resultRole  = " + resultRole);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      Vector vectorReturn = null;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+          vectorReturn = _associatorNames (TSassociationInstances,
+                                           localObjectPath,
+                                           role,
+                                           resultClass,
+                                           resultRole);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+          vectorReturn = _associatorNames (ASassociationInstances,
+                                           localObjectPath,
+                                           role,
+                                           resultClass,
+                                           resultRole);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                   assocName.getObjectName () + " is not supported");
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::associatorNames: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public Vector associators (CIMObjectPath    assocName,
+                              CIMObjectPath    objectName,
+                              String           resultClass,
+                              String           role,
+                              String           resultRole,
+                              boolean          includeQualifiers,
+                              boolean          includeClassOrigin,
+                              String[]         propertyList)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::associators: assocName          = " + assocName);
+         System.err.println ("JMPIAssociationProvider::associators: objectName         = " + objectName);
+         System.err.println ("JMPIAssociationProvider::associators: resultClass        = " + resultClass);
+         System.err.println ("JMPIAssociationProvider::associators: role               = " + role);
+         System.err.println ("JMPIAssociationProvider::associators: resultRole         = " + resultRole);
+         System.err.println ("JMPIAssociationProvider::associators: includeQualifiers  = " + includeQualifiers);
+         System.err.println ("JMPIAssociationProvider::associators: includeClassOrigin = " + includeClassOrigin);
+         System.err.println ("JMPIAssociationProvider::associators: propertyList       = " + propertyList);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      Vector vectorReturn = null;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+          vectorReturn = _associators (TSassociationInstances,
+                                       localObjectPath,
+                                       role,
+                                       resultClass,
+                                       resultRole);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+          vectorReturn = _associators (ASassociationInstances,
+                                       localObjectPath,
+                                       role,
+                                       resultClass,
+                                       resultRole);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                   assocName.getObjectName () + " is not supported");
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::associators: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public Vector referenceNames (CIMObjectPath    assocName,
+                                 CIMObjectPath    objectName,
+                                 String           role)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::referenceNames: assocName  = " + assocName);
+         System.err.println ("JMPIAssociationProvider::referenceNames: objectName = " + objectName);
+         System.err.println ("JMPIAssociationProvider::referenceNames: role       = " + role);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector resultInstances;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (TSassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (ASassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                   assocName.getObjectName () + " is not supported");
+      }
+
+      Vector vectorReturn = new Vector ();
+
+      // return the instance names
+      for (int i = 0, si = resultInstances.size (); i < si; i++)
+      {
+          CIMObjectPath objectPath = ((CIMInstance)resultInstances.elementAt (i)).getObjectPath ();
+
+          vectorReturn.addElement (objectPath);
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::referenceNames: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public Vector references (CIMObjectPath    assocName,
+                             CIMObjectPath    objectName,
+                             String           role,
+                             boolean          includeQualifiers,
+                             boolean          includeClassOrigin,
+                             String[]         propertyList)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::references: assocName          = " + assocName);
+         System.err.println ("JMPIAssociationProvider::references: objectName         = " + objectName);
+         System.err.println ("JMPIAssociationProvider::references: role               = " + role);
+         System.err.println ("JMPIAssociationProvider::references: includeQualifiers  = " + includeQualifiers);
+         System.err.println ("JMPIAssociationProvider::references: includeClassOrigin = " + includeClassOrigin);
+         System.err.println ("JMPIAssociationProvider::references: propertyList       = " + propertyList);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector resultInstances;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (TSassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (ASassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                  assocName.getObjectName () + " is not supported");
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::references: returning " + resultInstances.size () + " instances");
+      }
+
+      return resultInstances;
+   }
+
+   private void createDefaultInstances ()
+   {
+       //
+       // create 4 instances of the SAMPLE_TEACHER class
+       //
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher1", 1));
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher2", 2));
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher3", 3));
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher4", 4));
+
+       //
+       // create 3 instances of the SAMPLE_STUDENT class
+       //
+       studentInstances.add (createInstance (SAMPLE_STUDENT, "Student1", 1));
+       studentInstances.add (createInstance (SAMPLE_STUDENT, "Student2", 2));
+       studentInstances.add (createInstance (SAMPLE_STUDENT, "Student3", 3));
+
+       //
+       // create the instances for the SAMPLE_TEACHERSTUDENT association class
+       //    (Teacher1, Student1)
+       //    (Teacher1, Student2)
+       //    (Teacher1, Student3)
+       //    (Teacher2, Student1)
+       //    (Teacher2, Student2)
+       //    (Teacher3, Student2)
+       //    (Teacher3, Student3)
+       //    (Teacher4, Student1)
+       //
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 0)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 1)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 2)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 1), getPath (studentInstances, 0)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 1), getPath (studentInstances, 1)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 2), getPath (studentInstances, 1)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 2), getPath (studentInstances, 2)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 3), getPath (studentInstances, 0)));
+
+       //
+       // create the instances for the SAMPLE_ADVISORSTUDENT association class
+       //    (Teacher1, Student1)
+       //    (Teacher1, Student2)
+       //    (Teacher2, Student3)
+       //
+       ASassociationInstances.add (createASAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 0)));
+       ASassociationInstances.add (createASAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 1)));
+       ASassociationInstances.add (createASAssociationInstance (getPath (teacherInstances, 1), getPath (studentInstances, 2)));
+   }
+
+   private CIMObjectPath getPath (Vector v, int i)
+   {
+       try
+       {
+           CIMInstance c = (CIMInstance)v.elementAt (i);
+
+           return c.getObjectPath ();
+       }
+       catch (Exception e)
+       {
+           System.err.println ("JMPIAssociationProvider::getPath: Caught Exception " + e);
+       }
+
+       return null;
+   }
+
+   private CIMInstance createInstance (String className, String name, int id)
+   {
+      try
+      {
+         CIMProperty[] props    = {
+            new CIMProperty ("Name",
+                             new CIMValue (name)),                                    /* @TBD: CLI doesnt pass this in: className */
+            new CIMProperty ("Identifier",
+                             new CIMValue (new UnsignedInt8 (Integer.toString (id)))) /* @TBD: ... className */
+         };
+         CIMObjectPath cop      = new CIMObjectPath (className, NAMESPACE);
+         CIMInstance   instance = new CIMInstance (className);
+
+         for (int i = 0; i < props.length; i++)
+         {
+             instance.setProperty (props[i].getName (), props[i].getValue ());
+             cop.addKey (props[i].getName (), props[i].getValue ());
+         }
+
+         cop.setHost ("");
+         instance.setObjectPath (cop);
+
+         return instance;
+      }
+      catch (CIMException e)
+      {
+          return null;
+      }
+   }
+
+   private CIMInstance createTSAssociationInstance (CIMObjectPath ref1, CIMObjectPath ref2)
+   {
+      try
+      {
+         CIMProperty[] props    = {
+            new CIMProperty ("Teaches",
+                             new CIMValue (ref1)),
+            new CIMProperty ("TaughtBy",
+                             new CIMValue (ref2))
+         };
+         CIMObjectPath cop      = new CIMObjectPath (SAMPLE_TEACHERSTUDENT, NAMESPACE);
+         CIMInstance   instance = new CIMInstance (SAMPLE_TEACHERSTUDENT);
+
+         for (int i = 0; i < props.length; i++)
+         {
+             instance.setProperty (props[i].getName (), props[i].getValue ());
+             cop.addKey (props[i].getName (), props[i].getValue ());
+         }
+
+         cop.setHost ("");
+         instance.setObjectPath (cop);
+
+         return instance;
+      }
+      catch (CIMException e)
+      {
+          return null;
+      }
+   }
+
+   private CIMInstance createASAssociationInstance (CIMObjectPath ref1, CIMObjectPath ref2)
+   {
+      try
+      {
+         CIMProperty[] props    = {
+            new CIMProperty ("Advises",
+                             new CIMValue (ref1)),
+            new CIMProperty ("AdvisedBy",
+                             new CIMValue (ref2))
+         };
+         CIMObjectPath cop      = new CIMObjectPath (SAMPLE_ADVISORSTUDENT, NAMESPACE);
+         CIMInstance   instance = new CIMInstance (SAMPLE_ADVISORSTUDENT);
+
+         for (int i = 0; i < props.length; i++)
+         {
+             instance.setProperty (props[i].getName (), props[i].getValue ());
+             cop.addKey (props[i].getName (), props[i].getValue ());
+         }
+
+         cop.setHost ("");
+         instance.setObjectPath (cop);
+
+         return instance;
+      }
+      catch (CIMException e)
+      {
+          return null;
+      }
+   }
+
+   private CIMInstance _getInstance (Vector        instances,
+                                     CIMObjectPath localObjectPath)
+   {
+      Iterator iteratorInstances = instances.iterator ();
+
+      while (iteratorInstances.hasNext ())
+      {
+         CIMInstance   elm     = (CIMInstance)iteratorInstances.next ();
+         CIMObjectPath elmPath = elm.getObjectPath ();
+
+         if (equals (localObjectPath, elmPath))
+         {
+            return elm;
+         }
+      }
+
+      return null;
+   }
+
+   private Vector _enumerateInstances (Vector instances)
+   {
+      return instances;
+   }
+
+   private Vector _enumerateInstanceNames (Vector instances)
+   {
+      Vector   returnPaths       = new Vector ();
+      Iterator iteratorInstances = instances.iterator ();
+
+      while (iteratorInstances.hasNext ())
+      {
+         CIMInstance elm = (CIMInstance)iteratorInstances.next ();
+
+         returnPaths.addElement (elm.getObjectPath ());
+      }
+
+      return returnPaths;
+   }
+
+   private Vector _associators (Vector        associationInstances,
+                                CIMObjectPath localObjectPath,
+                                String        role,
+                                String        resultClass,
+                                String        resultRole)
+   {
+      Vector vectorReturn = new Vector ();
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector assocInstances = null;
+
+      assocInstances = _filterAssociationInstancesByRole (associationInstances,
+                                                          localObjectPath,
+                                                          role);
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::_associators: assocInstances.size () = " + assocInstances.size ());
+      }
+
+      // Now filter the result association instances against the specified
+      // resultClass and resultRole filters
+      //
+      for (int i = 0, si = assocInstances.size (); i < si; i++)
+      {
+         Vector resultPaths;
+
+         resultPaths = _filterAssociationInstances ((CIMInstance)assocInstances.elementAt (i),
+                                                    localObjectPath,
+                                                    resultClass,
+                                                    resultRole);
+         if (DEBUG)
+         {
+            System.err.println ("JMPIAssociationProvider::_associators: resultPaths.size () = " + resultPaths.size ());
+         }
+
+         for (int j = 0, sj = resultPaths.size (); j < sj; j++)
+         {
+            String className = ((CIMObjectPath)resultPaths.elementAt (j)).getObjectName ();
+
+            if (className.equalsIgnoreCase (SAMPLE_TEACHER))
+            {
+               if (DEBUG)
+               {
+                  System.err.println ("JMPIAssociationProvider::_associators: teacherInstances.size () = " + teacherInstances.size ());
+               }
+
+               // find instance that corresponds to the reference
+               for (int k = 0, s = teacherInstances.size (); k < s; k++)
+               {
+                  CIMObjectPath path = ((CIMInstance)teacherInstances.elementAt (k)).getObjectPath ();
+
+                  if (DEBUG)
+                  {
+                     System.err.println ("JMPIAssociationProvider::_associators: path                      = " + path);
+                     System.err.println ("JMPIAssociationProvider::_associators: resultPaths.elementAt (" + j + ") = " + resultPaths.elementAt (j));
+                  }
+
+                  if (equals (((CIMObjectPath)resultPaths.elementAt (j)), path))
+                  {
+                     if (DEBUG)
+                     {
+                        System.err.println ("JMPIAssociationProvider::_associators: adding!");
+                     }
+
+                     // return the instance
+                     // Note: See below.
+                     vectorReturn.addElement (((CIMInstance)teacherInstances.elementAt (k)).clone ());
+                  }
+               }
+            }
+            else if (className.equalsIgnoreCase (SAMPLE_STUDENT))
+            {
+               if (DEBUG)
+               {
+                  System.err.println ("JMPIAssociationProvider::_associators: studentInstances.size () = " + studentInstances.size ());
+               }
+
+               // find instance that corresponds to the reference
+               for (int k = 0, s = studentInstances.size (); k < s; k++)
+               {
+                  CIMObjectPath path = ((CIMInstance)studentInstances.elementAt (k)).getObjectPath ();
+
+                  if (DEBUG)
+                  {
+                     System.err.println ("JMPIAssociationProvider::_associators: path                      = " + path);
+                     System.err.println ("JMPIAssociationProvider::_associators: resultPaths.elementAt (" + j + ") = " + resultPaths.elementAt (j));
+                  }
+
+                  if (equals (((CIMObjectPath)resultPaths.elementAt (j)), path))
+                  {
+                     if (DEBUG)
+                     {
+                        System.err.println ("JMPIAssociationProvider::_associators: adding!");
+                     }
+
+                     // return the instance
+                     // Note: We must clone what is being returned since otherwise our
+                     //       copy will be modified.
+                     //       The CIMObjectPath will change from:
+                     //          root/SampleProvider:JMPIAssociation_Student.Identifier=1,Name="Student1"
+                     //       to:
+                     //          root/SampleProvider:JMPIAssociation_Student.Name="Student1"
+                     vectorReturn.addElement (((CIMInstance)studentInstances.elementAt (k)).clone ());
+                  }
+               }
+            }
+         }
+      }
+
+      return vectorReturn;
+   }
+
+   private Vector _associatorNames (Vector        associationInstances,
+                                    CIMObjectPath localObjectPath,
+                                    String        role,
+                                    String        resultClass,
+                                    String        resultRole)
+   {
+      Vector vectorReturn = new Vector ();
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector assocInstances;
+
+      assocInstances = _filterAssociationInstancesByRole (associationInstances,
+                                                          localObjectPath,
+                                                          role);
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::_associatorNames: assocInstances.size () = " + assocInstances.size ());
+      }
+
+      // Now filter the result association instances against the specified
+      // resultClass and resultRole filters
+      //
+      for (int i = 0, si = assocInstances.size (); i < si; i++)
+      {
+         Vector resultPaths;
+
+         resultPaths = _filterAssociationInstances ((CIMInstance)assocInstances.elementAt (i),
+                                                    localObjectPath,
+                                                    resultClass,
+                                                    resultRole);
+
+         if (DEBUG)
+         {
+            System.err.println ("JMPIAssociationProvider::_associatorNames: resultPaths.size () = " + resultPaths.size ());
+         }
+
+         vectorReturn.addAll (resultPaths);
+      }
+
+      return vectorReturn;
+   }
+
+   private Vector _filterAssociationInstancesByRole (Vector        associationInstances,
+                                                     CIMObjectPath targetObjectPath,
+                                                     String        role)
+   {
+      Vector returnInstances = new Vector ();
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: associationInstances.size () = " + associationInstances.size ());
+         System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: targetObjectPath             = " + targetObjectPath);
+         System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: role                         = " + role);
+      }
+
+      try
+      {
+         // Filter the instances from the list of association instances against
+         // the specified role filter
+         //
+         for (int i = 0, si = associationInstances.size (); i < si; i++)
+         {
+             CIMInstance instance = (CIMInstance)associationInstances.elementAt (i);
+
+             // Search the association instance for all reference properties
+             for (int j = 0, sj = instance.getPropertyCount (); j < sj; j++)
+             {
+                 CIMProperty p = instance.getProperty (j);
+
+                 if (p.getType ().getType () == CIMDataType.REFERENCE)
+                 {
+                     CIMObjectPath copRef = (CIMObjectPath)p.getValue ().getValue ();
+
+                     if (DEBUG)
+                     {
+                        System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: p                            = " + p);
+                        System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: copRef                       = " + copRef);
+                     }
+
+                     if (  (role.equalsIgnoreCase (""))
+                        || (p.getName ().equalsIgnoreCase (role))
+                        )
+                     {
+                        if (DEBUG)
+                        {
+                            System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: targetObjectPath             = " + targetObjectPath);
+                        }
+
+                        if (targetObjectPath.toString ().equalsIgnoreCase (copRef.toString ()))
+                        {
+                           if (DEBUG)
+                           {
+                               System.err.println ("JMPIAssociationProvider::_filterAssociationInstancesByRole: adding!");
+                           }
+
+                           returnInstances.addElement (instance);
+                        }
+                     }
+                  }
+              }
+          }
+      }
+      catch (CIMException e)
+      {
+      }
+
+      return returnInstances;
+   }
+
+   private Vector _filterAssociationInstances (CIMInstance   assocInstance,
+                                               CIMObjectPath sourceObjectPath,
+                                               String        resultClass,
+                                               String        resultRole)
+   {
+      Vector returnPaths = new Vector ();
+
+      try
+      {
+         if (DEBUG)
+         {
+            System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: assocInstance.getPropertyCount () = " + assocInstance.getPropertyCount ());
+            System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: sourceObjectPath                  = " + sourceObjectPath);
+            System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: resultClass                       = " + resultClass);
+            System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: resultRole                        = " + resultRole);
+         }
+
+         // get all Reference properties
+         for (int i = 0, si = assocInstance.getPropertyCount (); i < si; i++)
+         {
+            CIMProperty p = assocInstance.getProperty (i);
+
+            if (p.getType ().getType () == CIMDataType.REFERENCE)
+            {
+               CIMObjectPath copRef = (CIMObjectPath)p.getValue ().getValue ();
+
+               if (DEBUG)
+               {
+                  System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: p                                 = " + p);
+                  System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: copRef                            = " + copRef);
+               }
+
+               if (!equals (sourceObjectPath, copRef))
+               {
+                  if (  resultClass.equalsIgnoreCase ("")
+                     || resultClass == copRef.getObjectName ()
+                     )
+                  {
+                     if (  (resultRole.equalsIgnoreCase (""))
+                        || (p.getName ().equalsIgnoreCase (resultRole))
+                        )
+                     {
+                        if (DEBUG)
+                        {
+                            System.err.println ("JMPIAssociationProvider::_filterAssociationInstances: adding!");
+                        }
+
+                        returnPaths.addElement (copRef);
+                     }
+                  }
+               }
+            }
+         }
+      }
+      catch (CIMException e)
+      {
+      }
+
+      return returnPaths;
+   }
+
+   private boolean equals (CIMObjectPath l, CIMObjectPath r)
+   {
+      String ls = l.toString ();
+      String rs = r.toString ();
+
+      return ls.equalsIgnoreCase (rs);
+   }
+
+   private Vector         teacherInstances       = new Vector ();
+   private Vector         studentInstances       = new Vector ();
+   private Vector         TSassociationInstances = new Vector ();
+   private Vector         ASassociationInstances = new Vector ();
+
+   private String         NAMESPACE              = new String ("root/SampleProvider");
+
+   // Class names
+   private String         SAMPLE_TEACHER         = new String ("JMPIAssociation_Teacher");
+   private String         SAMPLE_STUDENT         = new String ("JMPIAssociation_Student");
+   private String         SAMPLE_TEACHERSTUDENT  = new String ("JMPIAssociation_TeacherStudent");
+   private String         SAMPLE_ADVISORSTUDENT  = new String ("JMPIAssociation_AdvisorStudent");
+}
diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProvider.mof b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProvider.mof
new file mode 100644 (file)
index 0000000..a8de076
--- /dev/null
@@ -0,0 +1,104 @@
+//%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.
+//
+//==============================================================================
+// Class definitions for the Sample Association Provider
+
+// =======================================================================
+// JMPIAssociation_Person
+// =======================================================================
+    [Version("1.0.0"), Description ("Top level class that defines a person.")]
+class JMPIAssociation_Person
+{
+    [key]
+    string Name;
+};
+
+// =======================================================================
+// JMPIAssociation_Teacher
+// =======================================================================
+    [Version("1.0.0"), Description ("A subclass that defines a teacher.")]
+class JMPIAssociation_Teacher : JMPIAssociation_Person
+{
+    Uint8 Identifier;
+};
+
+// =======================================================================
+// JMPIAssociation_Student
+// =======================================================================
+    [Version("1.0.0"), Description ("A subclass that defines a student.")]
+class JMPIAssociation_Student : JMPIAssociation_Person
+{
+    Uint8 Identifier;
+};
+
+// =======================================================================
+// JMPIAssociation_TeacherStudent
+// =======================================================================
+// A simple association that associates teacher and student in the
+// JMPIAssociation_Teacher and JMPIAssociation_Student classes.
+//
+// It shows a many-to-many relationship between a teacher and a student.
+//
+// A teacher can have MANY students, and a student can have MANY teachers.
+//
+
+    [Association, Version("1.0.0"), Description (
+        "The JMPIAssociation_TeacherStudent association defines the relationship "
+        "between teachers and students.") ]
+class JMPIAssociation_TeacherStudent
+{
+    [key]
+    JMPIAssociation_Teacher REF Teaches;
+    [key]
+    JMPIAssociation_Student REF TaughtBy;
+};
+
+// =======================================================================
+// JMPIAssociation_AdvisorStudent
+// =======================================================================
+// A simple association class that associates teacher and student in the
+// JMPIAssociation_Teacher and JMPIAssociation_Student classes.
+//
+// It shows a one-to-many relationship between a teacher and student.
+//
+// A student can have only ONE teacher as advisor, and a teacher who
+// is an advisor can have MANY students.
+//
+
+    [Association, Version("1.0.0"), Description (
+        "The JMPIAssociation_AdvisorStudent association identifies the students for "
+        "a particular teacher who is also an advisor.")]
+class JMPIAssociation_AdvisorStudent
+{
+    [key, Min (1), Max (1)]
+    JMPIAssociation_Teacher REF advises;
+    [key]
+    JMPIAssociation_Student REF advisedBy;
+};
diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProviderR.mof b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIAssociationProviderR.mof
new file mode 100644 (file)
index 0000000..edcfea3
--- /dev/null
@@ -0,0 +1,94 @@
+//%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.
+//
+//==============================================================================
+
+instance of PG_ProviderModule
+{
+   Name             = "JMPIAssociationProviderModule";
+   Location         = "JMPIAssociationProvider.jar:Associations/JMPIAssociationProvider";
+   Vendor           = "OpenPegasus";
+   Version          = "2.6.0";
+   InterfaceType    = "JMPI";
+   InterfaceVersion = "1.0.0";
+};
+
+instance of PG_Provider
+{
+   ProviderModuleName = "JMPIAssociationProviderModule";
+   Name               = "JMPIAssociationProvider";
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIAssociationProviderModule";
+   ProviderName        = "JMPIAssociationProvider";
+   CapabilityID        = "JMPIAssociation_Teacher";
+   ClassName           = "JMPIAssociation_Teacher";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2 }; // Instance
+   SupportedProperties = NULL;  // All properties
+   SupportedMethods    = NULL;  // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIAssociationProviderModule";
+   ProviderName        = "JMPIAssociationProvider";
+   CapabilityID        = "JMPIAssociation_Student";
+   ClassName           = "JMPIAssociation_Student";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2 }; // Instance
+   SupportedProperties = NULL;  // All properties
+   SupportedMethods    = NULL;  // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIAssociationProviderModule";
+   ProviderName        = "JMPIAssociationProvider";
+   CapabilityID        = "JMPIAssociation_TeacherStudent";
+   ClassName           = "JMPIAssociation_TeacherStudent";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2, 3 }; // Instance, Association
+   SupportedProperties = NULL;     // All properties
+   SupportedMethods    = NULL;     // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIAssociationProviderModule";
+   ProviderName        = "JMPIAssociationProvider";
+   CapabilityID        = "JMPIAssociation_AdvisorStudent";
+   ClassName           = "JMPIAssociation_AdvisorStudent";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2, 3 }; // Instance, Association
+   SupportedProperties = NULL;     // All properties
+   SupportedMethods    = NULL;     // All methods
+};
diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProvider.java b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProvider.java
new file mode 100644 (file)
index 0000000..b4769e2
--- /dev/null
@@ -0,0 +1,1046 @@
+//%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.
+//
+//==============================================================================
+//
+// Author:      Mark Hamzy,    hamzy@us.ibm.com
+//
+// Modified By: Mark Hamzy,    hamzy@us.ibm.com
+//
+//%/////////////////////////////////////////////////////////////////////////////
+package Associations;
+
+import java.util.Iterator;
+import java.util.Vector;
+import org.pegasus.jmpi.AssociatorProvider2;
+import org.pegasus.jmpi.CIMClass;
+import org.pegasus.jmpi.CIMDataType;
+import org.pegasus.jmpi.CIMException;
+import org.pegasus.jmpi.CIMInstance;
+import org.pegasus.jmpi.CIMObjectPath;
+import org.pegasus.jmpi.CIMOMHandle;
+import org.pegasus.jmpi.CIMProperty;
+import org.pegasus.jmpi.CIMValue;
+import org.pegasus.jmpi.InstanceProvider2;
+import org.pegasus.jmpi.OperationContext;
+import org.pegasus.jmpi.UnsignedInt8;
+import org.pegasus.jmpi.UnsignedInt64;
+
+public class JMPIExpAssociationProvider
+       implements InstanceProvider2,
+                  AssociatorProvider2
+{
+   private CIMOMHandle    handle                 = null;
+   private Vector         paths                  = new Vector ();
+   private Vector         instances              = new Vector ();
+   private boolean        fEnableModifications   = true;
+   private final boolean  DEBUG                  = false;
+
+   public void initialize (CIMOMHandle handle)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::initialize: handle = " + handle);
+      }
+
+      this.handle = handle;
+
+      createDefaultInstances ();
+   }
+
+   public void cleanup ()
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::cleanup");
+      }
+   }
+
+   public CIMObjectPath createInstance (OperationContext oc,
+                                        CIMObjectPath    cop,
+                                        CIMInstance      cimInstance)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::createInstance: oc          = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::createInstance: cop         = " + cop);
+         System.err.println ("JMPIExpAssociationProvider::createInstance: cimInstance = " + cimInstance);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public void deleteInstance (OperationContext oc,
+                               CIMObjectPath    cop)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::deleteInstance: oc   = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::deleteInstance: cop  = " + cop);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public Vector enumerateInstanceNames (OperationContext oc,
+                                         CIMObjectPath    cop,
+                                         CIMClass         cimClass)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstanceNames: oc       = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstanceNames: cop      = " + cop);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstanceNames: cimClass = " + cimClass);
+      }
+
+      // Enusre that the namespace is valid
+      if (!cop.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      // Ensure that the class exists in the specified namespace
+      if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER))
+      {
+         return _enumerateInstanceNames (teacherInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT))
+      {
+         return _enumerateInstanceNames (studentInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         return _enumerateInstanceNames (TSassociationInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         return _enumerateInstanceNames (ASassociationInstances);
+      }
+      else
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);
+      }
+   }
+
+   public Vector enumerateInstances (OperationContext oc,
+                                     CIMObjectPath    cop,
+                                     CIMClass         cimClass,
+                                     boolean          includeQualifiers,
+                                     boolean          includeClassOrigin,
+                                     String           propertyList[])
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: oc                 = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: cop                = " + cop);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: cimClass           = " + cimClass);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: includeQualifiers  = " + includeQualifiers);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: includeClassOrigin = " + includeClassOrigin);
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: propertyList       = " + propertyList);
+      }
+
+      // Enusre that the namespace is valid
+      if (!cop.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      Vector vectorReturn = null;
+
+      // Ensure that the class exists in the specified namespace
+      if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER))
+      {
+         vectorReturn = _enumerateInstances (teacherInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT))
+      {
+         vectorReturn = _enumerateInstances (studentInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         vectorReturn = _enumerateInstances (TSassociationInstances);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         vectorReturn = _enumerateInstances (ASassociationInstances);
+      }
+      else
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::enumerateInstances: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public CIMInstance getInstance (OperationContext oc,
+                                   CIMObjectPath    cop,
+                                   CIMClass         cimClass,
+                                   boolean          includeQualifiers,
+                                   boolean          includeClassOrigin,
+                                   String           propertyList[])
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::getInstance: oc                 = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::getInstance: cop                = " + cop);
+         System.err.println ("JMPIExpAssociationProvider::getInstance: cimClass           = " + cimClass);
+         System.err.println ("JMPIExpAssociationProvider::getInstance: includeQualifiers  = " + includeQualifiers);
+         System.err.println ("JMPIExpAssociationProvider::getInstance: includeClassOrigin = " + includeClassOrigin);
+         System.err.println ("JMPIExpAssociationProvider::getInstance: propertyList       = " + propertyList);
+      }
+
+      CIMObjectPath localObjectPath = (CIMObjectPath)cop.clone ();
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      // Ensure that the class exists in the specified namespace
+      if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER))
+      {
+         return _getInstance (teacherInstances, localObjectPath);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT))
+      {
+         return _getInstance (studentInstances, localObjectPath);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         return _getInstance (TSassociationInstances, localObjectPath);
+      }
+      else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         return _getInstance (ASassociationInstances, localObjectPath);
+      }
+      else
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);
+      }
+   }
+
+   public void setInstance (OperationContext oc,
+                            CIMObjectPath    cop,
+                            CIMInstance      cimInstance)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::modifyInstance: oc           = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::modifyInstance: cop          = " + cop);
+         System.err.println ("JMPIExpAssociationProvider::modifyInstance: cimInstance  = " + cimInstance);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public Vector execQuery (OperationContext oc,
+                            CIMObjectPath    cop,
+                            CIMClass         cimClass,
+                            String           queryStatement,
+                            String           queryLanguage)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::execQuery: oc             = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::execQuery: cop            = " + cop);
+         System.err.println ("JMPIExpAssociationProvider::execQuery: cimClass       = " + cimClass);
+         System.err.println ("JMPIExpAssociationProvider::execQuery: queryStatement = " + queryStatement);
+         System.err.println ("JMPIExpAssociationProvider::execQuery: queryLanguage  = " + queryLanguage);
+      }
+
+      throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED);
+   }
+
+   public Vector associatorNames (OperationContext oc,
+                                  CIMObjectPath    assocName,
+                                  CIMObjectPath    objectName,
+                                  String           resultClass,
+                                  String           role,
+                                  String           resultRole)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: oc          = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: assocName   = " + assocName);
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: objectName  = " + objectName);
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: resultClass = " + resultClass);
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: role        = " + role);
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: resultRole  = " + resultRole);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      Vector vectorReturn = null;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+          vectorReturn = _associatorNames (TSassociationInstances,
+                                           localObjectPath,
+                                           role,
+                                           resultClass,
+                                           resultRole);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+          vectorReturn = _associatorNames (ASassociationInstances,
+                                           localObjectPath,
+                                           role,
+                                           resultClass,
+                                           resultRole);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                   assocName.getObjectName () + " is not supported");
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::associatorNames: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public Vector associators (OperationContext oc,
+                              CIMObjectPath    assocName,
+                              CIMObjectPath    objectName,
+                              String           resultClass,
+                              String           role,
+                              String           resultRole,
+                              boolean          includeQualifiers,
+                              boolean          includeClassOrigin,
+                              String[]         propertyList)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::associators: oc                 = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::associators: assocName          = " + assocName);
+         System.err.println ("JMPIExpAssociationProvider::associators: objectName         = " + objectName);
+         System.err.println ("JMPIExpAssociationProvider::associators: resultClass        = " + resultClass);
+         System.err.println ("JMPIExpAssociationProvider::associators: role               = " + role);
+         System.err.println ("JMPIExpAssociationProvider::associators: resultRole         = " + resultRole);
+         System.err.println ("JMPIExpAssociationProvider::associators: includeQualifiers  = " + includeQualifiers);
+         System.err.println ("JMPIExpAssociationProvider::associators: includeClassOrigin = " + includeClassOrigin);
+         System.err.println ("JMPIExpAssociationProvider::associators: propertyList       = " + propertyList);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      Vector vectorReturn = null;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+          vectorReturn = _associators (TSassociationInstances,
+                                       localObjectPath,
+                                       role,
+                                       resultClass,
+                                       resultRole);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+          vectorReturn = _associators (ASassociationInstances,
+                                       localObjectPath,
+                                       role,
+                                       resultClass,
+                                       resultRole);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                   assocName.getObjectName () + " is not supported");
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::associators: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public Vector referenceNames (OperationContext oc,
+                                 CIMObjectPath    assocName,
+                                 CIMObjectPath    objectName,
+                                 String           role)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::referenceNames: oc         = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::referenceNames: assocName  = " + assocName);
+         System.err.println ("JMPIExpAssociationProvider::referenceNames: objectName = " + objectName);
+         System.err.println ("JMPIExpAssociationProvider::referenceNames: role       = " + role);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector resultInstances;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (TSassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (ASassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                   assocName.getObjectName () + " is not supported");
+      }
+
+      Vector vectorReturn = new Vector ();
+
+      // return the instance names
+      for (int i = 0, si = resultInstances.size (); i < si; i++)
+      {
+          CIMObjectPath objectPath = ((CIMInstance)resultInstances.elementAt (i)).getObjectPath ();
+
+          vectorReturn.addElement (objectPath);
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::referenceNames: returning " + vectorReturn.size () + " instances");
+      }
+
+      return vectorReturn;
+   }
+
+   public Vector references (OperationContext oc,
+                             CIMObjectPath    assocName,
+                             CIMObjectPath    objectName,
+                             String           role,
+                             boolean          includeQualifiers,
+                             boolean          includeClassOrigin,
+                             String[]         propertyList)
+      throws CIMException
+   {
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::references: oc                 = " + oc);
+         System.err.println ("JMPIExpAssociationProvider::references: assocName          = " + assocName);
+         System.err.println ("JMPIExpAssociationProvider::references: objectName         = " + objectName);
+         System.err.println ("JMPIExpAssociationProvider::references: role               = " + role);
+         System.err.println ("JMPIExpAssociationProvider::references: includeQualifiers  = " + includeQualifiers);
+         System.err.println ("JMPIExpAssociationProvider::references: includeClassOrigin = " + includeClassOrigin);
+         System.err.println ("JMPIExpAssociationProvider::references: propertyList       = " + propertyList);
+      }
+
+      // Enusre that the namespace is valid
+      if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE))
+      {
+         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);
+      }
+
+      CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (),
+                                                         objectName.getKeys ());
+      localObjectPath.setHost ("");
+      localObjectPath.setNameSpace (NAMESPACE);
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector resultInstances;
+
+      if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (TSassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT))
+      {
+         resultInstances = _filterAssociationInstancesByRole (ASassociationInstances,
+                                                              localObjectPath,
+                                                              role);
+      }
+      else
+      {
+          throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS,
+                                  assocName.getObjectName () + " is not supported");
+      }
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::references: returning " + resultInstances.size () + " instances");
+      }
+
+      return resultInstances;
+   }
+
+   private void createDefaultInstances ()
+   {
+       //
+       // create 4 instances of the SAMPLE_TEACHER class
+       //
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher1", 1));
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher2", 2));
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher3", 3));
+       teacherInstances.add (createInstance (SAMPLE_TEACHER, "Teacher4", 4));
+
+       //
+       // create 3 instances of the SAMPLE_STUDENT class
+       //
+       studentInstances.add (createInstance (SAMPLE_STUDENT, "Student1", 1));
+       studentInstances.add (createInstance (SAMPLE_STUDENT, "Student2", 2));
+       studentInstances.add (createInstance (SAMPLE_STUDENT, "Student3", 3));
+
+       //
+       // create the instances for the SAMPLE_TEACHERSTUDENT association class
+       //    (Teacher1, Student1)
+       //    (Teacher1, Student2)
+       //    (Teacher1, Student3)
+       //    (Teacher2, Student1)
+       //    (Teacher2, Student2)
+       //    (Teacher3, Student2)
+       //    (Teacher3, Student3)
+       //    (Teacher4, Student1)
+       //
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 0)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 1)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 2)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 1), getPath (studentInstances, 0)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 1), getPath (studentInstances, 1)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 2), getPath (studentInstances, 1)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 2), getPath (studentInstances, 2)));
+       TSassociationInstances.add (createTSAssociationInstance (getPath (teacherInstances, 3), getPath (studentInstances, 0)));
+
+       //
+       // create the instances for the SAMPLE_ADVISORSTUDENT association class
+       //    (Teacher1, Student1)
+       //    (Teacher1, Student2)
+       //    (Teacher2, Student3)
+       //
+       ASassociationInstances.add (createASAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 0)));
+       ASassociationInstances.add (createASAssociationInstance (getPath (teacherInstances, 0), getPath (studentInstances, 1)));
+       ASassociationInstances.add (createASAssociationInstance (getPath (teacherInstances, 1), getPath (studentInstances, 2)));
+   }
+
+   private CIMObjectPath getPath (Vector v, int i)
+   {
+       try
+       {
+           CIMInstance c = (CIMInstance)v.elementAt (i);
+
+           return c.getObjectPath ();
+       }
+       catch (Exception e)
+       {
+           System.err.println ("JMPIExpAssociationProvider::getPath: Caught Exception " + e);
+       }
+
+       return null;
+   }
+
+   private CIMInstance createInstance (String className, String name, int id)
+   {
+      try
+      {
+         CIMProperty[] props    = {
+            new CIMProperty ("Name",
+                             new CIMValue (name)),                                    /* @TBD: CLI doesnt pass this in: className */
+            new CIMProperty ("Identifier",
+                             new CIMValue (new UnsignedInt8 (Integer.toString (id)))) /* @TBD: ... className */
+         };
+         CIMObjectPath cop      = new CIMObjectPath (className, NAMESPACE);
+         CIMInstance   instance = new CIMInstance (className);
+
+         for (int i = 0; i < props.length; i++)
+         {
+             instance.setProperty (props[i].getName (), props[i].getValue ());
+             cop.addKey (props[i].getName (), props[i].getValue ());
+         }
+
+         cop.setHost ("");
+         instance.setObjectPath (cop);
+
+         return instance;
+      }
+      catch (CIMException e)
+      {
+          return null;
+      }
+   }
+
+   private CIMInstance createTSAssociationInstance (CIMObjectPath ref1, CIMObjectPath ref2)
+   {
+      try
+      {
+         CIMProperty[] props    = {
+            new CIMProperty ("Teaches",
+                             new CIMValue (ref1)),
+            new CIMProperty ("TaughtBy",
+                             new CIMValue (ref2))
+         };
+         CIMObjectPath cop      = new CIMObjectPath (SAMPLE_TEACHERSTUDENT, NAMESPACE);
+         CIMInstance   instance = new CIMInstance (SAMPLE_TEACHERSTUDENT);
+
+         for (int i = 0; i < props.length; i++)
+         {
+             instance.setProperty (props[i].getName (), props[i].getValue ());
+             cop.addKey (props[i].getName (), props[i].getValue ());
+         }
+
+         cop.setHost ("");
+         instance.setObjectPath (cop);
+
+         return instance;
+      }
+      catch (CIMException e)
+      {
+          return null;
+      }
+   }
+
+   private CIMInstance createASAssociationInstance (CIMObjectPath ref1, CIMObjectPath ref2)
+   {
+      try
+      {
+         CIMProperty[] props    = {
+            new CIMProperty ("Advises",
+                             new CIMValue (ref1)),
+            new CIMProperty ("AdvisedBy",
+                             new CIMValue (ref2))
+         };
+         CIMObjectPath cop      = new CIMObjectPath (SAMPLE_ADVISORSTUDENT, NAMESPACE);
+         CIMInstance   instance = new CIMInstance (SAMPLE_ADVISORSTUDENT);
+
+         for (int i = 0; i < props.length; i++)
+         {
+             instance.setProperty (props[i].getName (), props[i].getValue ());
+             cop.addKey (props[i].getName (), props[i].getValue ());
+         }
+
+         cop.setHost ("");
+         instance.setObjectPath (cop);
+
+         return instance;
+      }
+      catch (CIMException e)
+      {
+          return null;
+      }
+   }
+
+   private CIMInstance _getInstance (Vector        instances,
+                                     CIMObjectPath localObjectPath)
+   {
+      Iterator iteratorInstances = instances.iterator ();
+
+      while (iteratorInstances.hasNext ())
+      {
+         CIMInstance   elm     = (CIMInstance)iteratorInstances.next ();
+         CIMObjectPath elmPath = elm.getObjectPath ();
+
+         if (equals (localObjectPath, elmPath))
+         {
+            return elm;
+         }
+      }
+
+      return null;
+   }
+
+   private Vector _enumerateInstances (Vector instances)
+   {
+      return instances;
+   }
+
+   private Vector _enumerateInstanceNames (Vector instances)
+   {
+      Vector   returnPaths       = new Vector ();
+      Iterator iteratorInstances = instances.iterator ();
+
+      while (iteratorInstances.hasNext ())
+      {
+         CIMInstance elm = (CIMInstance)iteratorInstances.next ();
+
+         returnPaths.addElement (elm.getObjectPath ());
+      }
+
+      return returnPaths;
+   }
+
+   private Vector _associators (Vector        associationInstances,
+                                CIMObjectPath localObjectPath,
+                                String        role,
+                                String        resultClass,
+                                String        resultRole)
+   {
+      Vector vectorReturn = new Vector ();
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector assocInstances = null;
+
+      assocInstances = _filterAssociationInstancesByRole (associationInstances,
+                                                          localObjectPath,
+                                                          role);
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::_associators: assocInstances.size () = " + assocInstances.size ());
+      }
+
+      // Now filter the result association instances against the specified
+      // resultClass and resultRole filters
+      //
+      for (int i = 0, si = assocInstances.size (); i < si; i++)
+      {
+         Vector resultPaths;
+
+         resultPaths = _filterAssociationInstances ((CIMInstance)assocInstances.elementAt (i),
+                                                    localObjectPath,
+                                                    resultClass,
+                                                    resultRole);
+         if (DEBUG)
+         {
+            System.err.println ("JMPIExpAssociationProvider::_associators: resultPaths.size () = " + resultPaths.size ());
+         }
+
+         for (int j = 0, sj = resultPaths.size (); j < sj; j++)
+         {
+            String className = ((CIMObjectPath)resultPaths.elementAt (j)).getObjectName ();
+
+            if (className.equalsIgnoreCase (SAMPLE_TEACHER))
+            {
+               if (DEBUG)
+               {
+                  System.err.println ("JMPIExpAssociationProvider::_associators: teacherInstances.size () = " + teacherInstances.size ());
+               }
+
+               // find instance that corresponds to the reference
+               for (int k = 0, s = teacherInstances.size (); k < s; k++)
+               {
+                  CIMObjectPath path = ((CIMInstance)teacherInstances.elementAt (k)).getObjectPath ();
+
+                  if (DEBUG)
+                  {
+                     System.err.println ("JMPIExpAssociationProvider::_associators: path                      = " + path);
+                     System.err.println ("JMPIExpAssociationProvider::_associators: resultPaths.elementAt (" + j + ") = " + resultPaths.elementAt (j));
+                  }
+
+                  if (equals (((CIMObjectPath)resultPaths.elementAt (j)), path))
+                  {
+                     if (DEBUG)
+                     {
+                        System.err.println ("JMPIExpAssociationProvider::_associators: adding!");
+                     }
+
+                     // return the instance
+                     // Note: See below.
+                     vectorReturn.addElement (((CIMInstance)teacherInstances.elementAt (k)).clone ());
+                  }
+               }
+            }
+            else if (className.equalsIgnoreCase (SAMPLE_STUDENT))
+            {
+               if (DEBUG)
+               {
+                  System.err.println ("JMPIExpAssociationProvider::_associators: studentInstances.size () = " + studentInstances.size ());
+               }
+
+               // find instance that corresponds to the reference
+               for (int k = 0, s = studentInstances.size (); k < s; k++)
+               {
+                  CIMObjectPath path = ((CIMInstance)studentInstances.elementAt (k)).getObjectPath ();
+
+                  if (DEBUG)
+                  {
+                     System.err.println ("JMPIExpAssociationProvider::_associators: path                      = " + path);
+                     System.err.println ("JMPIExpAssociationProvider::_associators: resultPaths.elementAt (" + j + ") = " + resultPaths.elementAt (j));
+                  }
+
+                  if (equals (((CIMObjectPath)resultPaths.elementAt (j)), path))
+                  {
+                     if (DEBUG)
+                     {
+                        System.err.println ("JMPIExpAssociationProvider::_associators: adding!");
+                     }
+
+                     // return the instance
+                     // Note: We must clone what is being returned since otherwise our
+                     //       copy will be modified.
+                     //       The CIMObjectPath will change from:
+                     //          root/SampleProvider:JMPIExpAssociation_Student.Identifier=1,Name="Student1"
+                     //       to:
+                     //          root/SampleProvider:JMPIExpAssociation_Student.Name="Student1"
+                     vectorReturn.addElement (((CIMInstance)studentInstances.elementAt (k)).clone ());
+                  }
+               }
+            }
+         }
+      }
+
+      return vectorReturn;
+   }
+
+   private Vector _associatorNames (Vector        associationInstances,
+                                    CIMObjectPath localObjectPath,
+                                    String        role,
+                                    String        resultClass,
+                                    String        resultRole)
+   {
+      Vector vectorReturn = new Vector ();
+
+      // Filter the instances from the list of association instances against
+      // the specified role filter
+      //
+      Vector assocInstances;
+
+      assocInstances = _filterAssociationInstancesByRole (associationInstances,
+                                                          localObjectPath,
+                                                          role);
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::_associatorNames: assocInstances.size () = " + assocInstances.size ());
+      }
+
+      // Now filter the result association instances against the specified
+      // resultClass and resultRole filters
+      //
+      for (int i = 0, si = assocInstances.size (); i < si; i++)
+      {
+         Vector resultPaths;
+
+         resultPaths = _filterAssociationInstances ((CIMInstance)assocInstances.elementAt (i),
+                                                    localObjectPath,
+                                                    resultClass,
+                                                    resultRole);
+
+         if (DEBUG)
+         {
+            System.err.println ("JMPIExpAssociationProvider::_associatorNames: resultPaths.size () = " + resultPaths.size ());
+         }
+
+         vectorReturn.addAll (resultPaths);
+      }
+
+      return vectorReturn;
+   }
+
+   private Vector _filterAssociationInstancesByRole (Vector        associationInstances,
+                                                     CIMObjectPath targetObjectPath,
+                                                     String        role)
+   {
+      Vector returnInstances = new Vector ();
+
+      if (DEBUG)
+      {
+         System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: associationInstances.size () = " + associationInstances.size ());
+         System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: targetObjectPath             = " + targetObjectPath);
+         System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: role                         = " + role);
+      }
+
+      try
+      {
+         // Filter the instances from the list of association instances against
+         // the specified role filter
+         //
+         for (int i = 0, si = associationInstances.size (); i < si; i++)
+         {
+             CIMInstance instance = (CIMInstance)associationInstances.elementAt (i);
+
+             // Search the association instance for all reference properties
+             for (int j = 0, sj = instance.getPropertyCount (); j < sj; j++)
+             {
+                 CIMProperty p = instance.getProperty (j);
+
+                 if (p.getType ().getType () == CIMDataType.REFERENCE)
+                 {
+                     CIMObjectPath copRef = (CIMObjectPath)p.getValue ().getValue ();
+
+                     if (DEBUG)
+                     {
+                        System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: p                            = " + p);
+                        System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: copRef                       = " + copRef);
+                     }
+
+                     if (  (role.equalsIgnoreCase (""))
+                        || (p.getName ().equalsIgnoreCase (role))
+                        )
+                     {
+                        if (DEBUG)
+                        {
+                           System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: targetObjectPath             = " + targetObjectPath);
+                        }
+
+                         if (targetObjectPath.toString ().equalsIgnoreCase (copRef.toString ()))
+                         {
+                            if (DEBUG)
+                            {
+                               System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstancesByRole: adding!");
+                            }
+
+                             returnInstances.addElement (instance);
+                         }
+                     }
+                 }
+             }
+         }
+      }
+      catch (CIMException e)
+      {
+      }
+
+      return returnInstances;
+   }
+
+   private Vector _filterAssociationInstances (CIMInstance   assocInstance,
+                                               CIMObjectPath sourceObjectPath,
+                                               String        resultClass,
+                                               String        resultRole)
+   {
+      Vector returnPaths = new Vector ();
+
+      try
+      {
+         if (DEBUG)
+         {
+            System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: assocInstance.getPropertyCount () = " + assocInstance.getPropertyCount ());
+            System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: sourceObjectPath                  = " + sourceObjectPath);
+            System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: resultClass                       = " + resultClass);
+            System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: resultRole                        = " + resultRole);
+         }
+
+         // get all Reference properties
+         for (int i = 0, si = assocInstance.getPropertyCount (); i < si; i++)
+         {
+            CIMProperty p = assocInstance.getProperty (i);
+
+            if (p.getType ().getType () == CIMDataType.REFERENCE)
+            {
+               CIMObjectPath copRef = (CIMObjectPath)p.getValue ().getValue ();
+
+               if (DEBUG)
+               {
+                  System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: p                                 = " + p);
+                  System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: copRef                            = " + copRef);
+               }
+
+               if (!equals (sourceObjectPath, copRef))
+               {
+                  if (  resultClass.equalsIgnoreCase ("")
+                     || resultClass == copRef.getObjectName ()
+                     )
+                  {
+                     if (  (resultRole.equalsIgnoreCase (""))
+                        || (p.getName ().equalsIgnoreCase (resultRole))
+                        )
+                     {
+                        if (DEBUG)
+                        {
+                           System.err.println ("JMPIExpAssociationProvider::_filterAssociationInstances: adding!");
+                        }
+
+                        returnPaths.addElement (copRef);
+                     }
+                  }
+               }
+            }
+         }
+      }
+      catch (CIMException e)
+      {
+      }
+
+      return returnPaths;
+   }
+
+   private boolean equals (CIMObjectPath l, CIMObjectPath r)
+   {
+      String ls = l.toString ();
+      String rs = r.toString ();
+
+      return ls.equalsIgnoreCase (rs);
+   }
+
+   private Vector         teacherInstances       = new Vector ();
+   private Vector         studentInstances       = new Vector ();
+   private Vector         TSassociationInstances = new Vector ();
+   private Vector         ASassociationInstances = new Vector ();
+
+   private String         NAMESPACE              = new String ("root/SampleProvider");
+
+   // Class names
+   private String         SAMPLE_TEACHER         = new String ("JMPIExpAssociation_Teacher");
+   private String         SAMPLE_STUDENT         = new String ("JMPIExpAssociation_Student");
+   private String         SAMPLE_TEACHERSTUDENT  = new String ("JMPIExpAssociation_TeacherStudent");
+   private String         SAMPLE_ADVISORSTUDENT  = new String ("JMPIExpAssociation_AdvisorStudent");
+}
diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProvider.mof b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProvider.mof
new file mode 100644 (file)
index 0000000..e3e2306
--- /dev/null
@@ -0,0 +1,104 @@
+//%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.
+//
+//==============================================================================
+// Class definitions for the Sample Association Provider
+
+// =======================================================================
+// JMPIExpAssociation_Person
+// =======================================================================
+    [Version("1.0.0"), Description ("Top level class that defines a person.")]
+class JMPIExpAssociation_Person
+{
+    [key]
+    string Name;
+};
+
+// =======================================================================
+// JMPIExpAssociation_Teacher
+// =======================================================================
+    [Version("1.0.0"), Description ("A subclass that defines a teacher.")]
+class JMPIExpAssociation_Teacher : JMPIExpAssociation_Person
+{
+    Uint8 Identifier;
+};
+
+// =======================================================================
+// JMPIExpAssociation_Student
+// =======================================================================
+    [Version("1.0.0"), Description ("A subclass that defines a student.")]
+class JMPIExpAssociation_Student : JMPIExpAssociation_Person
+{
+    Uint8 Identifier;
+};
+
+// =======================================================================
+// JMPIExpAssociation_TeacherStudent
+// =======================================================================
+// A simple association that associates teacher and student in the
+// JMPIExpAssociation_Teacher and JMPIExpAssociation_Student classes.
+//
+// It shows a many-to-many relationship between a teacher and a student.
+//
+// A teacher can have MANY students, and a student can have MANY teachers.
+//
+
+    [Association, Version("1.0.0"), Description (
+        "The JMPIExpAssociation_TeacherStudent association defines the relationship "
+        "between teachers and students.") ]
+class JMPIExpAssociation_TeacherStudent
+{
+    [key]
+    JMPIExpAssociation_Teacher REF Teaches;
+    [key]
+    JMPIExpAssociation_Student REF TaughtBy;
+};
+
+// =======================================================================
+// JMPIExpAssociation_AdvisorStudent
+// =======================================================================
+// A simple association class that associates teacher and student in the
+// JMPIExpAssociation_Teacher and JMPIExpAssociation_Student classes.
+//
+// It shows a one-to-many relationship between a teacher and student.
+//
+// A student can have only ONE teacher as advisor, and a teacher who
+// is an advisor can have MANY students.
+//
+
+    [Association, Version("1.0.0"), Description (
+        "The JMPIExpAssociation_AdvisorStudent association identifies the students for "
+        "a particular teacher who is also an advisor.")]
+class JMPIExpAssociation_AdvisorStudent
+{
+    [key, Min (1), Max (1)]
+    JMPIExpAssociation_Teacher REF advises;
+    [key]
+    JMPIExpAssociation_Student REF advisedBy;
+};
diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProviderR.mof b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/JMPIExpAssociationProviderR.mof
new file mode 100644 (file)
index 0000000..f44f6a8
--- /dev/null
@@ -0,0 +1,94 @@
+//%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.
+//
+//==============================================================================
+
+instance of PG_ProviderModule
+{
+   Name             = "JMPIExpAssociationProviderModule";
+   Location         = "JMPIExpAssociationProvider.jar:Associations/JMPIExpAssociationProvider";
+   Vendor           = "OpenPegasus";
+   Version          = "2.6.0";
+   InterfaceType    = "JMPIExperimental";
+   InterfaceVersion = "0.0.1";
+};
+
+instance of PG_Provider
+{
+   ProviderModuleName = "JMPIExpAssociationProviderModule";
+   Name               = "JMPIExpAssociationProvider";
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIExpAssociationProviderModule";
+   ProviderName        = "JMPIExpAssociationProvider";
+   CapabilityID        = "1";
+   ClassName           = "JMPIExpAssociation_Teacher";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2 }; // Instance
+   SupportedProperties = NULL;  // All properties
+   SupportedMethods    = NULL;  // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIExpAssociationProviderModule";
+   ProviderName        = "JMPIExpAssociationProvider";
+   CapabilityID        = "JMPIExpAssociation_Student";
+   ClassName           = "JMPIExpAssociation_Student";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2 }; // Instance
+   SupportedProperties = NULL;  // All properties
+   SupportedMethods    = NULL;  // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIExpAssociationProviderModule";
+   ProviderName        = "JMPIExpAssociationProvider";
+   CapabilityID        = "JMPIExpAssociation_TeacherStudent";
+   ClassName           = "JMPIExpAssociation_TeacherStudent";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2, 3 }; // Instance, Association
+   SupportedProperties = NULL;     // All properties
+   SupportedMethods    = NULL;     // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+   ProviderModuleName  = "JMPIExpAssociationProviderModule";
+   ProviderName        = "JMPIExpAssociationProvider";
+   CapabilityID        = "JMPIExpAssociation_AdvisorStudent";
+   ClassName           = "JMPIExpAssociation_AdvisorStudent";
+   Namespaces          = { "root/SampleProvider" };
+   ProviderType        = { 2, 3 }; // Instance, Association
+   SupportedProperties = NULL;     // All properties
+   SupportedMethods    = NULL;     // All methods
+};
diff --git a/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/Makefile b/src/Pegasus/ProviderManager2/JMPI/org/pegasus/jmpi/tests/Providers/Associations/Makefile
new file mode 100644 (file)
index 0000000..8925688
--- /dev/null
@@ -0,0 +1,139 @@
+#//%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.
+#//
+#//==============================================================================
+ifndef PEGASUS_ROOT
+    $(error PEGASUS_ROOT environment variable undefined)
+endif
+ifndef PEGASUS_HOME
+    $(error PEGASUS_HOME environment variable undefined)
+endif
+
+include $(PEGASUS_ROOT)/mak/config.mak
+include $(PEGASUS_ROOT)/mak/configschema.mak
+include $(PEGASUS_ROOT)/test/config.mak
+
+.SUFFIXES: .java .class .jar
+
+.java.class:
+       javac -classpath $(PEGASUS_HOME)/lib/JMPIImpl.jar $*.java
+
+NAMESPACE          = root/SampleProvider
+PACKAGEDIR         = Associations/
+JAR1               = JMPIExpAssociationProvider.jar
+JAR1CLASSES        = \
+       JMPIExpAssociationProvider.class
+EXTRAJAR1CLASSES   =
+JAR2               = JMPIAssociationProvider.jar
+JAR2CLASSES        = \
+       JMPIAssociationProvider.class
+EXTRAJAR2CLASSES   =
+JARS               = $(JAR1) $(JAR2)
+
+LOCAL_CLEAN_TARGET = \
+       $(JAR1CLASSES) $(EXTRAJAR1CLASSES) $(addprefix $(PEGASUS_HOME)/lib/,$(JAR1)) \
+       $(JAR2CLASSES) $(EXTRAJAR2CLASSES) $(addprefix $(PEGASUS_HOME)/lib/,$(JAR2))
+
+all build:                     $(addprefix $(PEGASUS_HOME)/lib/,$(JARS))
+
+depend:
+
+clean:
+       $(RM) $(LOCAL_CLEAN_TARGET)
+
+repository:                    cimmofl_repository
+
+cimmofl_repository:
+       @$(ECHO) +++++ Loading CIM_Core$(CIM_SCHEMA_VER) into $(NAMESPACE) namespace ...
+       @cimmofl "-R$(REPOSITORY_DIR)" "-N$(REPOSITORY_NAME)" "-M$(REPOSITORY_MODE)" "-I$(CIM_SCHEMA_DIR)" "-n$(NAMESPACE)" $(ALLOW_EXPERIMENTAL) $(CIM_SCHEMA_DIR)/CIM_Core$(CIM_SCHEMA_VER).mof
+       @$(ECHO) +++++ Loading CIM_Event$(CIM_SCHEMA_VER) into $(NAMESPACE) namespace ...
+       @cimmofl "-R$(REPOSITORY_DIR)" "-N$(REPOSITORY_NAME)" "-M$(REPOSITORY_MODE)" "-I$(CIM_SCHEMA_DIR)" "-n$(NAMESPACE)" $(ALLOW_EXPERIMENTAL) $(CIM_SCHEMA_DIR)/CIM_Event$(CIM_SCHEMA_VER).mof
+       @$(ECHO) +++++ Loading $(subst .jar,,$(JAR1)) into $(NAMESPACE) namespace ...
+       @cimmofl "-R$(REPOSITORY_DIR)" "-N$(REPOSITORY_NAME)" "-M$(REPOSITORY_MODE)" -I. "-n$(NAMESPACE)" $(subst .jar,,$(JAR1)).mof
+       @cimmofl "-R$(REPOSITORY_DIR)" "-N$(REPOSITORY_NAME)" "-M$(REPOSITORY_MODE)" -I. "-n$(INTEROPNS)" $(subst .jar,,$(JAR1))R.mof
+       @$(ECHO) +++++ Loading $(subst .jar,,$(JAR2)) into $(NAMESPACE) namespace ...
+       @cimmofl "-R$(REPOSITORY_DIR)" "-N$(REPOSITORY_NAME)" "-M$(REPOSITORY_MODE)" -I. "-n$(NAMESPACE)" $(subst .jar,,$(JAR2)).mof
+       @cimmofl "-R$(REPOSITORY_DIR)" "-N$(REPOSITORY_NAME)" "-M$(REPOSITORY_MODE)" -I. "-n$(INTEROPNS)" $(subst .jar,,$(JAR2))R.mof
+
+cimmof_repository:
+       @$(ECHO) +++++ Loading CIM_Core$(CIM_SCHEMA_VER) into $(NAMESPACE) namespace ...
+       @cimmof "-I$(CIM_SCHEMA_DIR)" "-n$(NAMESPACE)" $(ALLOW_EXPERIMENTAL) $(CIM_SCHEMA_DIR)/CIM_Core$(CIM_SCHEMA_VER).mof
+       @$(ECHO) +++++ Loading CIM_Event$(CIM_SCHEMA_VER) into $(NAMESPACE) namespace ...
+       @cimmof "-I$(CIM_SCHEMA_DIR)" "-n$(NAMESPACE)" $(ALLOW_EXPERIMENTAL) $(CIM_SCHEMA_DIR)/CIM_Event$(CIM_SCHEMA_VER).mof
+       @$(ECHO) +++++ Loading $(subst .jar,,$(JAR1)) into $(NAMESPACE) namespace ...
+       @cimmof -I. "-n$(NAMESPACE)" $(subst .jar,,$(JAR1)).mof
+       @cimmof -I. "-n$(INTEROPNS)" $(subst .jar,,$(JAR1))R.mof
+       @$(ECHO) +++++ Loading $(subst .jar,,$(JAR2)) into $(NAMESPACE) namespace ...
+       @cimmof -I. "-n$(NAMESPACE)" $(subst .jar,,$(JAR2)).mof
+       @cimmof -I. "-n$(INTEROPNS)" $(subst .jar,,$(JAR2))R.mof
+
+poststarttests:                        $(addprefix $(PEGASUS_HOME)/lib/,$(JARS))
+       @CLI a  --sum -count 1 -n $(NAMESPACE) JMPIExpAssociation_Teacher
+       @CLI an --sum -count 1 -n $(NAMESPACE) JMPIExpAssociation_Teacher
+       @CLI r  --sum -count 2 -n $(NAMESPACE) JMPIExpAssociation_Teacher
+       @CLI rn --sum -count 2 -n $(NAMESPACE) JMPIExpAssociation_Teacher
+       @CLI a  --sum -count 3 -n $(NAMESPACE) -r Teaches 'JMPIExpAssociation_Teacher.Name="Teacher1",Identifier=1'
+       @CLI an --sum -count 3 -n $(NAMESPACE) -r Teaches 'JMPIExpAssociation_Teacher.Name="Teacher1",Identifier=1'
+       @CLI r  --sum -count 1 -n $(NAMESPACE) -r Teaches JMPIExpAssociation_Teacher
+       @CLI rn --sum -count 3 -n $(NAMESPACE) -r Teaches 'JMPIExpAssociation_Teacher.Name="Teacher1",Identifier=1'
+
+       @CLI a  --sum -count 1 -n $(NAMESPACE) JMPIExpAssociation_Student
+       @CLI an --sum -count 1 -n $(NAMESPACE) JMPIExpAssociation_Student
+       @CLI r  --sum -count 2 -n $(NAMESPACE) JMPIExpAssociation_Student
+       @CLI rn --sum -count 2 -n $(NAMESPACE) JMPIExpAssociation_Student
+       @CLI a  --sum -count 3 -n $(NAMESPACE) -r TaughtBy 'JMPIExpAssociation_Student.Name="Student1",Identifier=1'
+       @CLI an --sum -count 3 -n $(NAMESPACE) -r TaughtBy 'JMPIExpAssociation_Student.Name="Student1",Identifier=1'
+       @CLI r  --sum -count 1 -n $(NAMESPACE) -r TaughtBy JMPIExpAssociation_Student
+       @CLI rn --sum -count 3 -n $(NAMESPACE) -r TaughtBy 'JMPIExpAssociation_Student.Name="Student1",Identifier=1'
+
+       @CLI a  --sum -count 1 -n $(NAMESPACE) JMPIAssociation_Teacher
+       @CLI an --sum -count 1 -n $(NAMESPACE) JMPIAssociation_Teacher
+       @CLI r  --sum -count 2 -n $(NAMESPACE) JMPIAssociation_Teacher
+       @CLI rn --sum -count 2 -n $(NAMESPACE) JMPIAssociation_Teacher
+       @CLI a  --sum -count 3 -n $(NAMESPACE) -r Teaches 'JMPIAssociation_Teacher.Name="Teacher1",Identifier=1'
+       @CLI an --sum -count 3 -n $(NAMESPACE) -r Teaches 'JMPIAssociation_Teacher.Name="Teacher1",Identifier=1'
+       @CLI r  --sum -count 1 -n $(NAMESPACE) -r Teaches JMPIAssociation_Teacher
+       @CLI rn --sum -count 3 -n $(NAMESPACE) -r Teaches 'JMPIAssociation_Teacher.Name="Teacher1",Identifier=1'
+
+       @CLI a  --sum -count 1 -n $(NAMESPACE) JMPIAssociation_Student
+       @CLI an --sum -count 1 -n $(NAMESPACE) JMPIAssociation_Student
+       @CLI r  --sum -count 2 -n $(NAMESPACE) JMPIAssociation_Student
+       @CLI rn --sum -count 2 -n $(NAMESPACE) JMPIAssociation_Student
+       @CLI a  --sum -count 3 -n $(NAMESPACE) -r TaughtBy 'JMPIAssociation_Student.Name="Student1",Identifier=1'
+       @CLI an --sum -count 3 -n $(NAMESPACE) -r TaughtBy 'JMPIAssociation_Student.Name="Student1",Identifier=1'
+       @CLI r  --sum -count 1 -n $(NAMESPACE) -r TaughtBy JMPIAssociation_Student
+       @CLI rn --sum -count 3 -n $(NAMESPACE) -r TaughtBy 'JMPIAssociation_Student.Name="Student1",Identifier=1'
+
+$(PEGASUS_HOME)/lib/$(JAR1):   $(JAR1CLASSES)
+       jar -cf $@ $(addprefix -C .. $(PACKAGEDIR),$^) $(addprefix -C .. $(PACKAGEDIR),$(EXTRAJAR1CLASSES))
+
+$(PEGASUS_HOME)/lib/$(JAR2):   $(JAR2CLASSES)
+       jar -cf $@ $(addprefix -C .. $(PACKAGEDIR),$^) $(addprefix -C .. $(PACKAGEDIR),$(EXTRAJAR2CLASSES))
+
+#include $(ROOT)/test/configend.mak