1 //%2003////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 //==============================================================================
28 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
29 // (carolann_graves@hp.com)
31 //%/////////////////////////////////////////////////////////////////////////////
33 #include <Pegasus/Common/Config.h>
35 #include <Pegasus/Common/String.h>
36 //#include <Pegasus/Compiler/cimmofParser.h>
37 #include <Pegasus/Repository/CIMRepository.h>
39 PEGASUS_USING_PEGASUS;
42 void TestAssociations(CIMRepository& r)
44 String nameSpace = "root";
46 CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");
48 Array<CIMObjectPath> names = r.associatorNames(
56 assert(names.size() == 1);
57 Boolean cond = names[0] == CIMObjectPath("Y.key=\"John Jones\"");
62 CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");
64 Array<CIMObject> result = r.associators(
72 assert(result.size() == 1);
74 CIMObjectPath cimReference = result[0].getPath ();
75 CIMInstance cimInstance = CIMInstance(result[0]);
77 CIMClass tmpClass = r.getClass(nameSpace, cimInstance.getClassName());
78 CIMObjectPath tmpInstanceName = cimInstance.buildPath(tmpClass);
80 Boolean t = tmpInstanceName == CIMObjectPath("Y.key=\"John Jones\"");
86 CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");
88 Array<CIMObjectPath> result = r.referenceNames(
94 assert(result.size() == 1);
96 CIMObjectPath tmp = CIMObjectPath ("A."
97 "left=\"x.key=\\\"John Smith\\\"\","
98 "right=\"y.key=\\\"John Jones\\\"\"");
100 Boolean cond = (result[0] == tmp);
105 CIMObjectPath instanceName = CIMObjectPath ("X.key=\"John Smith\"");
107 Array<CIMObject> result = r.references(
113 assert(result.size() == 1);
115 CIMClass tmpClass = r.getClass(
116 nameSpace, CIMInstance(result[0]).getClassName());
118 CIMObjectPath tmpInstanceName =
119 CIMInstance(result[0]).buildPath(tmpClass);
121 CIMObjectPath tmp = CIMObjectPath ("A."
122 "left=\"x.key=\\\"John Smith\\\"\","
123 "right=\"y.key=\\\"John Jones\\\"\"");
125 Boolean cond = (tmpInstanceName == tmp);
129 // Delete all the object we created:
131 // First delete the association:
133 CIMObjectPath assocInstanceName = CIMObjectPath ("A."
134 "left=\"x.key=\\\"John Smith\\\"\","
135 "right=\"y.key=\\\"John Jones\\\"\"");
137 r.deleteInstance(nameSpace, assocInstanceName);
143 String repositoryRoot;
144 const char* tmpDir = getenv ("PEGASUS_TMP");
147 repositoryRoot = ".";
151 repositoryRoot = tmpDir;
153 repositoryRoot.append("/repository");
157 CIMRepository r (repositoryRoot);
159 // TestAssociations(r);
163 cerr << e.getMessage() << endl;
167 cout << "+++++ passed all tests" << endl;