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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2