1 //%/////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //==============================================================================
23 // Author: Mike Brasher (mbrasher@bmc.com)
25 // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
27 //%/////////////////////////////////////////////////////////////////////////////
30 #include <Pegasus/Common/CIMProperty.h>
31 #include <Pegasus/Common/CIMPropertyList.h>
33 PEGASUS_USING_PEGASUS;
35 static char * verbose; // controls test IO
43 CIMProperty p1("message", "Hi There");
44 p1.addQualifier(CIMQualifier("Key", true));
45 p1.addQualifier(CIMQualifier("stuff", true));
46 p1.addQualifier(CIMQualifier("stuff2", true));
47 p1.addQualifier(CIMQualifier("Description", "Blah Blah"));
48 CIMConstProperty p2 = p1;
51 CIMProperty p1clone = p1.clone(true);
52 CIMProperty p2clone = p2.clone(true);
77 assert(name == "message");
79 assert(name == "message");
82 assert(p1.getType() == CIMType::STRING);
83 assert(p2.getType() == CIMType::STRING);
86 assert(p1.isKey() == true);
87 assert(p2.isKey() == true);
90 assert(p1.getArraySize() == 0);
91 assert(p2.getArraySize() == 0);
94 assert(p1.getPropagated() == false);
95 assert(p2.getPropagated() == false);
97 // Tests for Qualifiers
98 assert(p1.findQualifier("stuff") != PEG_NOT_FOUND);
99 assert(p1.findQualifier("stuff2") != PEG_NOT_FOUND);
100 assert(p1.findQualifier("stuff21") == PEG_NOT_FOUND);
101 assert(p1.findQualifier("stuf") == PEG_NOT_FOUND);
102 assert(p1.getQualifierCount() == 4);
104 assert(p2.findQualifier("stuff") != PEG_NOT_FOUND);
105 assert(p2.findQualifier("stuff2") != PEG_NOT_FOUND);
106 assert(p2.findQualifier("stuff21") == PEG_NOT_FOUND);
107 assert(p2.findQualifier("stuf") == PEG_NOT_FOUND);
108 assert(p2.getQualifierCount() == 4);
110 assert(p1.existsQualifier("stuff"));
111 assert(p1.existsQualifier("stuff2"));
113 assert(!p1.existsQualifier("stuff21"));
114 assert(!p1.existsQualifier("stuf"));
117 posQualifier = p1.findQualifier("stuff");
118 assert(posQualifier != PEGASUS_NOT_FOUND);
119 assert(posQualifier < p1.getQualifierCount());
121 p1.removeQualifier(posQualifier);
122 assert(p1.getQualifierCount() == 3);
123 assert(!p1.existsQualifier("stuff"));
124 assert(p1.existsQualifier("stuff2"));
126 // Tests for value insertion.
128 CIMProperty p1("p1", "Hi There");
129 // test for CIMValue and type
130 CIMProperty p2("p2", Uint32(999));
131 // test for CIMValue and type
133 //Test getName and setName
134 assert(p1.getName() == "p1");
136 assert(p1.getName() == "px");
138 assert(p2.getName() == "p2");
140 assert(p2.getName() == "py");
142 // Test setValue and getValue
148 // Tests for CIMConstProperty methods
149 CIMProperty p1("message", "Hi There");
150 p1.addQualifier(CIMQualifier("Key", true));
151 p1.addQualifier(CIMQualifier("stuff", true));
152 p1.addQualifier(CIMQualifier("stuff2", true));
153 p1.addQualifier(CIMQualifier("Description", "Blah Blah"));
154 CIMConstProperty p2 = p1;
156 CIMConstProperty cp1 = p1;
157 CIMConstProperty cp2 = p2;
158 CIMConstProperty cp3("message3", "hello");
159 CIMConstProperty cp1clone = cp1.clone(true);
169 assert(cp1.getName() == "message");
170 assert(cp1.getType() == CIMType::STRING);
171 assert(cp1.isKey() == true);
172 assert(cp1.getArraySize() == 0);
173 assert(cp1.getPropagated() == false);
175 assert(cp1.findQualifier("stuff") != PEG_NOT_FOUND);
176 assert(cp1.findQualifier("stuff2") != PEG_NOT_FOUND);
177 assert(cp1.findQualifier("stuff21") == PEG_NOT_FOUND);
178 assert(cp1.findQualifier("stuf") == PEG_NOT_FOUND);
179 assert(cp1.getQualifierCount() == 4);
185 catch(OutOfBounds& e)
188 cout << "Exception: " << e.getMessage() << endl;
194 CIMPropertyList list1;
195 CIMPropertyList list2;
198 names.append("property1");
199 names.append("property2");
200 names.append("property3");
207 int main(int argc, char** argv)
209 verbose = getenv("PEGASUS_TEST_VERBOSE");
218 cout << "Exception: " << e.getMessage() << endl;
221 cout << "+++++ passed all tests" << endl;