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

Diff for /pegasus/src/Pegasus/Handler/snmpIndicationHandler/tests/SnmpHandlerException/TestSnmpHandlerException.cpp between version 1.3 and 1.9.8.2

version 1.3, 2006/08/18 17:58:48 version 1.9.8.2, 2013/06/03 22:36:11
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; Symantec Corporation; The Open Group.  
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // Permission is hereby granted, free of charge, to any person obtaining a
 // of this software and associated documentation files (the "Software"), to  // copy of this software and associated documentation files (the "Software"),
 // deal in the Software without restriction, including without limitation the  // to deal in the Software without restriction, including without limitation
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // sell copies of the Software, and to permit persons to whom the Software is  // and/or sell copies of the Software, and to permit persons to whom the
 // furnished to do so, subject to the following conditions:  // Software is furnished to do so, subject to the following conditions:
 // //
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // The above copyright notice and this permission notice shall be included
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // in all copies or substantial portions of the Software.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 51 
Line 49 
 const CIMName testClass5 = CIMName ("SnmpTestClass5"); const CIMName testClass5 = CIMName ("SnmpTestClass5");
 const CIMName testClass6 = CIMName ("SnmpTestClass6"); const CIMName testClass6 = CIMName ("SnmpTestClass6");
 const CIMName testClass7 = CIMName ("SnmpTestClass7"); const CIMName testClass7 = CIMName ("SnmpTestClass7");
   const CIMName testClass8 = CIMName ("SnmpTestClass8");
 String repositoryRoot;  
  
 static CIMInstance CreateHandlerInstance() static CIMInstance CreateHandlerInstance()
 { {
Line 128 
Line 125 
 { {
     repository.createNameSpace(NS);     repository.createNameSpace(NS);
  
     CIMQualifierDecl q1(CIMName ("MappingStrings"), String(),      Array<String> qualifierValue;
       qualifierValue.append("");
   
       CIMQualifierDecl q1(CIMName ("MappingStrings"), qualifierValue,
         CIMScope::PROPERTY + CIMScope::CLASS);         CIMScope::PROPERTY + CIMScope::CLASS);
  
     // Qualifier name must be "MappingStrings", test the qualifier     // Qualifier name must be "MappingStrings", test the qualifier
     // name is not "MappingStrings"     // name is not "MappingStrings"
     CIMQualifierDecl q2(CIMName ("NotMappingStrings"), String(),      CIMQualifierDecl q2(CIMName ("NotMappingStrings"), qualifierValue,
         CIMScope::CLASS);         CIMScope::CLASS);
  
     repository.setQualifier(NS, q1);     repository.setQualifier(NS, q1);
     repository.setQualifier(NS, q2);     repository.setQualifier(NS, q2);
  
     String mappingStr = "OID.IETF | SNMP.1.3.6.1.4.1.892.2.3.9000.8600";      Array<String> classMappingStr;
       classMappingStr.append("OID.IETF | SNMP.1.3.6.1.4.1.892.2.3.9000.8600");
  
     CIMClass class1(testClass1);     CIMClass class1(testClass1);
     class1.addQualifier(CIMQualifier(CIMName ("MappingStrings"),     class1.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
         String(mappingStr)));          CIMValue(classMappingStr)));
   
       Array<String> invalidFormatStr;
       invalidFormatStr.append(
           "Wrong format OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
       invalidFormatStr.append("DataType.IETF | OctetString ");
  
     // create wrong format property mappingStrings value     // create wrong format property mappingStrings value
     class1.addProperty(CIMProperty(CIMName ("OidDataType"), String("OctetString"))      class1.addProperty(
           CIMProperty(CIMName("OidDataType"), String("OctetString"))
         .addQualifier(CIMQualifier(CIMName ("MappingStrings"),         .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
             String("Wrong format OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600, DataType.IETF | OctetString "))));              CIMValue(invalidFormatStr))));
  
     repository.createClass(NS, class1);     repository.createClass(NS, class1);
  
     // create invalid mapping string value     // create invalid mapping string value
     String mappingStr2 = "OID.IETF |Invalid Mapping String Value";      Array<String> class2MappingStr;
       Array<String> mappingStr2;
   
       class2MappingStr.append("OID.IETF |Invalid Mapping String Value");
   
       mappingStr2.append("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
       mappingStr2.append("DataType.IETF OctetString ");
  
     CIMClass class2(testClass2);     CIMClass class2(testClass2);
     class2.addQualifier(CIMQualifier(CIMName ("MappingStrings"),     class2.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
         String(mappingStr2)));          CIMValue(class2MappingStr)));
  
     class2.addProperty(CIMProperty(CIMName ("OidDataType"), String())     class2.addProperty(CIMProperty(CIMName ("OidDataType"), String())
         .addQualifier(CIMQualifier(CIMName ("MappingStrings"),         .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
             String("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600, DataType.IETF OctetString "))));              CIMValue(mappingStr2))));
     repository.createClass(NS, class2);     repository.createClass(NS, class2);
  
     // create non MappingStrings qualifier     // create non MappingStrings qualifier
     CIMClass class3(testClass3);     CIMClass class3(testClass3);
     class3.addQualifier(CIMQualifier(CIMName ("NotMappingStrings"), String(mappingStr)));      class3.addQualifier(CIMQualifier(CIMName ("NotMappingStrings"),
           CIMValue(classMappingStr)));
  
     repository.createClass(NS, class3);     repository.createClass(NS, class3);
  
     // error building ASN.1 representation     // error building ASN.1 representation
     String mappingStr4 = "OID.IETF | SNMP.1.204.6.1.6.3.1.330.5.1.0 ";      Array<String> class4MappingStr;
       class4MappingStr.append("OID.IETF | SNMP.1.204.6.1.6.3.1.330.5.1.0 ");
  
     CIMClass class4(testClass4);     CIMClass class4(testClass4);
     class4.addQualifier(CIMQualifier(CIMName ("MappingStrings"),     class4.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
     String(mappingStr4)));          CIMValue(class4MappingStr)));
  
     repository.createClass(NS, class4);     repository.createClass(NS, class4);
  
     // create incorrect class mappingStrings value     // create incorrect class mappingStrings value
     String mappingStr5 = "OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3 ";      Array<String> class5MappingStr;
       class5MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3 ");
  
     CIMClass class5(testClass5);     CIMClass class5(testClass5);
     class5.addQualifier(CIMQualifier(CIMName     class5.addQualifier(CIMQualifier(CIMName
         ("MappingStrings"), String(mappingStr5)));          ("MappingStrings"), CIMValue(class5MappingStr)));
  
     // create incorrect property name     // create incorrect property name
     class5.addProperty(     class5.addProperty(
         CIMProperty(CIMName ("WrongPropertyName"), String("OctetString"))         CIMProperty(CIMName ("WrongPropertyName"), String("OctetString"))
             .addQualifier(CIMQualifier(CIMName ("MappingStrings"),             .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
                 String(mappingStr5))));                  CIMValue(class5MappingStr))));
  
     repository.createClass(NS, class5);     repository.createClass(NS, class5);
  
     // create incorrect property mappingStrings value     // create incorrect property mappingStrings value
     String mappingStr6 =      Array<String> class6MappingStr;
        "OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3, DataType.IETF | OctetString ";      class6MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.3.1.1.0.1 ");
   
       Array<String> mappingStr6;
       mappingStr6.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3");
       mappingStr6.append("DataType.IETF | OctetString");
  
     CIMClass class6(testClass6);     CIMClass class6(testClass6);
     class6.addQualifier(CIMQualifier(CIMName ("MappingStrings"),     class6.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
         String("OID.IETF | SNMP.1.3.6.1.6.3.1.1.0.1 ")));          CIMValue(class6MappingStr)));
     class6.addProperty(     class6.addProperty(
         CIMProperty(CIMName ("OidDataType"), String("OctetString"))         CIMProperty(CIMName ("OidDataType"), String("OctetString"))
             .addQualifier(CIMQualifier(CIMName ("MappingStrings"),             .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
                 String(mappingStr6))));                  CIMValue(mappingStr6))));
  
     repository.createClass(NS, class6);     repository.createClass(NS, class6);
  
     // create unsupportted SNMP Data Type for the CIM property     // create unsupportted SNMP Data Type for the CIM property
     String mappingStr7 =      Array<String> class7MappingStr;
         "OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3, DataType.IETF | test ";      class7MappingStr.append("OID.IETF | SNMP.1.3.6.1.6.3.1.1.5.1 ");
   
       Array<String> mappingStr7;
       mappingStr7.append("OID.IETF | SNMP.1.3.6.1.6.test.1.1.5.1.3");
       mappingStr7.append("DataType.IETF | test ");
  
     CIMClass class7(testClass7);     CIMClass class7(testClass7);
     class7.addQualifier(CIMQualifier(CIMName ("MappingStrings"),     class7.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
         String("OID.IETF | SNMP.1.3.6.1.6.3.1.1.5.1 ")));          CIMValue(class7MappingStr)));
     class7.addProperty(     class7.addProperty(
         CIMProperty(CIMName ("OidDataType"), String("test"))         CIMProperty(CIMName ("OidDataType"), String("test"))
             .addQualifier(CIMQualifier(CIMName ("MappingStrings"),             .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
                 String(mappingStr7))));                  CIMValue(mappingStr7))));
  
     repository.createClass(NS, class7);     repository.createClass(NS, class7);
   
       // create invalid syntax for MappingStrings qualifier
       Array<String> invalidSyntax;
       Array<String> class8MappingStr;
       class8MappingStr.append("OID.IETF Invalid Syntax for MappingStrings");
   
       Array<String> mappingStr8;
       mappingStr8.append("OID.IETF | SNMP.1.3.6.1.4.1.2.3.9000.8600");
       mappingStr8.append("DataType.IETF | OctetString ");
   
       CIMClass class8(testClass8);
       class8.addQualifier(CIMQualifier(CIMName ("MappingStrings"),
           CIMValue(class8MappingStr)));
   
       class8.addProperty(CIMProperty(CIMName ("OidDataType"), String())
           .addQualifier(CIMQualifier(CIMName ("MappingStrings"),
               CIMValue(mappingStr8))));
       repository.createClass(NS, class8);
 } }
  
 static void TestExceptionHandling(CIMHandler* handler) static void TestExceptionHandling(CIMHandler* handler)
