(file) Return to TestSnmpHandlerException.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Handler / snmpIndicationHandler / tests / SnmpHandlerException

  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                     testException = e; 
 95                 }
 96             
 97 yi.zhou 1.1     PEGASUS_TEST_ASSERT(exceptionCaught && 
 98                     testException.getCode() == statusCode);
 99             }
100             
101             // Snmp traps are sent, but, only partial data are in the trap since 
102             // 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 yi.zhou 1.1             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                 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 yi.zhou 1.5     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                 class1.addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
151 yi.zhou 1.5         CIMValue(classMappingStr)));
152 yi.zhou 1.1     
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                 class1.addProperty(CIMProperty(CIMName ("OidDataType"), String("OctetString"))
160                     .addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
161 yi.zhou 1.5             CIMValue(invalidFormatStr))));
162 yi.zhou 1.1 
163                 repository.createClass(NS, class1);
164             
165                 // create invalid mapping string value
166 yi.zhou 1.5     Array<String> class2MappingStr;
167                 Array<String> mappingStr2;
168             
169                 class2MappingStr.append("OID.IETF |Invalid Mapping String Value");
170             
171                 mappingStr2.append("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
172                 mappingStr2.append("DataType.IETF OctetString ");
173 yi.zhou 1.1 
174                 CIMClass class2(testClass2);
175                 class2.addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
176 yi.zhou 1.5         CIMValue(class2MappingStr)));
177 yi.zhou 1.1     
178                 class2.addProperty(CIMProperty(CIMName ("OidDataType"), String())
179                     .addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
180 yi.zhou 1.5             CIMValue(mappingStr2))));
181 yi.zhou 1.1     repository.createClass(NS, class2);
182             
183                 // create non MappingStrings qualifier
184                 CIMClass class3(testClass3);
185 yi.zhou 1.5     class3.addQualifier(CIMQualifier(CIMName ("NotMappingStrings"), 
186                     CIMValue(classMappingStr)));
187 yi.zhou 1.1     
188                 repository.createClass(NS, class3);
189             
190                 // error building ASN.1 representation
191 yi.zhou 1.5     Array<String> class4MappingStr;
192                 class4MappingStr.append("OID.IETF | SNMP.1.204.6.1.6.3.1.330.5.1.0 ");
193 yi.zhou 1.1 
194                 CIMClass class4(testClass4);
195                 class4.addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
196 yi.zhou 1.5         CIMValue(class4MappingStr)));
197 yi.zhou 1.1     
198                 repository.createClass(NS, class4);
199             
200                 // create incorrect class mappingStrings value
201 yi.zhou 1.5     Array<String> class5MappingStr;
202                 class5MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3 ");
203 yi.zhou 1.1 
204                 CIMClass class5(testClass5);
205                 class5.addQualifier(CIMQualifier(CIMName 
206 yi.zhou 1.5         ("MappingStrings"), CIMValue(class5MappingStr)));
207 yi.zhou 1.1 
208                 // create incorrect property name
209                 class5.addProperty(
210                     CIMProperty(CIMName ("WrongPropertyName"), String("OctetString"))
211                         .addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
212 yi.zhou 1.5                 CIMValue(class5MappingStr))));
213 yi.zhou 1.1     
214                 repository.createClass(NS, class5);
215             
216                 // create incorrect property mappingStrings value
217 yi.zhou 1.5     Array<String> class6MappingStr;
218                 class6MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.3.1.1.0.1 ");
219             
220                 Array<String> mappingStr6;
221                 mappingStr6.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3");
222                 mappingStr6.append("DataType.IETF | OctetString");
223 yi.zhou 1.1 
224                 CIMClass class6(testClass6);
225                 class6.addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
226 yi.zhou 1.5         CIMValue(class6MappingStr)));
227 yi.zhou 1.1     class6.addProperty(
228                     CIMProperty(CIMName ("OidDataType"), String("OctetString"))
229                         .addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
230 yi.zhou 1.5                 CIMValue(mappingStr6))));
231 yi.zhou 1.1     
232                 repository.createClass(NS, class6);
233             
234                 // create unsupportted SNMP Data Type for the CIM property
235 yi.zhou 1.5     Array<String> class7MappingStr;
236                 class7MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.3.1.1.5.1 ");
237             
238                 Array<String> mappingStr7;
239                 mappingStr7.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3");
240                 mappingStr7.append("DataType.IETF | test ");
241 yi.zhou 1.1 
242                 CIMClass class7(testClass7);
243                 class7.addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
244 yi.zhou 1.5         CIMValue(class7MappingStr)));
245 yi.zhou 1.1     class7.addProperty(
246                     CIMProperty(CIMName ("OidDataType"), String("test"))
247                         .addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
248 yi.zhou 1.5                 CIMValue(mappingStr7))));
249 yi.zhou 1.1     
250                 repository.createClass(NS, class7);
251 yi.zhou 1.5 
252                 // create invalid syntax for MappingStrings qualifier
253                 Array<String> invalidSyntax;
254                 Array<String> class8MappingStr;
255                 class8MappingStr.append("OID.IETF Invalid Syntax for MappingStrings");
256             
257                 Array<String> mappingStr8;
258                 mappingStr8.append("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
259                 mappingStr8.append("DataType.IETF | OctetString ");
260             
261                 CIMClass class8(testClass8);
262                 class8.addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
263                     CIMValue(class8MappingStr)));
264                 
265                 class8.addProperty(CIMProperty(CIMName ("OidDataType"), String())
266                     .addQualifier(CIMQualifier(CIMName ("MappingStrings"), 
267                         CIMValue(mappingStr8))));
268                 repository.createClass(NS, class8);
269 yi.zhou 1.1 }
270             
271             static void TestExceptionHandling(CIMHandler* handler)
272             {
273                 CIMInstance indicationHandlerInstance;
274             
275                 // Test "invalid IndicationHandlerSNMPMapper instance" exception
276                 CIMInstance indicationInstance(testClass1);
277                 indicationHandlerInstance = CreateHandlerInstance();
278                 TestException(handler, indicationHandlerInstance, indicationInstance,
279                     CIM_ERR_FAILED);
280             
281                 // Test "no required property TargetHostFormat" exception
282                 indicationInstance = CIMInstance(testClass1);
283                 indicationInstance.addProperty(CIMProperty(
284                    CIMName ("OidDataType"), String("OctetString")));
285                 indicationHandlerInstance = CreateHandlerInstance();
286                 indicationHandlerInstance.addProperty(CIMProperty(
287                    CIMName("TargetHost"), String("15.13.140.120")));
288                 indicationHandlerInstance.addProperty(CIMProperty(
289                     CIMName("SNMPVersion"), Uint16(2)));
290 yi.zhou 1.1     TestException(handler, indicationHandlerInstance, indicationInstance,
291                     CIM_ERR_FAILED);
292             
293                 // Test "no required property SNMPVersion" exception
294                 indicationInstance = CIMInstance(testClass1);
295                 indicationHandlerInstance = CreateHandlerInstance();
296                 indicationHandlerInstance.addProperty(CIMProperty(
297                    CIMName("TargetHost"), String("15.13.140.120")));
298                 indicationHandlerInstance.addProperty(CIMProperty(
299                     CIMName("TargetHostFormat"), Uint16(3)));
300                 TestException(handler, indicationHandlerInstance, indicationInstance,
301                     CIM_ERR_FAILED);
302             
303                 // Test "unsupported snmp Version" exception
304                 indicationInstance = CIMInstance(testClass1);
305                 indicationHandlerInstance = CreateHandlerInstance();
306                 indicationHandlerInstance.addProperty(CIMProperty(
307                    CIMName("TargetHost"), String("15.13.140.120")));
308                 indicationHandlerInstance.addProperty(CIMProperty(
309                     CIMName("TargetHostFormat"), Uint16(3)));
310                 indicationHandlerInstance.addProperty(CIMProperty(
311 yi.zhou 1.1         CIMName("SNMPVersion"), Uint16(5)));
312                 TestException(handler, indicationHandlerInstance, indicationInstance,
313                     CIM_ERR_FAILED);
314             
315                 // Test "SNMP session open failed" exception
316                 indicationInstance = CIMInstance(testClass1);
317                 indicationHandlerInstance = CreateHandlerInstance();
318                 indicationHandlerInstance.addProperty(CIMProperty(
319                    CIMName("TargetHost"), String("")));
320                 indicationHandlerInstance.addProperty(CIMProperty(
321                     CIMName("TargetHostFormat"), Uint16(3)));
322                 indicationHandlerInstance.addProperty(CIMProperty(
323                     CIMName("SNMPVersion"), Uint16(2)));
324                 indicationHandlerInstance.addProperty(CIMProperty(
325                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
326                 indicationHandlerInstance.addProperty(CIMProperty(
327                    CIMName("PortNumber"), Uint32(200)));
328                 TestException(handler, indicationHandlerInstance, indicationInstance,
329                     CIM_ERR_FAILED);
330             
331 yi.zhou 1.5     // Test "invalid MappingStrings Syntax" exception
332                 indicationInstance = CIMInstance(testClass8);
333                 indicationInstance.addProperty(CIMProperty(
334                     CIMName ("OidDataType"), String("OctetString")));
335                 indicationHandlerInstance = CreateHandlerInstance();
336                 indicationHandlerInstance.addProperty(CIMProperty(
337                    CIMName("TargetHost"), String("15.13.140.120")));
338                 indicationHandlerInstance.addProperty(CIMProperty(
339                     CIMName("TargetHostFormat"), Uint16(3)));
340                 indicationHandlerInstance.addProperty(CIMProperty(
341                     CIMName("SNMPVersion"), Uint16(2)));
342                 TestException(handler, indicationHandlerInstance, indicationInstance,
343                     CIM_ERR_FAILED);
344             
345 yi.zhou 1.1     // Test "invalid MappingStrings value" exception
346                 indicationInstance = CIMInstance(testClass2);
347                 indicationInstance.addProperty(CIMProperty(
348                     CIMName ("OidDataType"), String("OctetString")));
349                 indicationHandlerInstance = CreateHandlerInstance();
350                 indicationHandlerInstance.addProperty(CIMProperty(
351                    CIMName("TargetHost"), String("15.13.140.120")));
352                 indicationHandlerInstance.addProperty(CIMProperty(
353                     CIMName("TargetHostFormat"), Uint16(3)));
354                 indicationHandlerInstance.addProperty(CIMProperty(
355                     CIMName("SNMPVersion"), Uint16(2)));
356                 TestException(handler, indicationHandlerInstance, indicationInstance,
357                     CIM_ERR_FAILED);
358             
359                 // Test "no MappingStrings qualifier" exception
360                 indicationInstance = CIMInstance(testClass3);
361                 indicationHandlerInstance = CreateHandlerInstance();
362                 indicationHandlerInstance.addProperty(CIMProperty(
363                    CIMName("TargetHost"), String("15.13.140.120")));
364                 indicationHandlerInstance.addProperty(CIMProperty(
365                     CIMName("TargetHostFormat"), Uint16(3)));
366 yi.zhou 1.1     indicationHandlerInstance.addProperty(CIMProperty(
367                     CIMName("SNMPVersion"), Uint16(2)));
368                 TestException(handler, indicationHandlerInstance, indicationInstance,
369                     CIM_ERR_FAILED);
370             
371                 // Test "send trap failed" exception
372                 indicationInstance = CIMInstance(testClass4);
373                 indicationHandlerInstance = CreateHandlerInstance();
374                 indicationHandlerInstance.addProperty(CIMProperty(
375                    CIMName("TargetHost"), String("15.13.140.120")));
376                 indicationHandlerInstance.addProperty(CIMProperty(
377                     CIMName("TargetHostFormat"), Uint16(3)));
378                 indicationHandlerInstance.addProperty(CIMProperty(
379                     CIMName("SNMPVersion"), Uint16(2)));
380                 indicationHandlerInstance.addProperty(CIMProperty(
381                     CIMName("SNMPSecurityName"), String("t")));
382                 indicationHandlerInstance.addProperty(CIMProperty(
383                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
384                 TestException(handler, indicationHandlerInstance, indicationInstance,
385                     CIM_ERR_FAILED);
386             
387 yi.zhou 1.1     // Test "failed to add snmp variables to PDU", 
388                 // Both a DiscardedData message and an error message
389                 // are logged to log file 
390                 indicationInstance = CIMInstance(testClass5);
391                 indicationInstance.addProperty(CIMProperty(
392                     CIMName ("OidDataType"), String("OctetString")));
393                 indicationHandlerInstance = CreateHandlerInstance();
394                 indicationHandlerInstance.addProperty(CIMProperty(
395                    CIMName("TargetHost"), String("15.13.140.120")));
396                 indicationHandlerInstance.addProperty(CIMProperty(
397                     CIMName("TargetHostFormat"), Uint16(3)));
398                 indicationHandlerInstance.addProperty(CIMProperty(
399                     CIMName("SNMPVersion"), Uint16(2)));
400                 indicationHandlerInstance.addProperty(CIMProperty(
401                     CIMName("SNMPSecurityName"), String("t")));
402                 indicationHandlerInstance.addProperty(CIMProperty(
403                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
404                 TestError(handler, indicationHandlerInstance, indicationInstance);
405             
406                 // Test "convert enterprise OID from numeric form to a list of"
407                 // "subidentifiers failed".
408 yi.zhou 1.1     // Both a DiscardedData message and an error message
409                 // are logged to log file 
410                 indicationInstance = CIMInstance(testClass5);
411                 indicationInstance.addProperty(CIMProperty(
412                     CIMName ("OidDataType"), String("OctetString")));
413                 indicationHandlerInstance = CreateHandlerInstance();
414                 indicationHandlerInstance.addProperty(CIMProperty(
415                    CIMName("TargetHost"), String("15.13.140.120")));
416                 indicationHandlerInstance.addProperty(CIMProperty(
417                     CIMName("TargetHostFormat"), Uint16(3)));
418                 indicationHandlerInstance.addProperty(CIMProperty(
419                     CIMName("SNMPVersion"), Uint16(3)));
420                 indicationHandlerInstance.addProperty(CIMProperty(
421                     CIMName("SNMPSecurityName"), String("t")));
422                 indicationHandlerInstance.addProperty(CIMProperty(
423                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
424                 TestError(handler, indicationHandlerInstance, indicationInstance);
425             
426                 // Test "convert property OID from numeric form to a list of"
427                 // "subidentifiers failed".
428                 // Both a DiscardedData message and an error message
429 yi.zhou 1.1     // are logged to log file 
430                 indicationInstance = CIMInstance(testClass6);
431                 indicationInstance.addProperty(CIMProperty(
432                     CIMName ("OidDataType"), String("OctetString")));
433                 indicationHandlerInstance = CreateHandlerInstance();
434                 indicationHandlerInstance.addProperty(CIMProperty(
435                    CIMName("TargetHost"), String("15.13.140.120")));
436                 indicationHandlerInstance.addProperty(CIMProperty(
437                     CIMName("TargetHostFormat"), Uint16(3)));
438                 indicationHandlerInstance.addProperty(CIMProperty(
439                     CIMName("SNMPVersion"), Uint16(2)));
440                 indicationHandlerInstance.addProperty(CIMProperty(
441                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
442                 TestError(handler, indicationHandlerInstance, indicationInstance);
443             
444                 // Test "unsupported SNMP data type for the CIM property"
445                 // Both a DiscardedData message and an error message
446                 // are logged to log file 
447                 indicationInstance = CIMInstance(testClass7);
448                 indicationInstance.addProperty(CIMProperty(
449                     CIMName ("OidDataType"), String("test")));
450 yi.zhou 1.1     indicationHandlerInstance = CreateHandlerInstance();
451                 indicationHandlerInstance.addProperty(CIMProperty(
452                    CIMName("TargetHost"), String("15.13.140.120")));
453                 indicationHandlerInstance.addProperty(CIMProperty(
454                     CIMName("TargetHostFormat"), Uint16(3)));
455                 indicationHandlerInstance.addProperty(CIMProperty(
456                     CIMName("SNMPVersion"), Uint16(2)));
457                 TestError(handler, indicationHandlerInstance, indicationInstance);
458             }
459             
460             
461             int main(int argc, char** argv)
462             {
463             
464                 const char* pegasusHome = getenv("PEGASUS_HOME");
465                 if (!pegasusHome)
466                 {
467                     cerr << "PEGASUS_HOME environment variable not set" << endl;
468                     exit(1);
469                 }
470             
471 yi.zhou 1.1     String repositoryRoot = pegasusHome;
472                 repositoryRoot.append("/repository");
473             
474 kumpf   1.4     CIMRepository* repository = new CIMRepository(
475                     repositoryRoot, CIMRepository::MODE_BIN);
476 yi.zhou 1.1 
477                 ConfigManager::setPegasusHome(pegasusHome);
478             
479                 // -- Create repository and namespaces:
480             
481                 CreateRepository(*repository);
482             
483                 try
484                 {
485                     HandlerTable handlerTable;
486                     String handlerId = "snmpIndicationHandler";
487                     CIMHandler* handler = handlerTable.getHandler(handlerId, repository);
488             	PEGASUS_TEST_ASSERT(handler != 0);
489             
490                     TestExceptionHandling(handler);
491             
492                     //
493                     // -- Clean up classes:
494                     //
495                     repository->deleteClass(NS, testClass1);
496                     repository->deleteClass(NS, testClass2);
497 yi.zhou 1.1         repository->deleteClass(NS, testClass3);
498                     repository->deleteClass(NS, testClass4);
499                     repository->deleteClass(NS, testClass5);
500                     repository->deleteClass(NS, testClass6);
501                     repository->deleteClass(NS, testClass7);
502 yi.zhou 1.5         repository->deleteClass(NS, testClass8);
503 yi.zhou 1.1 
504                     //
505                     // -- Delete the qualifier:
506                     //
507                     repository->deleteQualifier(NS, CIMName ("MappingStrings"));
508                     repository->deleteQualifier(NS, CIMName ("NotMappingStrings"));
509             
510                     repository->deleteNameSpace(NS);
511                 }
512                 catch(Exception& e)
513                 {
514             	PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
515             	exit(1);
516                 }
517             
518 kumpf   1.2     delete repository;
519             
520 yi.zhou 1.1     cout << "+++++ passed all tests" << endl;
521                 return 0;
522             }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2