1 martin 1.8 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 martin 1.8 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 yi.zhou 1.1 //
|
28 martin 1.8 //////////////////////////////////////////////////////////////////////////
|
29 yi.zhou 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include <Pegasus/Common/PegasusAssert.h>
33 #include <Pegasus/Common/System.h>
34 #include <Pegasus/HandlerService/HandlerTable.h>
35 #include <Pegasus/Repository/CIMRepository.h>
36 #include <Pegasus/Config/ConfigManager.h>
37
38 PEGASUS_USING_PEGASUS;
39 PEGASUS_USING_STD;
40
41 const String NAMESPACE("TestSnmpHandler");
42
43 const CIMNamespaceName NS = CIMNamespaceName ("TestSnmpHandler");
44
45 const CIMName testClass1 = CIMName ("SnmpTestClass1");
46 const CIMName testClass2 = CIMName ("SnmpTestClass2");
47 const CIMName testClass3 = CIMName ("SnmpTestClass3");
48 const CIMName testClass4 = CIMName ("SnmpTestClass4");
49 const CIMName testClass5 = CIMName ("SnmpTestClass5");
50 yi.zhou 1.1 const CIMName testClass6 = CIMName ("SnmpTestClass6");
51 const CIMName testClass7 = CIMName ("SnmpTestClass7");
|
52 yi.zhou 1.5 const CIMName testClass8 = CIMName ("SnmpTestClass8");
|
53 yi.zhou 1.1
54 static CIMInstance CreateHandlerInstance()
55 {
56 CIMInstance handlerInstance(PEGASUS_CLASSNAME_INDHANDLER_SNMP);
57 handlerInstance.addProperty (CIMProperty (CIMName
58 ("SystemCreationClassName"), System::getSystemCreationClassName ()));
59 handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"),
60 System::getFullyQualifiedHostName ()));
61 handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"),
62 PEGASUS_CLASSNAME_INDHANDLER_SNMP.getString ()));
63 handlerInstance.addProperty(CIMProperty(CIMName ("Name"),
64 String("Handler1")));
65 return (handlerInstance);
66 }
67
68 static void TestException(
69 CIMHandler* handler,
70 CIMInstance indicationHandlerInstance,
71 CIMInstance indicationInstance,
72 CIMStatusCode statusCode)
73 {
74 yi.zhou 1.1 OperationContext context;
75 CIMInstance indicationSubscriptionInstance;
76 ContentLanguageList contentLanguages;
77
78 Boolean exceptionCaught = false;
79 CIMException testException;
80
81 try
82 {
83 handler->handleIndication(context, NAMESPACE, indicationInstance,
84 indicationHandlerInstance, indicationSubscriptionInstance,
85 contentLanguages);
86 }
87 catch (CIMException& e)
88 {
89 exceptionCaught = true;
|
90 kumpf 1.6 testException = e;
|
91 yi.zhou 1.1 }
92
|
93 kumpf 1.6 PEGASUS_TEST_ASSERT(exceptionCaught &&
|
94 yi.zhou 1.1 testException.getCode() == statusCode);
95 }
96
|
97 kumpf 1.6 // Snmp traps are sent, but, only partial data are in the trap since
|
98 yi.zhou 1.1 // there are errors in some data
99 static void TestError(
100 CIMHandler* handler,
101 CIMInstance indicationHandlerInstance,
102 CIMInstance indicationInstance)
103 {
104 OperationContext context;
105 CIMInstance indicationSubscriptionInstance;
106 ContentLanguageList contentLanguages;
107
108 Boolean exceptionCaught = false;
109
110 try
111 {
112 handler->handleIndication(context, NAMESPACE, indicationInstance,
113 indicationHandlerInstance, indicationSubscriptionInstance,
114 contentLanguages);
115 }
|
116 kumpf 1.3 catch (CIMException&)
|
117 yi.zhou 1.1 {
118 exceptionCaught = true;
119 }
120
121 PEGASUS_TEST_ASSERT(!exceptionCaught);
122 }
123
124 static void CreateRepository(CIMRepository & repository)
125 {
126 repository.createNameSpace(NS);
127
|
128 yi.zhou 1.5 Array<String> qualifierValue;
129 qualifierValue.append("");
130
|
131 kumpf 1.6 CIMQualifierDecl q1(CIMName ("MappingStrings"), qualifierValue,
|
132 yi.zhou 1.1 CIMScope::PROPERTY + CIMScope::CLASS);
133
134 // Qualifier name must be "MappingStrings", test the qualifier
135 // name is not "MappingStrings"
|
136 kumpf 1.6 CIMQualifierDecl q2(CIMName ("NotMappingStrings"), qualifierValue,
|
137 yi.zhou 1.1 CIMScope::CLASS);
138
139 repository.setQualifier(NS, q1);
140 repository.setQualifier(NS, q2);
141
|
142 yi.zhou 1.5 Array<String> classMappingStr;
143 classMappingStr.append("OID.IETF | SNMP.1.3.6.1.4.1.892.2.3.9000.8600");
|
144 yi.zhou 1.1
145 CIMClass class1(testClass1);
|
146 kumpf 1.6 class1.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
147 yi.zhou 1.5 CIMValue(classMappingStr)));
|
148 kumpf 1.6
|
149 yi.zhou 1.5 Array<String> invalidFormatStr;
150 invalidFormatStr.append(
151 "Wrong format OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
152 invalidFormatStr.append("DataType.IETF | OctetString ");
153
|
154 yi.zhou 1.1 // create wrong format property mappingStrings value
|
155 kumpf 1.6 class1.addProperty(
156 CIMProperty(CIMName("OidDataType"), String("OctetString"))
157 .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
158 yi.zhou 1.5 CIMValue(invalidFormatStr))));
|
159 yi.zhou 1.1
160 repository.createClass(NS, class1);
161
162 // create invalid mapping string value
|
163 yi.zhou 1.5 Array<String> class2MappingStr;
164 Array<String> mappingStr2;
165
166 class2MappingStr.append("OID.IETF |Invalid Mapping String Value");
167
168 mappingStr2.append("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
169 mappingStr2.append("DataType.IETF OctetString ");
|
170 yi.zhou 1.1
171 CIMClass class2(testClass2);
|
172 kumpf 1.6 class2.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
173 yi.zhou 1.5 CIMValue(class2MappingStr)));
|
174 kumpf 1.6
|
175 yi.zhou 1.1 class2.addProperty(CIMProperty(CIMName ("OidDataType"), String())
|
176 kumpf 1.6 .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
177 yi.zhou 1.5 CIMValue(mappingStr2))));
|
178 yi.zhou 1.1 repository.createClass(NS, class2);
179
180 // create non MappingStrings qualifier
181 CIMClass class3(testClass3);
|
182 kumpf 1.6 class3.addQualifier(CIMQualifier(CIMName ("NotMappingStrings"),
|
183 yi.zhou 1.5 CIMValue(classMappingStr)));
|
184 kumpf 1.6
|
185 yi.zhou 1.1 repository.createClass(NS, class3);
186
187 // error building ASN.1 representation
|
188 yi.zhou 1.5 Array<String> class4MappingStr;
189 class4MappingStr.append("OID.IETF | SNMP.1.204.6.1.6.3.1.330.5.1.0 ");
|
190 yi.zhou 1.1
191 CIMClass class4(testClass4);
|
192 kumpf 1.6 class4.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
193 yi.zhou 1.5 CIMValue(class4MappingStr)));
|
194 kumpf 1.6
|
195 yi.zhou 1.1 repository.createClass(NS, class4);
196
197 // create incorrect class mappingStrings value
|
198 yi.zhou 1.5 Array<String> class5MappingStr;
199 class5MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3 ");
|
200 yi.zhou 1.1
201 CIMClass class5(testClass5);
|
202 kumpf 1.6 class5.addQualifier(CIMQualifier(CIMName
|
203 yi.zhou 1.5 ("MappingStrings"), CIMValue(class5MappingStr)));
|
204 yi.zhou 1.1
205 // create incorrect property name
206 class5.addProperty(
207 CIMProperty(CIMName ("WrongPropertyName"), String("OctetString"))
|
208 kumpf 1.6 .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
209 yi.zhou 1.5 CIMValue(class5MappingStr))));
|
210 kumpf 1.6
|
211 yi.zhou 1.1 repository.createClass(NS, class5);
212
213 // create incorrect property mappingStrings value
|
214 yi.zhou 1.5 Array<String> class6MappingStr;
215 class6MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.3.1.1.0.1 ");
216
217 Array<String> mappingStr6;
218 mappingStr6.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3");
219 mappingStr6.append("DataType.IETF | OctetString");
|
220 yi.zhou 1.1
221 CIMClass class6(testClass6);
|
222 kumpf 1.6 class6.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
223 yi.zhou 1.5 CIMValue(class6MappingStr)));
|
224 yi.zhou 1.1 class6.addProperty(
225 CIMProperty(CIMName ("OidDataType"), String("OctetString"))
|
226 kumpf 1.6 .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
227 yi.zhou 1.5 CIMValue(mappingStr6))));
|
228 kumpf 1.6
|
229 yi.zhou 1.1 repository.createClass(NS, class6);
230
231 // create unsupportted SNMP Data Type for the CIM property
|
232 yi.zhou 1.5 Array<String> class7MappingStr;
233 class7MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.3.1.1.5.1 ");
234
235 Array<String> mappingStr7;
236 mappingStr7.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3");
237 mappingStr7.append("DataType.IETF | test ");
|
238 yi.zhou 1.1
239 CIMClass class7(testClass7);
|
240 kumpf 1.6 class7.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
241 yi.zhou 1.5 CIMValue(class7MappingStr)));
|
242 yi.zhou 1.1 class7.addProperty(
243 CIMProperty(CIMName ("OidDataType"), String("test"))
|
244 kumpf 1.6 .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
245 yi.zhou 1.5 CIMValue(mappingStr7))));
|
246 kumpf 1.6
|
247 yi.zhou 1.1 repository.createClass(NS, class7);
|
248 yi.zhou 1.5
249 // create invalid syntax for MappingStrings qualifier
250 Array<String> invalidSyntax;
251 Array<String> class8MappingStr;
252 class8MappingStr.append("OID.IETF Invalid Syntax for MappingStrings");
253
254 Array<String> mappingStr8;
255 mappingStr8.append("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
256 mappingStr8.append("DataType.IETF | OctetString ");
257
258 CIMClass class8(testClass8);
|
259 kumpf 1.6 class8.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
260 yi.zhou 1.5 CIMValue(class8MappingStr)));
|
261 kumpf 1.6
|
262 yi.zhou 1.5 class8.addProperty(CIMProperty(CIMName ("OidDataType"), String())
|
263 kumpf 1.6 .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
|
264 yi.zhou 1.5 CIMValue(mappingStr8))));
265 repository.createClass(NS, class8);
|
266 yi.zhou 1.1 }
267
268 static void TestExceptionHandling(CIMHandler* handler)
269 {
270 CIMInstance indicationHandlerInstance;
271
272 // Test "invalid IndicationHandlerSNMPMapper instance" exception
273 CIMInstance indicationInstance(testClass1);
274 indicationHandlerInstance = CreateHandlerInstance();
275 TestException(handler, indicationHandlerInstance, indicationInstance,
276 CIM_ERR_FAILED);
277
278 // Test "no required property TargetHostFormat" exception
279 indicationInstance = CIMInstance(testClass1);
280 indicationInstance.addProperty(CIMProperty(
281 CIMName ("OidDataType"), String("OctetString")));
282 indicationHandlerInstance = CreateHandlerInstance();
283 indicationHandlerInstance.addProperty(CIMProperty(
284 CIMName("TargetHost"), String("15.13.140.120")));
285 indicationHandlerInstance.addProperty(CIMProperty(
286 CIMName("SNMPVersion"), Uint16(2)));
287 yi.zhou 1.1 TestException(handler, indicationHandlerInstance, indicationInstance,
288 CIM_ERR_FAILED);
289
290 // Test "no required property SNMPVersion" exception
291 indicationInstance = CIMInstance(testClass1);
292 indicationHandlerInstance = CreateHandlerInstance();
293 indicationHandlerInstance.addProperty(CIMProperty(
294 CIMName("TargetHost"), String("15.13.140.120")));
295 indicationHandlerInstance.addProperty(CIMProperty(
296 CIMName("TargetHostFormat"), Uint16(3)));
297 TestException(handler, indicationHandlerInstance, indicationInstance,
298 CIM_ERR_FAILED);
299
300 // Test "unsupported snmp Version" exception
301 indicationInstance = CIMInstance(testClass1);
302 indicationHandlerInstance = CreateHandlerInstance();
303 indicationHandlerInstance.addProperty(CIMProperty(
304 CIMName("TargetHost"), String("15.13.140.120")));
305 indicationHandlerInstance.addProperty(CIMProperty(
306 CIMName("TargetHostFormat"), Uint16(3)));
307 indicationHandlerInstance.addProperty(CIMProperty(
308 yi.zhou 1.1 CIMName("SNMPVersion"), Uint16(5)));
309 TestException(handler, indicationHandlerInstance, indicationInstance,
310 CIM_ERR_FAILED);
311
312 // Test "SNMP session open failed" exception
313 indicationInstance = CIMInstance(testClass1);
314 indicationHandlerInstance = CreateHandlerInstance();
315 indicationHandlerInstance.addProperty(CIMProperty(
316 CIMName("TargetHost"), String("")));
317 indicationHandlerInstance.addProperty(CIMProperty(
318 CIMName("TargetHostFormat"), Uint16(3)));
319 indicationHandlerInstance.addProperty(CIMProperty(
320 CIMName("SNMPVersion"), Uint16(2)));
321 indicationHandlerInstance.addProperty(CIMProperty(
322 CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
323 indicationHandlerInstance.addProperty(CIMProperty(
324 CIMName("PortNumber"), Uint32(200)));
325 TestException(handler, indicationHandlerInstance, indicationInstance,
326 CIM_ERR_FAILED);
327
|
328 yi.zhou 1.5 // Test "invalid MappingStrings Syntax" exception
329 indicationInstance = CIMInstance(testClass8);
330 indicationInstance.addProperty(CIMProperty(
331 CIMName ("OidDataType"), String("OctetString")));
332 indicationHandlerInstance = CreateHandlerInstance();
333 indicationHandlerInstance.addProperty(CIMProperty(
334 CIMName("TargetHost"), String("15.13.140.120")));
335 indicationHandlerInstance.addProperty(CIMProperty(
336 CIMName("TargetHostFormat"), Uint16(3)));
337 indicationHandlerInstance.addProperty(CIMProperty(
338 CIMName("SNMPVersion"), Uint16(2)));
339 TestException(handler, indicationHandlerInstance, indicationInstance,
340 CIM_ERR_FAILED);
341
|
342 yi.zhou 1.1 // Test "invalid MappingStrings value" exception
343 indicationInstance = CIMInstance(testClass2);
344 indicationInstance.addProperty(CIMProperty(
345 CIMName ("OidDataType"), String("OctetString")));
346 indicationHandlerInstance = CreateHandlerInstance();
347 indicationHandlerInstance.addProperty(CIMProperty(
348 CIMName("TargetHost"), String("15.13.140.120")));
349 indicationHandlerInstance.addProperty(CIMProperty(
350 CIMName("TargetHostFormat"), Uint16(3)));
351 indicationHandlerInstance.addProperty(CIMProperty(
352 CIMName("SNMPVersion"), Uint16(2)));
353 TestException(handler, indicationHandlerInstance, indicationInstance,
354 CIM_ERR_FAILED);
355
356 // Test "no MappingStrings qualifier" exception
357 indicationInstance = CIMInstance(testClass3);
358 indicationHandlerInstance = CreateHandlerInstance();
359 indicationHandlerInstance.addProperty(CIMProperty(
360 CIMName("TargetHost"), String("15.13.140.120")));
361 indicationHandlerInstance.addProperty(CIMProperty(
362 CIMName("TargetHostFormat"), Uint16(3)));
363 yi.zhou 1.1 indicationHandlerInstance.addProperty(CIMProperty(
364 CIMName("SNMPVersion"), Uint16(2)));
365 TestException(handler, indicationHandlerInstance, indicationInstance,
366 CIM_ERR_FAILED);
367
368 // Test "send trap failed" exception
369 indicationInstance = CIMInstance(testClass4);
370 indicationHandlerInstance = CreateHandlerInstance();
371 indicationHandlerInstance.addProperty(CIMProperty(
372 CIMName("TargetHost"), String("15.13.140.120")));
373 indicationHandlerInstance.addProperty(CIMProperty(
374 CIMName("TargetHostFormat"), Uint16(3)));
375 indicationHandlerInstance.addProperty(CIMProperty(
376 CIMName("SNMPVersion"), Uint16(2)));
377 indicationHandlerInstance.addProperty(CIMProperty(
378 CIMName("SNMPSecurityName"), String("t")));
379 indicationHandlerInstance.addProperty(CIMProperty(
380 CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
381 TestException(handler, indicationHandlerInstance, indicationInstance,
382 CIM_ERR_FAILED);
383
|
384 kumpf 1.6 // Test "failed to add snmp variables to PDU",
|
385 yi.zhou 1.1 // Both a DiscardedData message and an error message
|
386 kumpf 1.6 // are logged to log file
|
387 yi.zhou 1.1 indicationInstance = CIMInstance(testClass5);
388 indicationInstance.addProperty(CIMProperty(
389 CIMName ("OidDataType"), String("OctetString")));
390 indicationHandlerInstance = CreateHandlerInstance();
391 indicationHandlerInstance.addProperty(CIMProperty(
392 CIMName("TargetHost"), String("15.13.140.120")));
393 indicationHandlerInstance.addProperty(CIMProperty(
394 CIMName("TargetHostFormat"), Uint16(3)));
395 indicationHandlerInstance.addProperty(CIMProperty(
396 CIMName("SNMPVersion"), Uint16(2)));
397 indicationHandlerInstance.addProperty(CIMProperty(
398 CIMName("SNMPSecurityName"), String("t")));
399 indicationHandlerInstance.addProperty(CIMProperty(
400 CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
401 TestError(handler, indicationHandlerInstance, indicationInstance);
402
403 // Test "convert enterprise OID from numeric form to a list of"
404 // "subidentifiers failed".
405 // Both a DiscardedData message and an error message
|
406 kumpf 1.6 // are logged to log file
|
407 yi.zhou 1.1 indicationInstance = CIMInstance(testClass5);
408 indicationInstance.addProperty(CIMProperty(
409 CIMName ("OidDataType"), String("OctetString")));
410 indicationHandlerInstance = CreateHandlerInstance();
411 indicationHandlerInstance.addProperty(CIMProperty(
412 CIMName("TargetHost"), String("15.13.140.120")));
413 indicationHandlerInstance.addProperty(CIMProperty(
414 CIMName("TargetHostFormat"), Uint16(3)));
415 indicationHandlerInstance.addProperty(CIMProperty(
416 CIMName("SNMPVersion"), Uint16(3)));
417 indicationHandlerInstance.addProperty(CIMProperty(
418 CIMName("SNMPSecurityName"), String("t")));
419 indicationHandlerInstance.addProperty(CIMProperty(
420 CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
421 TestError(handler, indicationHandlerInstance, indicationInstance);
422
423 // Test "convert property OID from numeric form to a list of"
424 // "subidentifiers failed".
425 // Both a DiscardedData message and an error message
|
426 kumpf 1.6 // are logged to log file
|
427 yi.zhou 1.1 indicationInstance = CIMInstance(testClass6);
428 indicationInstance.addProperty(CIMProperty(
429 CIMName ("OidDataType"), String("OctetString")));
430 indicationHandlerInstance = CreateHandlerInstance();
431 indicationHandlerInstance.addProperty(CIMProperty(
432 CIMName("TargetHost"), String("15.13.140.120")));
433 indicationHandlerInstance.addProperty(CIMProperty(
434 CIMName("TargetHostFormat"), Uint16(3)));
435 indicationHandlerInstance.addProperty(CIMProperty(
436 CIMName("SNMPVersion"), Uint16(2)));
437 indicationHandlerInstance.addProperty(CIMProperty(
438 CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
439 TestError(handler, indicationHandlerInstance, indicationInstance);
440
441 // Test "unsupported SNMP data type for the CIM property"
442 // Both a DiscardedData message and an error message
|
443 kumpf 1.6 // are logged to log file
|
444 yi.zhou 1.1 indicationInstance = CIMInstance(testClass7);
445 indicationInstance.addProperty(CIMProperty(
446 CIMName ("OidDataType"), String("test")));
447 indicationHandlerInstance = CreateHandlerInstance();
448 indicationHandlerInstance.addProperty(CIMProperty(
449 CIMName("TargetHost"), String("15.13.140.120")));
450 indicationHandlerInstance.addProperty(CIMProperty(
451 CIMName("TargetHostFormat"), Uint16(3)));
452 indicationHandlerInstance.addProperty(CIMProperty(
453 CIMName("SNMPVersion"), Uint16(2)));
454 TestError(handler, indicationHandlerInstance, indicationInstance);
455 }
456
457
458 int main(int argc, char** argv)
459 {
460
461 const char* pegasusHome = getenv("PEGASUS_HOME");
462 if (!pegasusHome)
463 {
464 cerr << "PEGASUS_HOME environment variable not set" << endl;
465 yi.zhou 1.1 exit(1);
466 }
467
468 String repositoryRoot = pegasusHome;
469 repositoryRoot.append("/repository");
470
|
471 kumpf 1.4 CIMRepository* repository = new CIMRepository(
472 repositoryRoot, CIMRepository::MODE_BIN);
|
473 yi.zhou 1.1
474 ConfigManager::setPegasusHome(pegasusHome);
475
476 // -- Create repository and namespaces:
477
478 CreateRepository(*repository);
479
480 try
481 {
482 HandlerTable handlerTable;
483 String handlerId = "snmpIndicationHandler";
484 CIMHandler* handler = handlerTable.getHandler(handlerId, repository);
|
485 kumpf 1.6 PEGASUS_TEST_ASSERT(handler != 0);
|
486 yi.zhou 1.1
487 TestExceptionHandling(handler);
488
489 //
490 // -- Clean up classes:
491 //
492 repository->deleteClass(NS, testClass1);
493 repository->deleteClass(NS, testClass2);
494 repository->deleteClass(NS, testClass3);
495 repository->deleteClass(NS, testClass4);
496 repository->deleteClass(NS, testClass5);
497 repository->deleteClass(NS, testClass6);
498 repository->deleteClass(NS, testClass7);
|
499 yi.zhou 1.5 repository->deleteClass(NS, testClass8);
|
500 yi.zhou 1.1
501 //
502 // -- Delete the qualifier:
503 //
504 repository->deleteQualifier(NS, CIMName ("MappingStrings"));
505 repository->deleteQualifier(NS, CIMName ("NotMappingStrings"));
506
507 repository->deleteNameSpace(NS);
508 }
509 catch(Exception& e)
510 {
|
511 kumpf 1.6 PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
512 exit(1);
|
513 yi.zhou 1.1 }
514
|
515 kumpf 1.2 delete repository;
516
|
517 yi.zhou 1.1 cout << "+++++ passed all tests" << endl;
518 return 0;
519 }
|