Line 267 
Line 309 
     TestException(handler, indicationHandlerInstance, indicationInstance,     TestException(handler, indicationHandlerInstance, indicationInstance,
         CIM_ERR_FAILED);         CIM_ERR_FAILED);
  
     // Test "SNMP session open failed" exception      // Test "invalid MappingStrings Syntax" exception
     indicationInstance = CIMInstance(testClass1);      indicationInstance = CIMInstance(testClass8);
       indicationInstance.addProperty(CIMProperty(
           CIMName ("OidDataType"), String("OctetString")));
     indicationHandlerInstance = CreateHandlerInstance();     indicationHandlerInstance = CreateHandlerInstance();
     indicationHandlerInstance.addProperty(CIMProperty(     indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHost"), String("")));         CIMName("TargetHost"), String("15.13.140.120")));
     indicationHandlerInstance.addProperty(CIMProperty(     indicationHandlerInstance.addProperty(CIMProperty(
         CIMName("TargetHostFormat"), Uint16(3)));         CIMName("TargetHostFormat"), Uint16(3)));
     indicationHandlerInstance.addProperty(CIMProperty(     indicationHandlerInstance.addProperty(CIMProperty(
         CIMName("SNMPVersion"), Uint16(2)));         CIMName("SNMPVersion"), Uint16(2)));
     indicationHandlerInstance.addProperty(CIMProperty(  
        CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));  
     indicationHandlerInstance.addProperty(CIMProperty(  
        CIMName("PortNumber"), Uint32(200)));  
     TestException(handler, indicationHandlerInstance, indicationInstance,     TestException(handler, indicationHandlerInstance, indicationInstance,
         CIM_ERR_FAILED);         CIM_ERR_FAILED);
  
Line 399 
Line 439 
 } }
  
  
 int main(int argc, char** argv)  int main()
 { {
  
     const char* pegasusHome = getenv("PEGASUS_HOME");     const char* pegasusHome = getenv("PEGASUS_HOME");
Line 412 
Line 452 
     String repositoryRoot = pegasusHome;     String repositoryRoot = pegasusHome;
     repositoryRoot.append("/repository");     repositoryRoot.append("/repository");
  
     CIMRepository_Mode mode;      CIMRepository* repository = new CIMRepository(
     mode.flag = CIMRepository_Mode::BIN;          repositoryRoot, CIMRepository::MODE_BIN);
     CIMRepository* repository = new CIMRepository(repositoryRoot, mode);  
  
     ConfigManager::setPegasusHome(pegasusHome);     ConfigManager::setPegasusHome(pegasusHome);
  
Line 441 
Line 480 
         repository->deleteClass(NS, testClass5);         repository->deleteClass(NS, testClass5);
         repository->deleteClass(NS, testClass6);         repository->deleteClass(NS, testClass6);
         repository->deleteClass(NS, testClass7);         repository->deleteClass(NS, testClass7);
           repository->deleteClass(NS, testClass8);
  
         //         //
         // -- Delete the qualifier:         // -- Delete the qualifier:


Legend:
Removed from v.1.3  
changed lines
  Added in v.1.9.8.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2