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

  1 martin 1.8 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.9 //
  3 martin 1.8 // 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 martin 1.9 //
 10 martin 1.8 // 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 martin 1.9 //
 17 martin 1.8 // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19 martin 1.9 //
 20 martin 1.8 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.9 // 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 martin 1.9 //
 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 yi.zhou 1.5     // Test "invalid MappingStrings Syntax" exception
313                 indicationInstance = CIMInstance(testClass8);
314                 indicationInstance.addProperty(CIMProperty(
315                     CIMName ("OidDataType"), String("OctetString")));
316                 indicationHandlerInstance = CreateHandlerInstance();
317                 indicationHandlerInstance.addProperty(CIMProperty(
318                    CIMName("TargetHost"), String("15.13.140.120")));
319                 indicationHandlerInstance.addProperty(CIMProperty(
320                     CIMName("TargetHostFormat"), Uint16(3)));
321                 indicationHandlerInstance.addProperty(CIMProperty(
322                     CIMName("SNMPVersion"), Uint16(2)));
323                 TestException(handler, indicationHandlerInstance, indicationInstance,
324                     CIM_ERR_FAILED);
325             
326 yi.zhou 1.1     // Test "invalid MappingStrings value" exception
327                 indicationInstance = CIMInstance(testClass2);
328                 indicationInstance.addProperty(CIMProperty(
329                     CIMName ("OidDataType"), String("OctetString")));
330                 indicationHandlerInstance = CreateHandlerInstance();
331                 indicationHandlerInstance.addProperty(CIMProperty(
332                    CIMName("TargetHost"), String("15.13.140.120")));
333                 indicationHandlerInstance.addProperty(CIMProperty(
334                     CIMName("TargetHostFormat"), Uint16(3)));
335                 indicationHandlerInstance.addProperty(CIMProperty(
336                     CIMName("SNMPVersion"), Uint16(2)));
337                 TestException(handler, indicationHandlerInstance, indicationInstance,
338                     CIM_ERR_FAILED);
339             
340                 // Test "no MappingStrings qualifier" exception
341                 indicationInstance = CIMInstance(testClass3);
342                 indicationHandlerInstance = CreateHandlerInstance();
343                 indicationHandlerInstance.addProperty(CIMProperty(
344                    CIMName("TargetHost"), String("15.13.140.120")));
345                 indicationHandlerInstance.addProperty(CIMProperty(
346                     CIMName("TargetHostFormat"), Uint16(3)));
347 yi.zhou 1.1     indicationHandlerInstance.addProperty(CIMProperty(
348                     CIMName("SNMPVersion"), Uint16(2)));
349                 TestException(handler, indicationHandlerInstance, indicationInstance,
350                     CIM_ERR_FAILED);
351             
352                 // Test "send trap failed" exception
353                 indicationInstance = CIMInstance(testClass4);
354                 indicationHandlerInstance = CreateHandlerInstance();
355                 indicationHandlerInstance.addProperty(CIMProperty(
356                    CIMName("TargetHost"), String("15.13.140.120")));
357                 indicationHandlerInstance.addProperty(CIMProperty(
358                     CIMName("TargetHostFormat"), Uint16(3)));
359                 indicationHandlerInstance.addProperty(CIMProperty(
360                     CIMName("SNMPVersion"), Uint16(2)));
361                 indicationHandlerInstance.addProperty(CIMProperty(
362                     CIMName("SNMPSecurityName"), String("t")));
363                 indicationHandlerInstance.addProperty(CIMProperty(
364                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
365                 TestException(handler, indicationHandlerInstance, indicationInstance,
366                     CIM_ERR_FAILED);
367             
368 kumpf   1.6     // Test "failed to add snmp variables to PDU",
369 yi.zhou 1.1     // Both a DiscardedData message and an error message
370 kumpf   1.6     // are logged to log file
371 yi.zhou 1.1     indicationInstance = CIMInstance(testClass5);
372                 indicationInstance.addProperty(CIMProperty(
373                     CIMName ("OidDataType"), String("OctetString")));
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                 TestError(handler, indicationHandlerInstance, indicationInstance);
386             
387                 // Test "convert enterprise OID from numeric form to a list of"
388                 // "subidentifiers failed".
389                 // 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(3)));
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 property 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(testClass6);
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(2)));
421                 indicationHandlerInstance.addProperty(CIMProperty(
422                    CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
423                 TestError(handler, indicationHandlerInstance, indicationInstance);
424             
425                 // Test "unsupported SNMP data type for the CIM property"
426                 // Both a DiscardedData message and an error message
427 kumpf   1.6     // are logged to log file
428 yi.zhou 1.1     indicationInstance = CIMInstance(testClass7);
429                 indicationInstance.addProperty(CIMProperty(
430                     CIMName ("OidDataType"), String("test")));
431                 indicationHandlerInstance = CreateHandlerInstance();
432                 indicationHandlerInstance.addProperty(CIMProperty(
433                    CIMName("TargetHost"), String("15.13.140.120")));
434                 indicationHandlerInstance.addProperty(CIMProperty(
435                     CIMName("TargetHostFormat"), Uint16(3)));
436                 indicationHandlerInstance.addProperty(CIMProperty(
437                     CIMName("SNMPVersion"), Uint16(2)));
438                 TestError(handler, indicationHandlerInstance, indicationInstance);
439             }
440             
441             
442             int main(int argc, char** argv)
443             {
444             
445                 const char* pegasusHome = getenv("PEGASUS_HOME");
446                 if (!pegasusHome)
447                 {
448                     cerr << "PEGASUS_HOME environment variable not set" << endl;
449 yi.zhou 1.1         exit(1);
450                 }
451             
452                 String repositoryRoot = pegasusHome;
453                 repositoryRoot.append("/repository");
454             
455 kumpf   1.4     CIMRepository* repository = new CIMRepository(
456                     repositoryRoot, CIMRepository::MODE_BIN);
457 yi.zhou 1.1 
458                 ConfigManager::setPegasusHome(pegasusHome);
459             
460                 // -- Create repository and namespaces:
461             
462                 CreateRepository(*repository);
463             
464                 try
465                 {
466                     HandlerTable handlerTable;
467                     String handlerId = "snmpIndicationHandler";
468                     CIMHandler* handler = handlerTable.getHandler(handlerId, repository);
469 kumpf   1.6         PEGASUS_TEST_ASSERT(handler != 0);
470 yi.zhou 1.1 
471                     TestExceptionHandling(handler);
472             
473                     //
474                     // -- Clean up classes:
475                     //
476                     repository->deleteClass(NS, testClass1);
477                     repository->deleteClass(NS, testClass2);
478                     repository->deleteClass(NS, testClass3);
479                     repository->deleteClass(NS, testClass4);
480                     repository->deleteClass(NS, testClass5);
481                     repository->deleteClass(NS, testClass6);
482                     repository->deleteClass(NS, testClass7);
483 yi.zhou 1.5         repository->deleteClass(NS, testClass8);
484 yi.zhou 1.1 
485                     //
486                     // -- Delete the qualifier:
487                     //
488                     repository->deleteQualifier(NS, CIMName ("MappingStrings"));
489                     repository->deleteQualifier(NS, CIMName ("NotMappingStrings"));
490             
491                     repository->deleteNameSpace(NS);
492                 }
493                 catch(Exception& e)
494                 {
495 kumpf   1.6         PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
496                     exit(1);
497 yi.zhou 1.1     }
498             
499 kumpf   1.2     delete repository;
500             
501 yi.zhou 1.1     cout << "+++++ passed all tests" << endl;
502                 return 0;
503             }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2