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