//-------------------------------------------------------------------- // Microsoft OLE DB Test // // Copyright 1995-2000 Microsoft Corporation. // // @doc // // @module irowinfo.cpp | Source file for test module IRowsetInfo // #include "modstandard.hpp" #define DBINITCONSTANTS // Must be defined to initialize constants in OLEDB.H #define INITGUID #include "irowinfo.h" #include "msdasql.h" #include // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Module Values // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // {{ TCW_MODULE_GLOBALS DECLARE_MODULE_CLSID = { 0x779ee042, 0x9239, 0x11cf, { 0xb4, 0xb2, 0x00, 0xaa, 0x00, 0xbb, 0xba, 0x1c }}; DECLARE_MODULE_NAME("IRowsetInfo"); DECLARE_MODULE_OWNER("Microsoft"); DECLARE_MODULE_DESCRIP("Test IRowsetInfo"); DECLARE_MODULE_VERSION(829078083); // TCW_WizardVersion(2) // TCW_Automation(True) // }} TCW_MODULE_GLOBALS_END ///////////////////////////////////////////////////////////// // Defines // ///////////////////////////////////////////////////////////// #define MAX_MULTI_ROWSETS 10 // Constant DBPROP Values DBPROPID DBPROP_NOTSUPPORTEDPROPERTY; DBPROPID DBPROP_NOTSUPPORTEDINTERFACE; DBPROPID DBPROP_NOTSETTABLEPROPERTY; DBPROPID DBPROP_SETTABLEPROPERTY; // NOTE: // When you remove these defines, please go down to the case statement in // CreateRowsetObjectWithInfo (just search for "case USE_GETCOLROWSET:") and // remove the commented out block - since these are all the same value // it was necessary to do this. The code was left in // #define USE_GETCOLROWSET ((EQUERY) 9999) // fake EQUERY // ENUMSOURCES // Apparently, EnumerateSources has been removed V1. // TODO Enumertor object is now inplememted, need to update test! #ifdef ENUMSOURCES #define USE_ENUMSOURCES SELECT_EMPTYROWSET // TODO for now (this one doesn't crash) #endif // Increment the error counter #define RECORD_FAILURE ((*m_pError)++) // If commands are not supported, certain tests may not be able to be run // The following variable should be set at ModuleInit time and will be // queried by those variations which require commands, so that the test // will not record a failure when the provider gives a NOT SUPPORTED error. // // Bookmarks are so commonly used that it too gets its own global variable. BOOL g_fBookmarksOnByDft; BOOL g_fBookmarksSettable; BOOL g_fBookmarksSupported; BOOL g_fSchemaRowSupported; BOOL g_fColumnRowSupported; // Strings for DBPROPERTYERROR values. // This is an ordered enumeration starting at 0, so a straight index // into the array can be used... // const WCHAR *g_szPropertyErrorStrings[] = { L"OK", L"NOT SUPPORTED", L"BAD VALUE", L"BAD OPTION", L"BAD COLUMN", L"NOT ALL SETTABLE", L"NOT SETTABLE", L"NOT SET", L"CONFLICTING" }; typedef struct tagDBEXPECTEDPROPERTY { DBPROPID dwPropertyID; VARIANT vValue; DBID colid; DBPROPOPTIONS dwOptions; LPCWSTR szPropertyName; BOOL bCheckValue; ULONG uLine; } DBEXPECTEDPROPERTY; #define PROPERTY_NOT_FOUND 0xFFFFFFFF // Will be in the 2.0 Leveling Spec. #define NUM_MANDATORY_PROPERTIES 5 #define ADD_MANDATORY_PROPERTIES(var,idx) \ (ADD_TRUE_PROP(&var[(idx)+0], DBPROP_IAccessor), \ ADD_TRUE_PROP(&var[(idx)+1], DBPROP_IRowsetInfo), \ ADD_TRUE_PROP(&var[(idx)+2], DBPROP_IColumnsInfo), \ ADD_TRUE_PROP(&var[(idx)+3], DBPROP_IConvertType), \ ADD_TRUE_PROP(&var[(idx)+4], DBPROP_IRowset)) DBEXPECTEDPROPERTY g_rgMandatoryInterfaces[NUM_MANDATORY_PROPERTIES]; //-------------------------------------------------------------------- // @func Sets up the data in a Boolean property entry for SetProperty // or to compare the results of GetProperty // // The version which sets up an expected property is primarily set // via macro, so no default exists for its value argument. // // @rdesc None // //-------------------------------------------------------------------- void SetupBooleanProperty ( DBEXPECTEDPROPERTY *pEntry, // @cparm [in out]: Entry to set const DBPROPID &dwPropertyID, // @cparm [in]: Property to set VARIANT_BOOL bValue, // @cparm [in]: Value WCHAR *szPropertyName, // @cparm [in]: Print string for logging ULONG uLine // @cparm [in]: Where it came from ) { pEntry->dwPropertyID = dwPropertyID; pEntry->vValue.vt = VT_BOOL; V_BOOL(&pEntry->vValue) = bValue; pEntry->szPropertyName = szPropertyName; pEntry->bCheckValue = TRUE; pEntry->colid = DB_NULLID; pEntry->dwOptions = DBPROPOPTIONS_REQUIRED; pEntry->uLine = uLine; } void SetupBooleanPropertyOptional ( DBEXPECTEDPROPERTY *pEntry, // @cparm [in out]: Entry to set const DBPROPID &dwPropertyID, // @cparm [in]: Property to set VARIANT_BOOL bValue, // @cparm [in]: Value WCHAR *szPropertyName, // @cparm [in]: Print string for logging ULONG uLine // @cparm [in]: Where it came from ) { pEntry->dwPropertyID = dwPropertyID; pEntry->vValue.vt = VT_BOOL; V_BOOL(&pEntry->vValue) = bValue; pEntry->szPropertyName = szPropertyName; pEntry->bCheckValue = TRUE; pEntry->colid = DB_NULLID; pEntry->dwOptions = DBPROPOPTIONS_OPTIONAL; pEntry->uLine = uLine; } void SetupUndefinedProperty ( DBEXPECTEDPROPERTY *pEntry, // @cparm [in out]: Entry to set const DBPROPID &dwPropertyID, // @cparm [in]: Property to set WCHAR *szPropertyName, // @cparm [in]: Print string for logging ULONG uLine // @cparm [in]: Where it came from ) { pEntry->dwPropertyID = dwPropertyID; pEntry->szPropertyName = szPropertyName; pEntry->bCheckValue = FALSE; pEntry->colid = DB_NULLID; pEntry->dwOptions = DBPROPOPTIONS_REQUIRED; pEntry->uLine = uLine; } void SetupUnsupportedProperty ( DBEXPECTEDPROPERTY *pEntry, // @cparm [in out]: Entry to set const DBPROPID &dwPropertyID, // @cparm [in]: Property to set WCHAR *szPropertyName, // @cparm [in]: Print string for logging ULONG uLine // @cparm [in]: Where it came from ) { pEntry->dwPropertyID = dwPropertyID; pEntry->szPropertyName = szPropertyName; pEntry->bCheckValue = FALSE; pEntry->colid = DB_NULLID; pEntry->dwOptions = DBPROPOPTIONS_REQUIRED; pEntry->uLine = uLine; pEntry->vValue.vt = VT_BOOL; V_BOOL(&pEntry->vValue) = VARIANT_TRUE; // All of the unsupported properties we choose at this time are boolean. May need to change... } #define ADD_BOOL_PROP(entry,prop,value) SetupBooleanProperty(entry,prop,value,L#prop,__LINE__) #define ADD_TRUE_PROP_OPTIONAL(entry,prop) SetupBooleanPropertyOptional(entry,prop,VARIANT_TRUE,L#prop,__LINE__) #define ADD_TRUE_PROP(entry,prop) SetupBooleanProperty(entry,prop,VARIANT_TRUE,L#prop,__LINE__) #define ADD_FALSE_PROP(entry,prop) SetupBooleanProperty(entry,prop,VARIANT_FALSE,L#prop,__LINE__) #define ADD_UNSUP_PROP(entry,prop) SetupUnsupportedProperty(entry,prop,L#prop,__LINE__) #define ADD_UNDEF_PROP(entry,prop) SetupUndefinedProperty(entry,prop,L#prop,__LINE__) //-------------------------------------------------------------------- // @func Module level initialization routine // // @rdesc Success or Failure // @flag TRUE | Successful initialization // @flag FALSE | Initialization problems // BOOL ModuleInit(CThisTestModule * pThisTestModule) { DBPROP_NOTSUPPORTEDPROPERTY = 0; // The following are the mandatory interfaces... ADD_MANDATORY_PROPERTIES(g_rgMandatoryInterfaces, 0); if(ModuleCreateDBSession(pThisTestModule)) return TRUE; return FALSE; } //-------------------------------------------------------------------- // @func Module level termination routine // // @rdesc Success or Failure // @flag TRUE | Successful initialization // @flag FALSE | Initialization problems // BOOL ModuleTerminate(CThisTestModule * pThisTestModule) { // Free the interface we got in ModuleCreateDBSession() return ModuleReleaseDBSession(pThisTestModule); } //-------------------------------------------------------------------- // @func Is a given property included in a property list? // // Searches a property list returned by IRowsetInfo::GetProperties // to determine if a given property is included in the list. // // Currently, the implementation is a linear search. While not // the most efficient, there may not be a great enough number // of searches to justify spending much time improving the // algorithm. // // COMMENT: Necessary when cProperties is 0 to GetProperties. // Not clear if when cProperties is > 0, the properties come back // in the same order as they are requested in GetProperties. // // @rdesc Returns TRUE if the property is found, false otherwise. // If lPropSetIndex is not NULL, it will be set to the property // set index of the set containing the property; if lPropIndex is // not NULL it will be set to the index within the property set // which contains the related property information; if ppProperty // is not NULL it is set to a pointer to the matched property. // // If the property is not found, *lPropSetIndex and *lPropIndex // will be set to PROPERTY_NOT_FOUND and *ppProperty will be set // to NULL. // // In some situations the caller cares merely that a match exists, // but does not care about the match data: in these cases, the caller // may safely pass NULL as the out arguments. // // CHANGED FOR M8: The returned property is no longer a list of properties // but a list of property lists. For this test all desired properties fall // in the same list. // //-------------------------------------------------------------------- BOOL IsPropertyInList ( const DBPROPID dwPropertyID, // @cparm [in]: Property to look for const DBPROPSET *prgProperties, // @cparm [in]: Property list ULONG cNumProperties, // @cparm [in]: Number of properties in property list ULONG *lPropSetIndex, // @cparm [out]: Which prop set contains property ULONG *lPropIndex, // @cparm [out]: Which property in prop set DBPROP **ppProperty // @cparm [out]: Actual property data ) { // Loop down the list, checking the property against each entry // until a match is found. for (ULONG uIndex1=0; uIndex1 < cNumProperties; uIndex1++) { for (ULONG uIndex2=0; uIndex2 < prgProperties[uIndex1].cProperties; uIndex2++) { if( (dwPropertyID == prgProperties[uIndex1].rgProperties[uIndex2].dwPropertyID) && (prgProperties[uIndex1].guidPropertySet == DBPROPSET_ROWSET) ) { if (lPropSetIndex) *lPropSetIndex = uIndex1; if (lPropIndex) *lPropIndex = uIndex2; if (ppProperty) *ppProperty = &prgProperties[uIndex1].rgProperties[uIndex2]; return TRUE; } } } if (lPropSetIndex) *lPropSetIndex = NULL; if (lPropIndex) *lPropIndex = NULL; return FALSE; } //-------------------------------------------------------------------- // @func Remove a property entry from a property list. // // When a property list is being checked for correctness, // each expected property is searched from the list returned // from IRowsetInfo::GetProperties. Matching properties are // removed from the list. // // When all required entries have been removed, the list should // be empty unless "Return all properties" was requested and // the Rowset interface defines its own properties. // // Now its no longer a list of properties, but // a list of property lists. The entry to be deleted is identified // by Set Index and Index within the set; as a programming safeguard // I pass a pointer to the property to be deleted and check against // the delete indeces. // // @rdesc none //-------------------------------------------------------------------- void RemoveProperty ( DBPROPSET *prgPropertyList, // @cparm [in out]: Property list ULONG uIndexMatchSet, // @cparm [in] Property set containing property to remove ULONG uIndexToRemove // @cparm [in] 0-based index of entry to remove ) { // Subtract one from the count prgPropertyList[uIndexMatchSet].cProperties--; if (uIndexToRemove < prgPropertyList[uIndexMatchSet].cProperties) memcpy(&prgPropertyList[uIndexMatchSet].rgProperties[uIndexToRemove], &prgPropertyList[uIndexMatchSet].rgProperties[uIndexToRemove + 1], sizeof(DBPROP) * (prgPropertyList[uIndexMatchSet].cProperties - uIndexToRemove)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Base Class Section // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - typedef enum {STATE_TEXT_SET, STATE_PREPARED} enumSTATE; // @class GenTblEntry (General Table Entry) Support class used to encapsulate // information found in the test specification tables. Arrays of these table // entries comprise the basis for the General tests found under GetProperties // of the test specification; however, each table entry also includes a test // for GetReferencedRowset and GetSpecification as well. // // A single table entry is one "column entry" of the tables found in the test // specification. class GenTblEntry { public: // @cmember SQL Statement on which to base rowset for this test enum EQUERY m_fSQLQuery; // @cmember Properties to ask for before creating rowset UWORD m_cPresetProperties; DBEXPECTEDPROPERTY *m_prgPresetProperties; // @cmember Additional property: Requested ID const GUID *m_id; DBPROPID m_idRequestedID; WCHAR *m_szRequestedIDString; // @cmember State of the Command Object: either "Text Set" or "Prepared" enumSTATE m_eCmdObjState; // @cmember Properties which are inquired via GetProperties ULONG m_cInquiredProperties; DBEXPECTEDPROPERTY *m_prgInquiredProperties; // @cmember Returned value ULONG m_cReturnedProperties; DBEXPECTEDPROPERTY *m_prgReturnedProperties; BOOL m_bAllowMoreProperties; // obsolete - ignored // @cmember Column to request from GetReferencedRowset ULONG m_ulColumn; // @cmember HRESULT expected from GetReferencedRowset HRESULT m_hrGetReferencedRowset; // @cmember IID used to request from GetSpecification const GUID *m_idCommandObjectID; // @cmember HRESULT expected from GetSpecification HRESULT m_hrGetSpecification; // @cmember String representing SQL Text (EQUERY name) // Entered automatically via TEST_TABLE_ENTRY macro // from m_szQuery argument; used to identify table // entry in test logs WCHAR *m_pszSelectString; // // @cmember Source line of this table entry // Entered automatically via TEST_TABLE_ENTRY macro // used so tester can quickly located source of failures ULONG m_uLine; }; #define TEST_TABLE_ENTRY(a,b,c,d,e,f,g,h,i,j,k,l) \ {a,\ (UWORD) ((b) ? (sizeof(b) / sizeof(*((DBEXPECTEDPROPERTY *)(b)))) : 0),(b),\ &c,d,L#d,e,\ (ULONG) ((f) ? (sizeof(f) / sizeof(*((DBEXPECTEDPROPERTY *)(f)))) : 0),(f),\ (ULONG) ((h) ? (sizeof(h) / sizeof(*((DBEXPECTEDPROPERTY *)(h)))) : 0),(h),\ g,\ i,j,\ &k,l,\ L#a, __LINE__} // Forward declaration necessary. class CSubRowset; // @class CRowsetInfoSupport Base Class for all IRowsetInfo test cases // provides intermediate functions to verify "universal behavior" of the // IRowsetInfo functions (i.e., when error occurs, proper fields are reset, // when successful, proper fields contain data); also provides functions // which execute a repeated series of steps which constitute the test // performed by several variations or by multiple table entries within // a variation. class CRowsetInfoSupport : public CRowsetObject { public: // @cmember Constructor CRowsetInfoSupport(LPWSTR wszTestCaseName) : CRowsetObject(wszTestCaseName) { // Initialize g_fBookmarksOnByDft = FALSE; g_fBookmarksSettable = FALSE; g_fBookmarksSupported = FALSE; g_fSchemaRowSupported = FALSE; g_fColumnRowSupported = FALSE; m_pszSQLStatement = NULL; m_pICreator = NULL; m_pICmdPrepare = NULL; m_pIRowsetInfo = NULL; }; // @cmember Destructor virtual ~CRowsetInfoSupport(){}; // @cmember Common base class initialization BOOL Init(); // @cmember Common base class termination BOOL Terminate(); // @cmember Calls IRowsetInfo::GetProperties; verifies whenever an // error code is returned, *pcProperties is set to 0 and *prgProperties // is set to NULL. All test case calls pass through here. HRESULT GetProperties ( ULONG cProperties, // @parm [IN] Count of properties for which values are requested DBPROPIDSET rgProperties[], // @parm [IN] Array of size cProperties containing GUIDs representing properties of interest ULONG * pcProperties, // @parm [OUT] Number of properties returned DBPROPSET ** prgProperties // @parm [OUT] Returned properties and values ); // @cmember Calls IRowsetInfo::GetProperties HRESULT GetProperties ( ULONG cProperties, // @parm [IN] Count of properties for which values are requested DBPROPID * rgPropIDs, // @parm [IN] Array of size cProperties containing GUIDs representing properties of interest ULONG * pcProperties, // @parm [OUT] Number of properties returned DBPROPSET ** prgProperties // @parm [OUT] Returned properties and values ); // @cmember Calls IRowsetInfo::GetReferencedRowset; verifies whenever // an error code is returned, *ppReferencedRowset is set to NULL. All // test case calls pass through here. HRESULT GetReferencedRowset ( DBORDINAL iOrdinal, // @parm [IN] The bookmark or chapter column for which to get the related rowset REFIID riid, // @parm [IN] ID of interface pointer to return in ppReferencedRowset IUnknown **ppReferencedRowset // @parm [OUT] Where to return interface pointer on rowset which interprets values from this column ); // @cmember Calls IRowsetInfo::GetSpecification; verifies whenever an // error code is returned, *pcSpecification is set to NULL. All test // case code pass through here. GetSpecification also always tests // the reference count of the creator. HRESULT GetSpecification ( REFIID riid, // @parm [IN] ID of interface on which to return pointer IUnknown ** ppSpecification // @parm [OUT] Object which created the rowset ); // @cmember Calls CreateRowsetObject and sets up the m_pIRowsetInfo // member field for later use by member functions. If desired, // can specify properties to request on OPEN, but these must // be successful and the error return array is automatically checked. // HRESULT CreateRowsetObjectWithInfo ( EQUERY eQuery, //@parm [IN] Query to generate rowset with REFIID riid, //@parm [IN] What type of rowset to create ULONG cProperties=0, //@parm [IN] Number of properties to set DBEXPECTEDPROPERTY *rgProperties=NULL, //@parm [IN] Properties to set enumSTATE fPrepare=STATE_TEXT_SET //@parm [IN] STATE_TEXT_SET or STATE_PREPARE ); // @cmember Releases a rowset created with an Info object as // well as its Info object. void ReleaseRowsetObjectWithInfo(BOOL bReleaseEverything = TRUE); BOOL CheckPropertyValue (const DBEXPECTEDPROPERTY *pExpectedEntry, const DBPROP *pActualEntry); // @cmember Check the property list returned by GetProperties against // a set of expected properties ULONG ComparePropertyLists (DBPROPSET *prgReturnedProperties, // @cparm [in]: Prop list from GetProperties. ULONG cNumReturnedProperties, // @cparm [in]: # entries in prgReturnedProperties const DBEXPECTEDPROPERTY *prgRequiredProperties, // @cparm [in]: Prop. which must appear ULONG cNumRequiredProperties, // @cparm [in] Number of required properties const DBEXPECTEDPROPERTY *prgPermittedProperties, // @cparm [in]: Prop. which MAY appear ULONG cNumPermittedProperties, // @cparm [in]: Number of permitted properties ULONG uCompareFlags // @cparm [in]: Flags: see function description ); #define COMPAREPROP_CHECKVALUES (0x0001) // check value when a match is found #define COMPAREPROP_DISALLOWEXTRAS (0x0002) // check that no other properties remain #define COMPAREPROP_NODUPCHECK (0x0004) // check each match occurs only once #define COMPAREPROP_LOGCHECKS (0x0008) // print a line for each property checked // @cmember Check the interface returned by GetReferencedRowset int CheckGetRRRetval(IUnknown *(&pRRRetval)); // @cmember Check the interface returned by GetSpecification int CheckGetSpecRetval(IUnknown *(&pSpecRetval)); // @cmember Dumps the errors CreateRowsetObject found on SetProperties void DumpPropertyErrors(ULONG cNumProperties, DBEXPECTEDPROPERTY *rgProperties, DBPROPSET *rgPropSet, ULONG &cNumErrors, ULONG &cNumNotSupported); // @cmember Creates an encapsulated rowset CSubRowset *MakeNewRowset(HRESULT *phr, EQUERY fQuery, ULONG cProperties = 0, DBEXPECTEDPROPERTY *rgProperties = NULL); // @cmember Releases an encapsulated rowset created by MakeNewRowset void ReleaseRowset(CSubRowset *(&pRowset)); // @cmember IRowsetInfo interface to the current rowset (in m_pIRowset) IRowsetInfo * m_pIRowsetInfo; // @cmember Count of columns in current rowset DBORDINAL m_cRowsetColumns; // @cmember Is there a bookmark column on this rowset. BOOL m_fBookmarksActive; // @cmember Who created the rowset created by CreateRowsetObject // Used to check return value of GetSpecification IUnknown * m_pICreator; // @cmember SQL Text for prepared statements WCHAR * m_pszSQLStatement; // @cmember For prepared items, command object ICommandPrepare * m_pICmdPrepare; private: }; // @class CSubRowset // For those test cases which require more than one rowset, CSubRowset provides // a mechanism for declaring multiple rowsets; each rowset gets the same methods // as the "implicit" rowset defined for each test case. (For example, each // SubRowset in a set of multiple rowsets can call the RowsetInfoSupport version // of GetProperties, which performs certain return value validations). // // CSubRowset looks to C++ like a test case because CRowsetInfoSupport inherits // from CTestCase; however, its purpose is not to provide test variations but // to support all the functionality encapsulated between CTestCase and a test // case class, in an instance where the test case must distinguish between // several rowset objects at the same time. // class CSubRowset : public CRowsetInfoSupport { public: //@cmember CTOR CSubRowset(LPWSTR tcName) : CRowsetInfoSupport(tcName) { m_pReferencedRowset = NULL; m_pSpecification = NULL; }; //@cmember Initialization virtual BOOL Init(); //@cmember Termination virtual BOOL Terminate(); //@cmember Finds a row and optionally returns the hRow for that row //@cmember Copies normally initialized by test framework test case info //into the encapsulated object which inherits from CTestCases. void CopyTestCaseInfo(CTestCases * pTC); // @cmember: where to place the result IUnknown *m_pReferencedRowset; // @cmember: where to place the result IUnknown *m_pSpecification; }; //-------------------------------------------------------------------- // @mfunc Init // Call the parent Init routine. CSubRowset has no member fields // of its own to set up. // // Following the call of the parent Init routine, it is still necessary // to copy test case information. //-------------------------------------------------------------------- BOOL CSubRowset::Init() { if(CRowsetInfoSupport::Init()) { return TRUE; } return FALSE; } //-------------------------------------------------------------------- // @mfunc CopyTestCaseInfo // Copies the test case info from the given testcase into this sub-rowset // object. This is needed since CSubRowset inherits from CTestCases // and may need to access some of the data members which are normally // set in initialization of a testcase, which won't happen because // we are encapsulating rather than inheriting from CRowsetInfoSupport. //-------------------------------------------------------------------- void CSubRowset::CopyTestCaseInfo(CTestCases * pTC) { SetOwningMod(0, pTC->m_pThisTestModule); } //-------------------------------------------------------------------- // @mfunc Terminate // Call the parent Terminate routine. CSubRowset has no member fields // of its own to clean up. //-------------------------------------------------------------------- BOOL CSubRowset::Terminate() { return(CRowsetInfoSupport::Terminate()); } //-------------------------------------------------------------------- // @mfunc Base class Initialization Routine // // @rdesc TRUE or FALSE // BOOL CRowsetInfoSupport::Init() { if(CRowsetObject::Init()) { HRESULT hr = E_FAIL; IDBSchemaRowset * pIDBSchemaRowset = NULL; IColumnsRowset * pIColumnsRowset = NULL; // Create a new DSO and Session CreateDBSession(); // Create a table we'll use for the whole test module, m_pTable = new CTable(m_pIOpenRowset, (LPWSTR)gwszModuleName); if(!m_pTable) return FALSE; // Start with a table with one row if (FAILED(hr=m_pTable->CreateTable(10))) return FALSE; // Display the row number we'll use -- this is for reproing odtLog << L"The single row table is using insert seed " <GetRowsOnCTable() << L" for this run." <DropTable(); delete m_pTable; m_pTable = NULL; } return(CRowsetObject::Terminate()); } //-------------------------------------------------------------------- // @mfunc Create an "encapsulated" rowset, so that test cases can // simultaneously process multiple rowsets with each rowset having // the functionality of the rowset which is provided as part of // all test cases inherited from CRowsetObject. // // @rdesc Pointer to the sub-rowset, which the caller is responsible // for freeing (by calling ReleaseRowset). If the creation fails, // all resources are released and MakeNewRowset returns NULL. // CSubRowset* CRowsetInfoSupport::MakeNewRowset(HRESULT *phr, EQUERY fQuery, ULONG cProperties, DBEXPECTEDPROPERTY *rgProperties) { CSubRowset *pReturnRowset = NULL; *phr = S_OK; pReturnRowset = new CSubRowset(L""); if (pReturnRowset) { pReturnRowset->CopyTestCaseInfo(this); if (pReturnRowset->Init()) { *phr = pReturnRowset->CreateRowsetObjectWithInfo(fQuery, IID_IRowset, cProperties, rgProperties); if (*phr == S_OK) return pReturnRowset; // This is coded so that if required properties are not set, no // failure is logged; but if a failure is logged it will show // we were expecting success. // if (*phr != DB_S_ERRORSOCCURRED) { CHECK(*phr, S_OK); odtLog << L"** FAILURE **: Couldn't create sub-rowset" <ReleaseRowsetObjectWithInfo(); } pReturnRowset->Terminate(); delete pReturnRowset; pReturnRowset = NULL; } return FALSE; } // @mfunc Release a rowset created by MakeNewRowset // // @rdesc none // void CRowsetInfoSupport::ReleaseRowset(CSubRowset *(&pRowset)) { if (pRowset) { pRowset->ReleaseRowsetObjectWithInfo(); pRowset->Terminate(); delete pRowset; pRowset = NULL; } } // @mfunc CGetRefRSParameters // All of the GetReferencedRowset parameter tests are based on this class, // which merely provides a member variable to hold the return value for // the GetReferencedRowset call (this would otherwise be a local variable // common to every test variation). class CGetRefRSParameters : public CRowsetInfoSupport { public: // @cmember Constructor CGetRefRSParameters(LPWSTR wszTestCaseName) : CRowsetInfoSupport(wszTestCaseName) {}; // @cmember Destructor virtual ~CGetRefRSParameters(){}; protected: // @cmember: where to place the result IUnknown *m_pReferencedRowset; }; // @mfunc CGetSpecParameters // All of the GetSpecification parameter tests are based on this class, // which merely provides a member variable to hold the return value for // the GetSpecification call (this would otherwise be a local variable // common to every test variation). class CGetSpecParameters : public CRowsetInfoSupport { public: // @cmember Constructor CGetSpecParameters(LPWSTR wszTestCaseName) : CRowsetInfoSupport(wszTestCaseName) {}; // @cmember Destructor virtual ~CGetSpecParameters(){}; protected: // @cmember: where to place the result IUnknown *m_pSpecification; }; HRESULT CRowsetInfoSupport::GetProperties ( ULONG cPropertyIDSets, DBPROPIDSET rgPropertyIDSets[], ULONG * pcPropertySets, DBPROPSET ** prgPropertySets ) { HRESULT hr = E_FAIL; // Initialize to INVALID if (pcPropertySets) *pcPropertySets = INVALID(ULONG); if (prgPropertySets) *prgPropertySets = INVALID(DBPROPSET *); // Call GetProperties if (m_pIRowsetInfo) hr = m_pIRowsetInfo->GetProperties(cPropertyIDSets, rgPropertyIDSets, pcPropertySets, prgPropertySets); // Check the return code if (FAILED(hr) && (hr != DB_E_ERRORSOCCURRED)) { // Whenever GetProperties returns an error condition if ((pcPropertySets && *pcPropertySets) || (prgPropertySets && *prgPropertySets)) { odtLog << L"GetProperties failed but did not reset the return values." <GetReferencedRowset(iOrdinal, riid, ppReferencedRowset); // Whenever GetReferencedRowset returns an error condition, // ppReferencedRowset is to be set to NULL. if (FAILED(hr) && (ppReferencedRowset && *ppReferencedRowset)) odtLog << L"GetReferencedRowset failed but did not reset *ppReferencedRowset" <GetSpecification(riid, ppSpecification); // Whenever GetReferencedRowset returns an error condition, // ppReferencedRowset is to be set to NULL. if (FAILED(hr) && (ppSpecification && *ppSpecification)) { odtLog << L"GetSpecification failed but did not reset *ppSpecification" <ExecuteCommand(eQuery,IID_IUnknown,NULL,NULL, NULL,NULL,EXECUTE_NEVER,0,NULL,NULL,NULL,&m_pICommand), S_OK)) break; // Prepare the Text if(VerifyInterface(m_pICommand, IID_ICommandPrepare,COMMAND_INTERFACE, (IUnknown **) &m_pICmdPrepare)) { if (!CHECK(m_pICmdPrepare->Prepare(1), S_OK)) { break; } } } // Set up the Property Structure if(cProperties > 0) { // Allocate memory and fill the property structure prgProperties = (DBPROP *) PROVIDER_ALLOC(sizeof(DBPROP) * cProperties); fNotSupported = (BOOL *) PROVIDER_ALLOC(sizeof(BOOL) * cProperties); memset(fNotSupported,0,sizeof(BOOL) * cProperties); for(ULONG uIndex = 0; uIndex < cProperties; uIndex++) { prgProperties[uIndex].dwPropertyID = rgProperties[uIndex].dwPropertyID; prgProperties[uIndex].vValue = rgProperties[uIndex].vValue; prgProperties[uIndex].colid = rgProperties[uIndex].colid; prgProperties[uIndex].dwOptions = rgProperties[uIndex].dwOptions; prgProperties[uIndex].dwStatus = 0; // Count the unsupported and unsettable properties if(!SupportedProperty(rgProperties[uIndex].dwPropertyID, DBPROPSET_ROWSET, m_pIDBInitialize)) { fNotSupported[uIndex] = TRUE; } } // Set up the Property Structure PropertySet.rgProperties = prgProperties; PropertySet.cProperties = cProperties; PropertySet.guidPropertySet = DBPROPSET_ROWSET; // Set the Property and free the memory if(!CHECK(hr=SetRowsetProperties(&PropertySet, 1), S_OK)) { PROVIDER_FREE(prgProperties); break; } } // Free the Properties structure PROVIDER_FREE(prgProperties); // Get the Rowset Object if(eQuery == USE_GETCOLROWSET) { hr=CreateRowsetObject(USE_OPENROWSET, IID_IColumnsRowset, EXECUTE_IFNOERROR); hr=CreateColumnRowset(); } else { // Check to see if the IID is supported if( ((riid == IID_IRowsetChange) && (SupportedProperty(DBPROP_IRowsetChange,DBPROPSET_ROWSET,m_pIDBInitialize))) || ((riid == IID_IRowsetLocate) && (SupportedProperty(DBPROP_IRowsetLocate,DBPROPSET_ROWSET,m_pIDBInitialize))) ) hr=CreateRowsetObject(eQuery, riid, EXECUTE_IFNOERROR); else hr=CreateRowsetObject(eQuery, IID_IRowset, EXECUTE_IFNOERROR); } if(m_rgPropSets) { //if a prop is not supported make sure it comes back as not supported for(ULONG uIndex = 0; uIndex < cProperties; uIndex++) { if(fNotSupported[uIndex]) { COMPARE(m_rgPropSets->rgProperties[uIndex].dwStatus,DBPROPSTATUS_NOTSUPPORTED); } } } // Check to see if the Provider supports Views if((FAILED(hr)) && (eQuery == SELECT_REVCOLLISTFROMVIEW)) { odtLog<GetColumnInfo(&m_cRowsetColumns, &rgInfo, &pStringsBuffer), S_OK); if(!m_cRowsetColumns) { odtLog << L"** FAILURE **: Unable to get number of columns." <iOrdinal)) m_cRowsetColumns--; // Release the objects SAFE_RELEASE(pIColumnsInfo); PROVIDER_FREE(rgInfo); PROVIDER_FREE(pStringsBuffer); } // The rowset we created is stored in Accessor, but the local tools // require the copy in m_pIRowsetInfo (so it doesn't always have // to figure out where CreateRowsetObject left the darn thing). It // is NOT necessary to release the copy. if(VerifyInterface(m_pIAccessor, IID_IRowsetInfo, ROWSET_INTERFACE, (IUnknown **) &m_pIRowsetInfo)) { // Remember who created this rowset, so we can check the return // value of GetSpecification switch (eQuery) { case USE_OPENROWSET: case USE_GETCOLROWSET: case SELECT_DBSCHEMA_TABLE: m_pICreator = m_pIOpenRowset; break; // case USE_ENUMSOURCES: // m_pICreator = m_pIDBCreateCommand; // break; default: m_pICreator = m_pICommand; } return S_OK; } } while (FALSE); cleanup_rowset: // Cleanup from CreateRowsetObject, which succeeded. ReleaseRowsetObject(); SAFE_RELEASE(m_pICmdPrepare); // If previous stuff was saved, do not release it // during this cleanup. if(m_pICommand) ReleaseCommandObject(); return hr; } void CRowsetInfoSupport::ReleaseRowsetObjectWithInfo(BOOL bReleaseEverything) { // Release the objects SAFE_RELEASE(m_pIRowsetInfo); SAFE_RELEASE(m_pColRowset); ReleaseRowsetObject(); if(m_pICmdPrepare) CHECK(m_pICmdPrepare->Unprepare(), S_OK); SAFE_RELEASE(m_pICmdPrepare); if (bReleaseEverything) ReleaseCommandObject(); } //-------------------------------------------------------------------- // @func Check a property value returned from IRowsetInfo::GetProperties // against the expected value. // // @rdesc Success or failure // @flag TEST_PASS | The value was as expected // @flag TEST_FAIL | The value was not correct //-------------------------------------------------------------------- BOOL CRowsetInfoSupport::CheckPropertyValue(const DBEXPECTEDPROPERTY *pExpectedEntry,const DBPROP *pActualEntry) { // Compare the dwOptions if((pExpectedEntry->bCheckValue) && !COMPARE(pExpectedEntry->dwOptions, pActualEntry->dwOptions)) return FALSE; // Compare the colid's if(!CompareDBID(pExpectedEntry->colid, pActualEntry->colid)) { odtLog <szPropertyName <bCheckValue) { if (!CompareVariant((VARIANT *) &pActualEntry->vValue, (VARIANT *) &pExpectedEntry->vValue)) { odtLog << L"** FAILURE **: Incorrect value for " <szPropertyName < 1) || (rgReturnedProperties[0].cProperties > 0)) { // error - extra properties returned odtLog << L"** TEST FAILURE **: List contains " << cNumReturnedProperties << L" prohibited additional entries." <rgProperties[uIndex]; if (pProperty->dwStatus != DBPROPSTATUS_OK) { if (pProperty->dwStatus == DBPROPSTATUS_NOTSUPPORTED || pProperty->dwStatus == DBPROPSTATUS_NOTSETTABLE ) { cNumNotSupported++; } else { cNumErrors++; } } swprintf(szTmpBuf, L" ...#%u: %-20s : %s\n", uIndex, rgProperties[uIndex].szPropertyName, g_szPropertyErrorStrings[pProperty->dwStatus]); odtLog << szTmpBuf; } } //-------------------------------------------------------------------- // @func Check the return value from GetReferencedRowset // // This function also frees the value. // // @rdesc TEST_PASS or TEST_FAIL //-------------------------------------------------------------------- BOOL CRowsetInfoSupport::CheckGetRRRetval(IUnknown *(&pRRRetval)) { BOOL fSuccess = FALSE; IUnknown *pIUnkActual = NULL; IUnknown *pIUnkExpect = NULL; // Get IUnknown pointers and compare them VerifyInterface(pRRRetval,IID_IUnknown,ROWSET_INTERFACE,&pIUnkActual); VerifyInterface(m_pIAccessor,IID_IUnknown,ROWSET_INTERFACE,&pIUnkExpect); if(COMPARE(pIUnkActual, pIUnkExpect)) fSuccess = TRUE; SAFE_RELEASE(pIUnkExpect); SAFE_RELEASE(pIUnkActual); SAFE_RELEASE(pRRRetval); return fSuccess; } //-------------------------------------------------------------------- // @func Check the return value from GetSpecification // // This function also frees the value. // // @rdesc TEST_PASS or TEST_FAIL //-------------------------------------------------------------------- int CRowsetInfoSupport::CheckGetSpecRetval(IUnknown *(&pSpecRetval)) { BOOL fSuccess = FALSE; IUnknown *pIUnkActual = NULL; IUnknown *pIUnkExpect = NULL; // Check the pointer and return code if((!pSpecRetval) && (m_hr == S_FALSE)) { odtLog << L"The Provider did not return a object pointer" < E_INVALIDARG int Variation_1(); // @cmember 0-valid-NULL-valid ==> E_INVALIDARG int Variation_2(); // @cmember 0-valid-valid-NULL ==> E_INVALIDARG int Variation_3(); // @cmember 0-NULL-NULL-NULL ==> E_INVALIDARG int Variation_4(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetPropBoundary) #define THE_CLASS TCGetPropBoundary BEG_TEST_CASE(TCGetPropBoundary, CRowsetInfoSupport, L"Get Properties Boundary Tests") TEST_VARIATION(1, L"1-NULL-valid-valid ==> E_INVALIDARG") TEST_VARIATION(2, L"0-valid-NULL-valid ==> E_INVALIDARG") TEST_VARIATION(3, L"0-valid-valid-NULL ==> E_INVALIDARG") TEST_VARIATION(4, L"0-NULL-NULL-NULL ==> E_INVALIDARG") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetPropParam) //-------------------------------------------------------------------- // @class GetProperties Parameter tests // class TCGetPropParam : public CRowsetInfoSupport { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetPropParam,CRowsetInfoSupport); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember First Variation int Variation_1(); // @cmember Second Variation int Variation_2(); // @cmember Third Variation int Variation_3(); // @cmember Fourth Variation int Variation_4(); // @cmember Fifth Variation int Variation_5(); // @cmember Sixth Variation int Variation_6(); // @cmember Seventh Variation int Variation_7(); // @cmember Eighth Variation int Variation_8(); // @cmember Ninth Variation int Variation_9(); // @cmember Tenth Variation int Variation_10(); // @cmember Eleventh Variation int Variation_11(); // @cmember Twelfth Variation int Variation_12(); // @cmember Thirteen Variation int Variation_13(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetPropParam) #define THE_CLASS TCGetPropParam BEG_TEST_CASE(TCGetPropParam, CRowsetInfoSupport, L"GetProperties Parameter tests") TEST_VARIATION(1, L"First Variation") TEST_VARIATION(2, L"Second Variation") TEST_VARIATION(3, L"Third Variation") TEST_VARIATION(4, L"Fourth Variation") TEST_VARIATION(5, L"Fifth Variation") TEST_VARIATION(6, L"Sixth Variation") TEST_VARIATION(7, L"Seventh Variation") TEST_VARIATION(8, L"Eighth Variation") TEST_VARIATION(9, L"Ninth Variation") TEST_VARIATION(10, L"Tenth Variation") TEST_VARIATION(11, L"Eleventh Variation") TEST_VARIATION(12, L"Twelfth Variation") TEST_VARIATION(13, L"Thirteen Variation") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetPropSequence) //-------------------------------------------------------------------- // @class GetProperties Sequence Tests // class TCGetPropSequence : public CRowsetInfoSupport { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); CSubRowset *m_pCRowset1; CSubRowset *m_pCRowset2; CSubRowset *m_pCRowset3; public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetPropSequence,CRowsetInfoSupport); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember First Variation int Variation_1(); // @cmember Second Variation int Variation_2(); // @cmember Third Variation int Variation_3(); // @cmember Fourth Variation int Variation_4(); // @cmember Fifth Variation int Variation_5(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetPropSequence) #define THE_CLASS TCGetPropSequence BEG_TEST_CASE(TCGetPropSequence, CRowsetInfoSupport, L"GetProperties Sequence Tests") TEST_VARIATION(1, L"First Variation") TEST_VARIATION(2, L"Second Variation") TEST_VARIATION(3, L"Third Variation") TEST_VARIATION(4, L"Fourth Variation") TEST_VARIATION(5, L"Fifth Variation") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetRefRowsetBoundary) //-------------------------------------------------------------------- // @class GetReferenceRowset Boundary Tests // class TCGetRefRowsetBoundary : public CRowsetInfoSupport { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); // @cmember List used to request bookmarks for variations which require them DBEXPECTEDPROPERTY *m_rgBookmarkProperties; public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetRefRowsetBoundary,CRowsetInfoSupport); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember Without a Bookmark int Variation_1(); // @cmember Without a Bookmark int Variation_2(); // @cmember Without a Bookmark int Variation_3(); // @cmember With a Bookmark int Variation_4(); // @cmember With a Bookmark int Variation_5(); // @cmember With a Bookmark int Variation_6(); // @cmember Get all madatory IID's int Variation_7(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetRefRowsetBoundary) #define THE_CLASS TCGetRefRowsetBoundary BEG_TEST_CASE(TCGetRefRowsetBoundary, CRowsetInfoSupport, L"GetReferenceRowset Boundary Tests") TEST_VARIATION(1, L"Without a Bookmark") TEST_VARIATION(2, L"Without a Bookmark") TEST_VARIATION(3, L"Without a Bookmark") TEST_VARIATION(4, L"With a Bookmark") TEST_VARIATION(5, L"With a Bookmark") TEST_VARIATION(6, L"With a Bookmark") TEST_VARIATION(7, L"Get all madatory IID's") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetRefRowsetProp) //-------------------------------------------------------------------- // @class GetReferencedRowset Param Tests: Properties // class TCGetRefRowsetProp : public CGetRefRSParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetRefRowsetProp,CGetRefRSParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember Entire Test Table int Variation_1(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetRefRowsetProp) #define THE_CLASS TCGetRefRowsetProp BEG_TEST_CASE(TCGetRefRowsetProp, CGetRefRSParameters, L"GetReferencedRowset Param Tests: Properties") TEST_VARIATION(1, L"Entire Test Table") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetRefRowsetICol) //-------------------------------------------------------------------- // @class GetReferencedRowset Param Tests: iOrdinal // class TCGetRefRowsetICol : public CGetRefRSParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetRefRowsetICol,CGetRefRSParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember iOrdinal=# of columns in the Rowset int Variation_1(); // @cmember iOrdinal=# of columns in the rowset + 1 int Variation_2(); // @cmember iOrdinal=ULONG_MAX int Variation_3(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetRefRowsetICol) #define THE_CLASS TCGetRefRowsetICol BEG_TEST_CASE(TCGetRefRowsetICol, CGetRefRSParameters, L"GetReferencedRowset Param Tests: iOrdinal") TEST_VARIATION(1, L"iOrdinal=# of columns in the Rowset") TEST_VARIATION(2, L"iOrdinal=# of columns in the rowset + 1") TEST_VARIATION(3, L"iOrdinal=ULONG_MAX") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetRefRowsetNoBmk) //-------------------------------------------------------------------- // @class GetReferencedRowset Parameter Tests: No Bookmarks // class TCGetRefRowsetNoBmk : public CGetRefRSParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetRefRowsetNoBmk,CGetRefRSParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember By ICommand::Execute int Variation_1(); // @cmember By IOpenRowset::OpenRowset int Variation_2(); // @cmember By IDBSchemaRowset::GetRowset int Variation_3(); // @cmember By IDBEnumerateSources::Sources int Variation_4(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetRefRowsetNoBmk) #define THE_CLASS TCGetRefRowsetNoBmk BEG_TEST_CASE(TCGetRefRowsetNoBmk, CGetRefRSParameters, L"GetReferencedRowset Parameter Tests: No Bookmarks") TEST_VARIATION(1, L"By ICommand::Execute") TEST_VARIATION(2, L"By IOpenRowset::OpenRowset") TEST_VARIATION(3, L"By IDBSchemaRowset::GetRowset") TEST_VARIATION(4, L"By IDBEnumerateSources::Sources") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetSpecBoundary) //-------------------------------------------------------------------- // @class GetSpecification Boundary Tests // class TCGetSpecBoundary : public CRowsetInfoSupport { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetSpecBoundary,CRowsetInfoSupport); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember IID_IUnknown int Variation_1(); // @cmember IID_IRowsetInfo int Variation_2(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetSpecBoundary) #define THE_CLASS TCGetSpecBoundary BEG_TEST_CASE(TCGetSpecBoundary, CRowsetInfoSupport, L"GetSpecification Boundary Tests") TEST_VARIATION(1, L"IID_IUnknown") TEST_VARIATION(2, L"IID_IRowsetInfo") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetSpecParamByExecute) //-------------------------------------------------------------------- // @class GetSpecification Parameters: Rowset created by lCommand::Execute // class TCGetSpecParamByExecute : public CGetSpecParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetSpecParamByExecute,CGetSpecParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember IID_IRowsetInfo int Variation_1(); // @cmember IID_IDBCreateCommand int Variation_2(); // @cmember IID_IUnknown int Variation_3(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetSpecParamByExecute) #define THE_CLASS TCGetSpecParamByExecute BEG_TEST_CASE(TCGetSpecParamByExecute, CGetSpecParameters, L"GetSpecification Parameters: Rowset created by lCommand::Execute") TEST_VARIATION(1, L"IID_IRowsetInfo") TEST_VARIATION(2, L"IID_IDBCreateCommand") TEST_VARIATION(3, L"IID_IUnknown") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetSpecParamByOpenRowset) //-------------------------------------------------------------------- // @class GetSpecification Parameters: Rowset created by OpenRowset // class TCGetSpecParamByOpenRowset : public CGetSpecParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetSpecParamByOpenRowset,CGetSpecParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember IID_IRowsetInfo int Variation_1(); // @cmember IID_ICommand int Variation_2(); // @cmember IID_IUnknown int Variation_3(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetSpecParamByOpenRowset) #define THE_CLASS TCGetSpecParamByOpenRowset BEG_TEST_CASE(TCGetSpecParamByOpenRowset, CGetSpecParameters, L"GetSpecification Parameters: Rowset created by OpenRowset") TEST_VARIATION(1, L"IID_IRowsetInfo") TEST_VARIATION(2, L"IID_ICommand") TEST_VARIATION(3, L"IID_IUnknown") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetSpecParamBySchemaRowset) //-------------------------------------------------------------------- // @class GetSpecification Parameters: rowset created by GetRowset // class TCGetSpecParamBySchemaRowset : public CGetSpecParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetSpecParamBySchemaRowset,CGetSpecParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember IID_IUnknown int Variation_1(); // @cmember IID_IDBCreateCommand int Variation_2(); // @cmember IID_IDBSchemaRowset int Variation_3(); // @cmember IID_ICommand int Variation_4(); // @cmember IID_IRowsetInfo int Variation_5(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetSpecParamBySchemaRowset) #define THE_CLASS TCGetSpecParamBySchemaRowset BEG_TEST_CASE(TCGetSpecParamBySchemaRowset, CGetSpecParameters, L"GetSpecification Parameters: rowset created by GetRowset") TEST_VARIATION(1, L"IID_IUnknown") TEST_VARIATION(2, L"IID_IDBCreateCommand") TEST_VARIATION(3, L"IID_IDBSchemaRowset") TEST_VARIATION(4, L"IID_ICommand") TEST_VARIATION(5, L"IID_IRowsetInfo") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetSpecParamBySources) //-------------------------------------------------------------------- // @class GetSpecification Parameters: Rowset created by Sources // class TCGetSpecParamBySources : public CGetSpecParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetSpecParamBySources,CGetSpecParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember IID_IUnknown int Variation_1(); // @cmember IID_IDBProperties int Variation_2(); // @cmember IID_IDBInitialize int Variation_3(); // @cmember IID_IDBEnumerateSources int Variation_4(); // @cmember IID_ICommand int Variation_5(); // @cmember IID_IRowsetInfo int Variation_6(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetSpecParamBySources) #define THE_CLASS TCGetSpecParamBySources BEG_TEST_CASE(TCGetSpecParamBySources, CGetSpecParameters, L"GetSpecification Parameters: Rowset created by Sources") TEST_VARIATION(1, L"IID_IUnknown") TEST_VARIATION(2, L"IID_IDBProperties") TEST_VARIATION(3, L"IID_IDBInitialize") TEST_VARIATION(4, L"IID_IDBEnumerateSources") TEST_VARIATION(5, L"IID_ICommand") TEST_VARIATION(6, L"IID_IRowsetInfo") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCGetSpecParamByColRowset) //-------------------------------------------------------------------- // @class GetSpecification Parameters: Rowset created by IColumnsRowset::GetColumnsRowset // class TCGetSpecParamByColRowset : public CGetSpecParameters { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCGetSpecParamByColRowset,CGetSpecParameters); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember IID_IUnknown int Variation_1(); // @cmember IID_IDBProperties int Variation_2(); // @cmember IID_IDBInitialize int Variation_3(); // @cmember IID_IDBEnumerateSources int Variation_4(); // @cmember IID_ICommand int Variation_5(); // @cmember IID_IRowsetInfo int Variation_6(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCGetSpecParamByColRowset) #define THE_CLASS TCGetSpecParamByColRowset BEG_TEST_CASE(TCGetSpecParamByColRowset, CGetSpecParameters, L"GetSpecification Parameters: Rowset created by IColumnsRowset::GetColumnsRowset") TEST_VARIATION(1, L"IID_IUnknown") TEST_VARIATION(2, L"IID_IDBProperties") TEST_VARIATION(3, L"IID_IDBInitialize") TEST_VARIATION(4, L"IID_IDBEnumerateSources") TEST_VARIATION(5, L"IID_ICommand") TEST_VARIATION(6, L"IID_IRowsetInfo") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCZombieTests) //-------------------------------------------------------------------- // @class Zombie State Tests // class TCZombieTests : public CTransaction { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCZombieTests,CTransaction); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // @cmember Set up a zombie state int TestTxn(ETXN eTxn, BOOL fRetaining); // {{ TCW_TESTVARS() // @cmember S_OK - Abort IRowsetInfo with fRetaining=FALSE int Variation_1(); // @cmember S_OK - Abort IRowsetInfo with fRetaining=TRUE int Variation_2(); // @cmember S_OK - Commit IRowsetInfo with fRetaining=FALSE int Variation_3(); // @cmember S_OK - Commit IRowsetInfo with fRetaining=TRUE int Variation_4(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCZombieTests) #define THE_CLASS TCZombieTests BEG_TEST_CASE(TCZombieTests, CTransaction, L"Zombie State Tests") TEST_VARIATION(1, L"S_OK - Abort IRowsetInfo with fRetaining=FALSE") TEST_VARIATION(2, L"S_OK - Abort IRowsetInfo with fRetaining=TRUE") TEST_VARIATION(3, L"S_OK - Commit IRowsetInfo with fRetaining=FALSE") TEST_VARIATION(4, L"S_OK - Commit IRowsetInfo with fRetaining=TRUE") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCMultiRowsets) //-------------------------------------------------------------------- // @class Multiple (Concurrent) Rowsets // class TCMultiRowsets : public CRowsetInfoSupport { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); public: struct { EQUERY m_fSourceQuery; DBCOUNTITEM m_cTblCols; LONG_PTR *m_rgTableColOrds; WCHAR *m_pszSQLStmt; IAccessor *m_pIAccessor; ICommand *m_pICommand; IRowset *m_pIRowset; IRowsetInfo *m_pIRowsetInfo; ICommandPrepare *m_pICmdPrepare; IUnknown *m_pICreator; } m_RowsetPtrs[MAX_MULTI_ROWSETS]; // @cmember: where to place the result IUnknown *m_pSpecification; // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCMultiRowsets,CRowsetInfoSupport); // }} TCW_DECLARE_FUNCS_END // @cmember Set up 1 or more rowsets BOOL SetupMultiRowsets(ULONG uNumRowsets, ...); // @cmember Sets one of the rowsets as current: // RowsetInfoSupport calls operate on the "current" rowset int SetCurrentRowset(ULONG uRowsetNum); // @cmember Clean up all rowsets BOOL CleanupMultiRowsets(void); ULONG m_uNumRowsets; // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember Multiple Rowsets, 2 Command Objects int Variation_1(); // @cmember Multiple Rowsets, 2 OpenRowset Objects int Variation_2(); // @cmember Multiple Rowsets, 1 Command, 1 OpenRowset Objects int Variation_3(); // @cmember Multiple Rowsets, 1 OpenRowset, 1 Command Objects int Variation_4(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCMultiRowsets) #define THE_CLASS TCMultiRowsets BEG_TEST_CASE(TCMultiRowsets, CRowsetInfoSupport, L"Multiple (Concurrent) Rowsets") TEST_VARIATION(1, L"Multiple Rowsets, 2 Command Objects") TEST_VARIATION(2, L"Multiple Rowsets, 2 OpenRowset Objects") TEST_VARIATION(3, L"Multiple Rowsets, 1 Command, 1 OpenRowset Objects") TEST_VARIATION(4, L"Multiple Rowsets, 1 OpenRowset, 1 Command Objects") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // {{ TCW_TEST_CASE_MAP(TCExtendedErrors) //-------------------------------------------------------------------- // @class Extended Errors // class TCExtendedErrors : public CRowsetInfoSupport { private: // @cmember Static array of variations DECLARE_TEST_CASE_DATA(); // @cmember List used to request bookmarks for variations which require them DBEXPECTEDPROPERTY *m_rgBookmarkProperties; // @cmember: a valid place to store the output property count ULONG m_cPropertySets; // @cmember: a valid place to return the output property list DBPROPSET * m_rgPropertySets; // @cmember: where to place the result IUnknown * m_pSpecification; public: // {{ TCW_DECLARE_FUNCS // @cmember Execution Routine DECLARE_TEST_CASE_FUNCS(TCExtendedErrors,CRowsetInfoSupport); // }} TCW_DECLARE_FUNCS_END // @cmember Initialization Routine virtual BOOL Init(); // @cmember Termination Routine virtual BOOL Terminate(); // {{ TCW_TESTVARS() // @cmember Valid IRowsetInfo calls with previous error object existing. int Variation_1(); // @cmember Valid IRowsetInfo calls with previous error object existing. int Variation_2(); // @cmember valid IRowsetInfo calls with previous error object existing int Variation_3(); // @cmember Invalid IRowsetInfo calls with previous error object existing int Variation_4(); // @cmember Invalid IRowsetInfo calls with previous error object existing int Variation_5(); // @cmember Invalid IRowsetInfo calls with previous error object existing int Variation_6(); // @cmember Invalid IRowsetInfo calls with no error object existing int Variation_7(); // @cmember Invalid IRowsetInfo calls with no previous error object existing int Variation_8(); // @cmember Invalid IRowsetInfo calls with no previous error object existing int Variation_9(); // }} TCW_TESTVARS_END }; // {{ TCW_TESTCASE(TCExtendedErrors) #define THE_CLASS TCExtendedErrors BEG_TEST_CASE(TCExtendedErrors, CRowsetInfoSupport, L"Extended Errors") TEST_VARIATION(1, L"Valid IRowsetInfo calls with previous error object existing.") TEST_VARIATION(2, L"Valid IRowsetInfo calls with previous error object existing.") TEST_VARIATION(3, L"valid IRowsetInfo calls with previous error object existing") TEST_VARIATION(4, L"Invalid IRowsetInfo calls with previous error object existing") TEST_VARIATION(5, L"Invalid IRowsetInfo calls with previous error object existing") TEST_VARIATION(6, L"Invalid IRowsetInfo calls with previous error object existing") TEST_VARIATION(7, L"Invalid IRowsetInfo calls with no error object existing") TEST_VARIATION(8, L"Invalid IRowsetInfo calls with no previous error object existing") TEST_VARIATION(9, L"Invalid IRowsetInfo calls with no previous error object existing") END_TEST_CASE() #undef THE_CLASS // }} TCW_TESTCASE_END // }} TCW_TEST_CASE_MAP_END // }} END_DECLARE_TEST_CASES() // {{ TCW_TESTMODULE(ThisModule) TEST_MODULE(17, ThisModule, gwszModuleDescrip) TEST_CASE(1, TCGeneral) TEST_CASE(2, TCGetPropBoundary) TEST_CASE(3, TCGetPropParam) TEST_CASE(4, TCGetPropSequence) TEST_CASE(5, TCGetRefRowsetBoundary) TEST_CASE(6, TCGetRefRowsetProp) TEST_CASE(7, TCGetRefRowsetICol) TEST_CASE(8, TCGetRefRowsetNoBmk) TEST_CASE(9, TCGetSpecBoundary) TEST_CASE(10, TCGetSpecParamByExecute) TEST_CASE(11, TCGetSpecParamByOpenRowset) TEST_CASE(12, TCGetSpecParamBySchemaRowset) TEST_CASE(13, TCGetSpecParamBySources) TEST_CASE(14, TCGetSpecParamByColRowset) TEST_CASE(15, TCZombieTests) TEST_CASE(16, TCMultiRowsets) TEST_CASE(17, TCExtendedErrors) END_TEST_MODULE() // }} TCW_TESTMODULE_END // {{ TCW_TC_PROTOTYPE(TCGeneral) //*----------------------------------------------------------------------- //| Test Case: TCGeneral - General (see table in test spec //| Created: 04/09/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE BOOL TCGeneral::Init() { // {{ TCW_INIT_BASECLASS_CHECK if(CRowsetInfoSupport::Init()) // }} { return TRUE; } return FALSE; } //-------------------------------------------------------------------- // @mfunc Test the GetProperties segment of each table entry specified // for the General Scenarios of this autotest. // // THE APPLICABLE ROWSET WILL HAVE ALREADY BEEN CREATED. This // routine calls GetProperties with the arguments specified in // the table entry, and checks that the returned properties are // as specified. // // @rdesc TEST_PASS or TEST_FAIL. // // This part is independent of the other parts of each table entry // test. If this part returns TEST_FAIL, the other parts are still // run. BOOL TCGeneral::TestPropertiesPart(GenTblEntry *pTableEntry) { HRESULT hr = E_FAIL; DBPROPID rgPropertiesIn[50]; ULONG cPropertiesOut; DBPROPSET *prgPropertiesOut; // Output the Title of the section odtLog << L"...GetProperties part" <m_cInquiredProperties) for (ULONG idx = 0; idx < pTableEntry->m_cInquiredProperties; idx++) rgPropertiesIn[idx] = pTableEntry->m_prgInquiredProperties[idx].dwPropertyID; // This is the fated test call to GetProperties... hr=GetProperties(pTableEntry->m_cInquiredProperties, rgPropertiesIn, &cPropertiesOut, &prgPropertiesOut); // GetProperties can return DB_S/DB_E_ if notsupported properties if (FAILED(hr) && (hr != DB_E_ERRORSOCCURRED)) return FALSE; // GetProperties should return the same number of properties if ((pTableEntry->m_cInquiredProperties) && (pTableEntry->m_cInquiredProperties != prgPropertiesOut->cProperties)) return FALSE; // It is built in to the check routine to dispose of the // results once they have been checked. if (!ComparePropertyLists( prgPropertiesOut, cPropertiesOut, pTableEntry->m_prgReturnedProperties, pTableEntry->m_cReturnedProperties, NULL, 0, COMPAREPROP_CHECKVALUES | COMPAREPROP_LOGCHECKS)) return FALSE; return TRUE; } //-------------------------------------------------------------------- // @mfunc Test the GetReferencedRowset segment of each table entry // specified for the General Scenarios of this autotest. // // THE APPLICABLE ROWSET WILL HAVE ALREADY BEEN CREATED. This // routine calls GetReferencedRowset with the arguments specified // in the table entry, and checks that the returned properties are // as specified. // // @rdesc TEST_PASS or TEST_FAIL. // // This part is independent of the other parts of each table entry // test. If this part returns TEST_FAIL, the other parts are still // run. BOOL TCGeneral::TestRefRowsetPart(GenTblEntry *pTableEntry) { // Output the Title of the section odtLog << L"...GetReferencedRowset part" <m_idRequestedID == DBPROP_IRowsetLocate) && (SupportedProperty(DBPROP_IRowsetLocate,DBPROPSET_ROWSET,m_pIDBInitialize)))) && (pTableEntry->m_hrGetReferencedRowset == DB_E_BADORDINAL) ) pTableEntry->m_hrGetReferencedRowset = S_OK; // Figure out the return code for commands if( (m_pICommand) && (((!GetProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pICommand)) && (!GetProperty(DBPROP_IRowsetLocate, DBPROPSET_ROWSET, m_pICommand))) && ((pTableEntry->m_idRequestedID != DBPROP_IRowsetLocate) || (!SupportedProperty(DBPROP_IRowsetLocate,DBPROPSET_ROWSET,m_pIDBInitialize)))) && (pTableEntry->m_hrGetReferencedRowset == S_OK) ) pTableEntry->m_hrGetReferencedRowset = DB_E_BADORDINAL; if(!CHECK(GetReferencedRowset(pTableEntry->m_ulColumn, IID_IUnknown, &m_pReferencedRowset), pTableEntry->m_hrGetReferencedRowset)) { // Release Object if(m_pReferencedRowset != INVALID(IUnknown*)) SAFE_RELEASE(m_pReferencedRowset); return FALSE; } // Check the return value if( (GetProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIRowsetInfo) && (pTableEntry->m_hrGetReferencedRowset == S_OK) && (!CheckGetRRRetval(m_pReferencedRowset))) ) { // Release Object if(m_pReferencedRowset != INVALID(IUnknown*)) SAFE_RELEASE(m_pReferencedRowset); return FALSE; } return TRUE; } //-------------------------------------------------------------------- // @mfunc Test the GetSpecification segment of each table entry // specified for the General Scenarios of this autotest. // // THE APPLICABLE ROWSET WILL HAVE ALREADY BEEN CREATED. This // routine calls GetSpecification with the arguments specified in // the table entry, and checks that the returned properties are // as specified. // // @rdesc TEST_PASS or TEST_FAIL. // // This part is independent of the other parts of each table entry // test. If this part returns TEST_FAIL, the other parts are still // run. BOOL TCGeneral::TestSpecificationPart(GenTblEntry *pTableEntry) { // Output the Title of the section odtLog << L"...GetSpecification part" <m_idCommandObjectID, &m_pSpecification), pTableEntry->m_hrGetSpecification)) return FALSE; if( (pTableEntry->m_hrGetSpecification == S_OK) && (!CheckGetSpecRetval(m_pSpecification)) ) return FALSE; return TRUE; } //-------------------------------------------------------------------- // @mfunc Run the series of tests for each table entry specified for // the general scenarios portion of this autotest. // // This function creates a rowset according to the parameters // specified in each table entry: a SELECT_* EQUERY is specified, // a set of properties which should be requested may be listed, // and a flag indicating whether the rowset is to be prepared // or not. // // It then calls subroutines to test each of the 3 functions // GetProperties, GetReferencedRowset, and GetSpecification. These // tests are independent and each one is run regardless of the success // of preceding runs... // // After each section is run, the rowset is released. // // @rdesc TEST_PASS or TEST_FAIL. // // If the rowset cannot be created, or if one or more of the three // test subparts fails, TEST_FAIL is returned. int TCGeneral::TestTableEntry(GenTblEntry *pTableEntry) { HRESULT hr = E_FAIL; BOOL fSuccess = FALSE; // Print a message identifying the current entry // This is because multiple table entries are tested // in the same variation. odtLog <m_pszSelectString <m_uLine <m_fSQLQuery != USE_OPENROWSET && pTableEntry->m_fSQLQuery != USE_GETCOLROWSET && pTableEntry->m_fSQLQuery != SELECT_DBSCHEMA_TABLE)) { odtLog <m_fSQLQuery, *pTableEntry->m_id, pTableEntry->m_cPresetProperties, pTableEntry->m_prgPresetProperties, pTableEntry->m_eCmdObjState); // This means required properties were not supported if (hr == DB_S_ERRORSOCCURRED) return TEST_PASS; if (!CHECK(hr, S_OK)) goto CLEANUP; // The three test parts: All 3 are run regardless of whether an earlier // one succeeded or failed. If one or more failed, remember because the // overall return code must be failure. if (!TestPropertiesPart(pTableEntry)) goto CLEANUP; if (!TestRefRowsetPart(pTableEntry)) goto CLEANUP; if (!TestSpecificationPart(pTableEntry)) goto CLEANUP; // Set the variation to TRUE fSuccess = TRUE; CLEANUP: // Release the rowset ReleaseRowsetObjectWithInfo(); odtLog < E_INVALIDARG // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropBoundary::Variation_1() { if(!CHECK(GetProperties(1,(DBPROPIDSET *)NULL, &m_cPropertySets,&m_rgPropertySets), E_INVALIDARG)) return TEST_FAIL; return TEST_PASS; } // }} // {{ TCW_VAR_PROTOTYPE(2) //-------------------------------------------------------------------- // @mfunc 0-valid-NULL-valid ==> E_INVALIDARG // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropBoundary::Variation_2() { // Initialize m_prgProperties = NULL; if(!CHECK(GetProperties(0,m_prgProperties, NULL,&m_rgPropertySets), E_INVALIDARG)) return TEST_FAIL; return TEST_PASS; } // }} // {{ TCW_VAR_PROTOTYPE(3) //-------------------------------------------------------------------- // @mfunc 0-valid-valid-NULL ==> E_INVALIDARG // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropBoundary::Variation_3() { // Initialize m_prgProperties = NULL; if(!CHECK(GetProperties(0,m_prgProperties, &m_cPropertySets,NULL), E_INVALIDARG)) return TEST_FAIL; return TEST_PASS; } // }} // {{ TCW_VAR_PROTOTYPE(4) //-------------------------------------------------------------------- // @mfunc 0-NULL-NULL-NULL ==> E_INVALIDARG // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropBoundary::Variation_4() { if(!CHECK(GetProperties(0,(DBPROPIDSET *)NULL,NULL,NULL),E_INVALIDARG)) return TEST_FAIL; return TEST_PASS; } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL TCGetPropBoundary::Terminate() { // Release the rowset object ReleaseRowsetObjectWithInfo(); // {{ TCW_TERM_BASECLASS_CHECK2 return(CRowsetInfoSupport::Terminate()); } // }} // }} // }} // {{ TCW_TC_PROTOTYPE(TCGetPropParam) //*----------------------------------------------------------------------- //| Test Case: TCGetPropParam - GetProperties Parameter tests //| Created: 04/09/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL TCGetPropParam::Init() { // {{ TCW_INIT_BASECLASS_CHECK if(CRowsetInfoSupport::Init()) // }} return TRUE; return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //-------------------------------------------------------------------- // @mfunc First Variation // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropParam::Variation_1() { ULONG uRsltPropCnt = 0; DBPROPSET *rgRsltProps = NULL; BOOL fSuccess = FALSE; DBEXPECTEDPROPERTY rgTestProps[6]; DBPROPID rgProperties[6]; // This variation requires that commands be supported. if(!GetCommandSupport()) return TEST_SKIPPED; // rgProperties contains a duplicated mandatory interface, duplicate not // settable property, and duplicate support interface. ADD_TRUE_PROP(&rgTestProps[0], DBPROP_IRowsetInfo); ADD_UNDEF_PROP(&rgTestProps[1], DBPROP_NOTSETTABLEPROPERTY); ADD_TRUE_PROP(&rgTestProps[2], DBPROP_IRowset); ADD_TRUE_PROP(&rgTestProps[3], DBPROP_IRowsetInfo); ADD_UNDEF_PROP(&rgTestProps[4], DBPROP_NOTSETTABLEPROPERTY); ADD_TRUE_PROP(&rgTestProps[5], DBPROP_IRowset); for(ULONG uIndex=0; uIndex<(sizeof(rgTestProps)/sizeof(rgTestProps[0])); uIndex++) rgProperties[uIndex] = rgTestProps[uIndex].dwPropertyID; // Get a rowset by ICommand::Execute if(!CHECK(CreateRowsetObjectWithInfo(SELECT_EMPTYROWSET, IID_IRowset),S_OK)) goto CLEANUP; // Cleanup is necessary following a failure from this point onward... if(!CHECK(GetProperties(6,rgProperties,&uRsltPropCnt,&rgRsltProps), S_OK)) goto CLEANUP; if(!ComparePropertyLists(rgRsltProps,uRsltPropCnt,rgTestProps,6,NULL,0, (COMPAREPROP_CHECKVALUES | COMPAREPROP_LOGCHECKS))) goto CLEANUP; fSuccess = TRUE; CLEANUP: // The property list was cleaned up by Compare. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(2) //-------------------------------------------------------------------- // @mfunc Second Variation // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropParam::Variation_2() { #ifdef ENUMSOURCES ULONG uRsltPropCnt = 0; DBPROPSET *rgRsltProps = NULL; BOOL fSuccess = FALSE; DBEXPECTEDPROPERTY rgTestProps[1]; DBPROPID rgProperties[1]; // Add properties to the list ADD_UNSUP_PROP(&rgTestProps[0], DBPROP_IRowsetChange); for(ULONG uIndex=0; uIndex<(sizeof(rgTestProps)/sizeof(rgTestProps[0])); uIndex++) rgProperties[uIndex] = rgTestProps[uIndex].dwPropertyID; // Get a rowset by IDBEnumerateSources::Sources if(!CHECK(CreateRowsetObjectWithInfo(USE_ENUMSOURCES, IID_IRowset),S_OK)) goto CLEANUP; // Cleanup is necessary following a failure from this point onward... if(!CHECK(GetProperties(1,rgProperties,&uRsltPropCnt,&rgRsltProps), S_OK)) goto CLEANUP; if(!ComparePropertyLists(rgRsltProps,uRsltPropCnt,rgTestProps,1,NULL,0, (COMPAREPROP_DISALLOWEXTRAS | COMPAREPROP_CHECKVALUES | COMPAREPROP_LOGCHECKS | COMPAREPROP_NODUPCHECK))) goto CLEANUP; fSuccess = TRUE; CLEANUP: // The property list was cleaned up by Compare. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; #else odtLog << L"EnumerateSources has been removed and will not be tested." <GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, g_rgMandatoryInterfaces, NUM_MANDATORY_PROPERTIES, NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, g_rgMandatoryInterfaces, NUM_MANDATORY_PROPERTIES, NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, g_rgMandatoryInterfaces, NUM_MANDATORY_PROPERTIES, NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; // Verify GetReferencedRowset returns the correct information if(!CHECK(m_pCRowset1->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset1->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetRRRetval(m_pCRowset1->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset2->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetRRRetval(m_pCRowset2->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset3->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetRRRetval(m_pCRowset3->m_pReferencedRowset)) bTestFailed = TRUE; // Verify GetSpecification returns the correct information if(FAILED(m_pCRowset1->m_hr=m_pCRowset1->GetSpecification(IID_IUnknown, &m_pCRowset1->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetSpecRetval(m_pCRowset1->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset2->m_hr=m_pCRowset2->GetSpecification(IID_IUnknown, &m_pCRowset2->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetSpecRetval(m_pCRowset2->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset3->m_hr=m_pCRowset3->GetSpecification(IID_IUnknown, &m_pCRowset3->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetSpecRetval(m_pCRowset3->m_pSpecification)) bTestFailed = TRUE; } ReleaseRowset(m_pCRowset1); ReleaseRowset(m_pCRowset2); ReleaseRowset(m_pCRowset3); if(bTestFailed) return TEST_FAIL; else return TEST_PASS; #else odtLog << L"EnumerateSources has been removed and will not be tested." <GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsOutExpect1, (sizeof(rgPropsIn1)/sizeof(rgPropsIn1[0])), NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsOutExpect2, (sizeof(rgPropsIn2)/sizeof(rgPropsIn2[0])), NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsOutExpect3, (sizeof(rgPropsIn3)/sizeof(rgPropsIn3[0])), NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; // Verify GetReferencedRowset returns the correct information if(!CHECK(m_pCRowset1->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset1->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetRRRetval(m_pCRowset1->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset2->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetRRRetval(m_pCRowset2->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset3->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetRRRetval(m_pCRowset3->m_pReferencedRowset)) bTestFailed = TRUE; // Verify GetSpecification returns the correct information if(FAILED(m_pCRowset1->m_hr=m_pCRowset1->GetSpecification(IID_IUnknown, &m_pCRowset1->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetSpecRetval(m_pCRowset1->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset2->m_hr=m_pCRowset2->GetSpecification(IID_IUnknown, &m_pCRowset2->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetSpecRetval(m_pCRowset2->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset3->m_hr=m_pCRowset3->GetSpecification(IID_IUnknown, &m_pCRowset3->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetSpecRetval(m_pCRowset3->m_pSpecification)) bTestFailed = TRUE; } ReleaseRowset(m_pCRowset1); ReleaseRowset(m_pCRowset2); ReleaseRowset(m_pCRowset3); if(bTestFailed) return TEST_FAIL; else return TEST_PASS; } // }} // {{ TCW_VAR_PROTOTYPE(3) //-------------------------------------------------------------------- // @mfunc Third Variation // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropSequence::Variation_3() { HRESULT hr1 = E_FAIL; HRESULT hr2 = E_FAIL; HRESULT hr3 = E_FAIL; BOOL bTestFailed = FALSE; ULONG cOutProps = 0; DBPROPSET *rgOutProps = NULL; ULONG cPropsIn = 1; DBEXPECTEDPROPERTY rgPropsIn[1]; // This variation requires that schemas are supported if (!g_fSchemaRowSupported) { odtLog << L"Variation skipped: SchemaRowsets not supported ." <GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsIn, (sizeof(rgPropsIn)/sizeof(rgPropsIn[0])), NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsIn, (sizeof(rgPropsIn)/sizeof(rgPropsIn[0])), NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsIn, (sizeof(rgPropsIn)/sizeof(rgPropsIn[0])), NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; // Verify GetReferencedRowset returns the correct information if(!CHECK(m_pCRowset1->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset1->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetRRRetval(m_pCRowset1->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset2->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetRRRetval(m_pCRowset2->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset3->m_pReferencedRowset), S_OK)) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetRRRetval(m_pCRowset3->m_pReferencedRowset)) bTestFailed = TRUE; // Verify GetSpecification returns the correct information // Some Prroviders don't know the object that created the rowset if(FAILED(m_pCRowset1->m_hr=m_pCRowset1->GetSpecification(IID_IUnknown, &m_pCRowset1->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetSpecRetval(m_pCRowset1->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset2->m_hr=m_pCRowset2->GetSpecification(IID_IUnknown, &m_pCRowset2->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetSpecRetval(m_pCRowset2->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset3->m_hr=m_pCRowset3->GetSpecification(IID_IUnknown, &m_pCRowset3->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetSpecRetval(m_pCRowset3->m_pSpecification)) bTestFailed = TRUE; } ReleaseRowset(m_pCRowset1); ReleaseRowset(m_pCRowset2); ReleaseRowset(m_pCRowset3); if(bTestFailed) return TEST_FAIL; else return TEST_PASS; } // }} // {{ TCW_VAR_PROTOTYPE(4) //-------------------------------------------------------------------- // @mfunc Fourth Variation // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropSequence::Variation_4() { HRESULT hr1 = E_FAIL; HRESULT hr2 = E_FAIL; BOOL bTestFailed = FALSE; // This variation requires that schemas are supported if (!g_fSchemaRowSupported) { odtLog << L"Variation skipped: SchemaRowsets not supported ." <m_hr=m_pCRowset1->GetSpecification(IID_IUnknown, &m_pCRowset1->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetSpecRetval(m_pCRowset1->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset2->m_hr=m_pCRowset2->GetSpecification(IID_IUnknown, &m_pCRowset2->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetSpecRetval(m_pCRowset2->m_pSpecification)) bTestFailed = TRUE; } ReleaseRowset(m_pCRowset1); ReleaseRowset(m_pCRowset2); if(bTestFailed) return TEST_FAIL; else return TEST_PASS; } // }} // {{ TCW_VAR_PROTOTYPE(5) //-------------------------------------------------------------------- // @mfunc Fifth Variation // // @rdesc TEST_PASS or TEST_FAIL // int TCGetPropSequence::Variation_5() { HRESULT hr1 = E_FAIL; HRESULT hr2 = E_FAIL; HRESULT hr3 = E_FAIL; BOOL bTestFailed = FALSE; ULONG cOutProps = 0; DBPROPSET *rgOutProps = NULL; ULONG cPropsIn = 0; DBEXPECTEDPROPERTY rgPropsIn[1]; // This variation requires that commands be supported. if (!GetCommandSupport()) { odtLog << L"Variation skipped: Commands not supported ." <GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsIn, cPropsIn, NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsIn, cPropsIn, NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetProperties(0, (DBPROPIDSET *)NULL, &cOutProps, &rgOutProps), S_OK)) bTestFailed = TRUE; else if(!ComparePropertyLists(rgOutProps, cOutProps, rgPropsIn, cPropsIn, NULL, 0, (COMPAREPROP_CHECKVALUES))) bTestFailed = TRUE; // Verify GetReferencedRowset returns the correct information if(!CHECK(m_pCRowset1->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset1->m_pReferencedRowset), cPropsIn ? S_OK : DB_E_BADORDINAL)) bTestFailed = TRUE; if(cPropsIn && !m_pCRowset1->CheckGetRRRetval(m_pCRowset1->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset2->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset2->m_pReferencedRowset), cPropsIn ? S_OK : DB_E_BADORDINAL)) bTestFailed = TRUE; if(cPropsIn && !m_pCRowset2->CheckGetRRRetval(m_pCRowset2->m_pReferencedRowset)) bTestFailed = TRUE; if(!CHECK(m_pCRowset3->GetReferencedRowset(0,IID_IUnknown, &m_pCRowset3->m_pReferencedRowset), cPropsIn ? S_OK : DB_E_BADORDINAL)) bTestFailed = TRUE; if(cPropsIn && !m_pCRowset3->CheckGetRRRetval(m_pCRowset3->m_pReferencedRowset)) bTestFailed = TRUE; // Verify GetSpecification returns the correct information if(FAILED(m_pCRowset1->m_hr=m_pCRowset1->GetSpecification(IID_IUnknown, &m_pCRowset1->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset1->CheckGetSpecRetval(m_pCRowset1->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset2->m_hr=m_pCRowset2->GetSpecification(IID_IUnknown, &m_pCRowset2->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset2->CheckGetSpecRetval(m_pCRowset2->m_pSpecification)) bTestFailed = TRUE; if(FAILED(m_pCRowset3->m_hr=m_pCRowset3->GetSpecification(IID_IUnknown, &m_pCRowset3->m_pSpecification))) bTestFailed = TRUE; else if(!m_pCRowset3->CheckGetSpecRetval(m_pCRowset3->m_pSpecification)) bTestFailed = TRUE; } ReleaseRowset(m_pCRowset1); ReleaseRowset(m_pCRowset2); ReleaseRowset(m_pCRowset3); if(bTestFailed) return TEST_FAIL; else return TEST_PASS; } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL TCGetPropSequence::Terminate() { // {{ TCW_TERM_BASECLASS_CHECK2 return(CRowsetInfoSupport::Terminate()); } // }} // }} // }} // {{ TCW_TC_PROTOTYPE(TCGetRefRowsetBoundary) //*----------------------------------------------------------------------- //| Test Case: TCGetRefRowsetBoundary - GetReferenceRowset Boundary Tests //| Created: 04/09/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL TCGetRefRowsetBoundary::Init() { // Allocate a property list of length 1 so we can request bookmarks // for those variations which want them. m_rgBookmarkProperties = NULL; m_rgBookmarkProperties = (DBEXPECTEDPROPERTY *)PROVIDER_ALLOC(sizeof(DBEXPECTEDPROPERTY)); // {{ TCW_INIT_BASECLASS_CHECK if(CRowsetInfoSupport::Init()) // }} { return TRUE; } return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //-------------------------------------------------------------------- // @mfunc Without a Bookmark // // @rdesc TEST_PASS or TEST_FAIL // int TCGetRefRowsetBoundary::Variation_1() { BOOL fSuccess = FALSE; IUnknown *pReferencedRowset = INVALID(IUnknown*); // This variation requires bookmarks are turned off. if((!g_fBookmarksSettable) && (g_fBookmarksOnByDft)) { odtLog << L"Variation skipped: Bookmarks are always enabled ." <." <." <." <." <." <." < %s [line %lu]\n", uTestCaseIndex, pThisTestCase->m_szTestPropertyString, pThisTestCase->m_szColumnString, pThisTestCase->m_szExpectedResultString, pThisTestCase->m_uLine); odtLog << szTmpBuf; // Create a rowset with any arbitrary method. // Set the test property. // SetupBooleanProperty(&rgTestProperty[0], pThisTestCase->m_idTestProperty, VARIANT_TRUE, pThisTestCase->m_szTestPropertyString, pThisTestCase->m_uLine); hr = CreateRowsetObjectWithInfo(fQueryToUse, IID_IRowset, 1, rgTestProperty); if (hr == DB_E_ERRORSOCCURRED) { // this means required properties were not supported uSkip++; continue; } if (CHECK(hr, S_OK)) { // This variation requires that we successfully received the // columns count. if (!m_cRowsetColumns) odtLog << L"Couldn't get column count" <m_iOrdinal) { case MIDDLE: iOrdinal = (m_cRowsetColumns+1) / 2; if (iOrdinal < 1) iOrdinal = 1; break; case LAST_MINUS_1: iOrdinal = m_cRowsetColumns - 1; break; case LAST: iOrdinal = m_cRowsetColumns; break; case LAST_PLUS_1: iOrdinal = m_cRowsetColumns + 1; break; default: iOrdinal = pThisTestCase->m_iOrdinal; } // Here's the nitty-gritty: Call the function and see that // it did what we wanted. // hr = GetReferencedRowset(iOrdinal, IID_IUnknown, &m_pReferencedRowset); //if BOOKMARKS are not supported, should return DB_E_BADORDINAL if(!g_fBookmarksSupported && iOrdinal==0) { if(CHECK(hr,DB_E_BADORDINAL) && COMPARE(m_pReferencedRowset, NULL)) bThisTestPassed = TRUE; } else if(g_fBookmarksSupported && iOrdinal==0) { // Check if bookmarks are supported on this rowset. VARIANT_BOOL bValue; if (GetProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, this->m_pIRowsetInfo, &bValue)) { if (bValue == VARIANT_TRUE) { if(CHECK(hr,S_OK) && CheckGetRRRetval(m_pReferencedRowset)) bThisTestPassed = TRUE; } else { if (CHECK(hr, DB_E_BADORDINAL)) bThisTestPassed = TRUE; } } else { if (CHECK(hr, DB_E_BADORDINAL)) bThisTestPassed = TRUE; } } else if(iOrdinal > m_cRowsetColumns) { if(CHECK(hr,DB_E_BADORDINAL) && COMPARE(m_pReferencedRowset, NULL)) bThisTestPassed = TRUE; } else if(CHECK(hr,pThisTestCase->m_hrExpectedResult)) { // Check returned referenced rowset against anything? if (g_fBookmarksSupported && pThisTestCase->m_hrExpectedResult == S_OK) { if (CheckGetRRRetval(m_pReferencedRowset)) bThisTestPassed = TRUE; } else { // Correct error returned: test passed if(FAILED(hr) && COMPARE(m_pReferencedRowset, NULL)) bThisTestPassed = TRUE; } } else assert(0); } ReleaseRowsetObjectWithInfo(); if (!bThisTestPassed) { odtLog << L"" <." <." <." <." <." <GetRowsOnCTable(); m_RowsetPtrs[uIndex].m_rgTableColOrds = m_rgTableColOrds; m_RowsetPtrs[uIndex].m_pszSQLStmt = m_pszSQLStatement; m_RowsetPtrs[uIndex].m_pICommand = m_pICommand; m_RowsetPtrs[uIndex].m_pIAccessor = m_pIAccessor; m_RowsetPtrs[uIndex].m_pIRowsetInfo = m_pIRowsetInfo; m_RowsetPtrs[uIndex].m_pICmdPrepare = m_pICmdPrepare; m_RowsetPtrs[uIndex].m_pICreator = m_pICreator; // Cleared, in case the creation of the next rowset makes // CreateRowsetObject cleanup any leftover pointers. m_rgTableColOrds = NULL; m_pszSQLStatement = NULL; m_pICommand = NULL; m_pIAccessor = NULL; m_pIRowsetInfo = NULL; m_pICmdPrepare = NULL; m_pICreator = NULL; } va_end(ap); // didn't make all the rowsets: something went wrong in the // loop. Free the rowsets and exit. if (uIndex < uNumRowsets) { m_uNumRowsets = uIndex; CleanupMultiRowsets(); return FALSE; } else { m_uNumRowsets = uNumRowsets; return TRUE; } } //-------------------------------------------------------------------- // @mfunc Set a given rowset (from the set created by SetupMultiRowsets // as the "current" rowset. The current rowset is the one to which // the CRowsetInfoSupport, CRowset, CCommand, and other methods will // be applied. // // uRowsetNum is a 1-based indication of which rowset to used. // // @rdesc TRUE or FALSE // BOOL TCMultiRowsets::SetCurrentRowset(ULONG uRowsetNum) { // the row numbers are 1-based, the array 0-based --uRowsetNum; // fQuery = m_RowsetPtrs[uRowsetNum].m_fSourceQuery; m_rgTableColOrds = m_RowsetPtrs[uRowsetNum].m_rgTableColOrds; m_pszSQLStatement = m_RowsetPtrs[uRowsetNum].m_pszSQLStmt; m_pICommand = m_RowsetPtrs[uRowsetNum].m_pICommand; m_pIAccessor = m_RowsetPtrs[uRowsetNum].m_pIAccessor; m_pIRowsetInfo = m_RowsetPtrs[uRowsetNum].m_pIRowsetInfo; m_pICmdPrepare = m_RowsetPtrs[uRowsetNum].m_pICmdPrepare; m_pICreator = m_RowsetPtrs[uRowsetNum].m_pICreator; return TRUE; } //-------------------------------------------------------------------- // @mfunc Release the set of rowsets created for this test // // @rdesc TRUE or FALSE // BOOL TCMultiRowsets::CleanupMultiRowsets(void) { for(ULONG uIndex = 1; uIndex <= m_uNumRowsets; uIndex++) { SetCurrentRowset(uIndex); ReleaseRowsetObjectWithInfo(); } // Reset to zero m_uNumRowsets=0; return TRUE; } //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL TCMultiRowsets::Init() { m_uNumRowsets = 0; // {{ TCW_INIT_BASECLASS_CHECK if(CRowsetInfoSupport::Init()) // }} { return TRUE; } return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc Multiple Rowsets, 2 Command Objects // // @rdesc TEST_PASS or TEST_FAIL // int TCMultiRowsets::Variation_1() { BOOL fSuccess = FALSE; ULONG_PTR ulValue = 0; // Figure out how many sessions are valid GetProperty(DBPROP_ACTIVESESSIONS, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulValue); if(ulValue == 1) { odtLog << L"Variation skipped: Max open sessions is one." <." <." <." <CauseError(); // Call GetProperties if(CHECK(hr=m_pIRowsetInfo->GetProperties(0, NULL, &m_cPropertySets, &m_rgPropertySets), S_OK)) fSuccess = TRUE; if(!m_cPropertySets || !m_rgPropertySets) fSuccess &= FALSE; // Do extended check following IsSameRow fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); // Release the rowset. ReleaseRowsetObjectWithInfo(); // Free memory from GetProperties FreeProperties(&m_cPropertySets, &m_rgPropertySets); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(2) //-------------------------------------------------------------------- // @mfunc Valid IRowsetInfo calls with previous error object existing. // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_2() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; IUnknown *ppReferencedRowset = NULL; // This variation requires bookmarks be supported. if((!g_fBookmarksSettable) && (!g_fBookmarksOnByDft)) { odtLog << L"Variation skipped: Bookmarks not supported ." <CauseError(); if(CHECK(hr=m_pIRowsetInfo->GetReferencedRowset(0,IID_IUnknown,&ppReferencedRowset), (g_fBookmarksSupported) ? S_OK : DB_E_BADORDINAL)) fSuccess = TRUE; // Do extended check following IsSameRow fSuccess = XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); CLEANUP: // Release all of the Interfaces SAFE_RELEASE(ppReferencedRowset); PROVIDER_FREE(m_rgBookmarkProperties); // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc valid IRowsetInfo calls with previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_3() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr=CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; // Cause an Error m_pExtError->CauseError(); // Call GetSpecification if(SUCCEEDED(hr=m_pIRowsetInfo->GetSpecification(IID_IUnknown, &m_pSpecification))) fSuccess = TRUE; if(!m_pSpecification) fSuccess &= FALSE; // Do extended error check fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); // Release all of the Interfaces SAFE_RELEASE(m_pSpecification); // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //}} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc Invalid IRowsetInfo calls with previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_4() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr=CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; // Cause an Error m_pExtError->CauseError(); // Call GetProperties if(CHECK(hr=m_pIRowsetInfo->GetProperties(1, NULL, &m_cPropertySets, &m_rgPropertySets), E_INVALIDARG)) fSuccess = TRUE; if(m_cPropertySets || m_rgPropertySets) fSuccess &= FALSE; // Do extended check following IsSameRow fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //}} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc Invalid IRowsetInfo calls with previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_5() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr = CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; // Cause an Error m_pExtError->CauseError(); if(CHECK(hr=m_pIRowsetInfo->GetReferencedRowset(1, IID_IUnknown, NULL), E_INVALIDARG)) fSuccess = TRUE; // Do extended check following IsSameRow fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc Invalid IRowsetInfo calls with previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_6() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr = CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; // Cause an Error m_pExtError->CauseError(); if(CHECK(hr=m_pIRowsetInfo->GetSpecification(IID_IRowsetInfo, &m_pSpecification), E_NOINTERFACE)) fSuccess = TRUE; // Do extended error check fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); if(m_pSpecification) fSuccess &= FALSE; // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc Invalid IRowsetInfo calls with no error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_7() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr = CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; // Call GetProperties if(CHECK(hr=m_pIRowsetInfo->GetProperties(1, NULL, &m_cPropertySets, &m_rgPropertySets),E_INVALIDARG)) fSuccess = TRUE; // Do extended check following IsSameRow fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); if(m_cPropertySets || m_rgPropertySets) fSuccess &= FALSE; // Release all of the Interfaces ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //}} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc Invalid IRowsetInfo calls with no previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_8() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr = CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; if(CHECK(hr=m_pIRowsetInfo->GetReferencedRowset(1, IID_IUnknown, NULL), E_INVALIDARG)) fSuccess = TRUE; // Do extended check following IsSameRow fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(9) //*----------------------------------------------------------------------- // @mfunc Invalid IRowsetInfo calls with no previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int TCExtendedErrors::Variation_9() { BOOL fSuccess = FALSE; HRESULT hr = E_FAIL; // Create a rowset with any arbitrary method. if(!CHECK(hr = CreateRowsetObjectWithInfo(USE_OPENROWSET, IID_IRowset),S_OK)) return TEST_FAIL; if(CHECK(hr=m_pIRowsetInfo->GetSpecification(IID_IRowsetInfo, &m_pSpecification), E_NOINTERFACE)) fSuccess = TRUE; // Do extended error check fSuccess &= XCHECK(m_pIRowsetInfo, IID_IRowsetInfo, hr); if(m_pSpecification) fSuccess &= FALSE; // Release the rowset. ReleaseRowsetObjectWithInfo(); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL TCExtendedErrors::Terminate() { //ReleaseRowsetObjectWithInfo(); return(CRowsetInfoSupport::Terminate()); } // }} // }} //-------------------------------------------------------------------- // @mfunc Set up a zombie state // // @rdesc TRUE or FALSE // int TCZombieTests::TestTxn(ETXN eTxn, BOOL fRetaining) { int fPassFail = TEST_FAIL; // ReturnValue HRESULT ExpectedHr = E_UNEXPECTED; // Expected HRESULT DBCOUNTITEM cRowsObtained = 0; // Number of rows returned, should be 1 HROW *rghRows = NULL; // Array of Row Handles ULONG cPropertySets = 0; // Number of PropSets DBPROPSET *rgPropertySets = NULL; // Array of PropSets IRowsetInfo *pIRowsetInfo = NULL; // IRowsetInfo IUnknown *pSpecification = NULL; // Back Pointer IUnknown *pSpecification1 = NULL; // Back Pointer IUnknown *pReferencedRowset = NULL; // Rowset Pointer to the rowset // Retrieve an Interface pointer to IRowsetInfo within a Transaction if(!StartTransaction(SELECT_ALLFROMTBL, (IUnknown**)&pIRowsetInfo)) goto END; // Obtain the ABORT or COMMIT PRESERVE flag and adjust ExpectedHr if( ((eTxn == ETXN_COMMIT) && (m_fCommitPreserve)) || ((eTxn == ETXN_ABORT) && (m_fAbortPreserve)) ) ExpectedHr = S_OK; // Commit or Abort the transaction, with retention as specified if( ((eTxn == ETXN_COMMIT) && (!GetCommit(fRetaining))) || ((eTxn == ETXN_ABORT) && (!GetAbort(fRetaining))) ) goto END; // Test zombie if(!CHECK(m_pIRowset->GetNextRows(0,0,1,&cRowsObtained,&rghRows), ExpectedHr)) goto END; // IRowsetInfo::GetProperties if(!CHECK(pIRowsetInfo->GetProperties(0, NULL, &cPropertySets, &rgPropertySets),ExpectedHr)) goto END; // IRowsetInfo::GetSpecification (S_OK and S_FALSE valid) if( ((ExpectedHr == S_OK) && (FAILED(pIRowsetInfo->GetSpecification(IID_IUnknown, &pSpecification)))) || (!CHECK(pIRowsetInfo->GetSpecification(IID_IUnknown, &pSpecification1), ExpectedHr)) ) goto END; // IRowsetInfo::GetReferencedRowset if( (ExpectedHr == S_OK) && (!GetProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, pIRowsetInfo)) ) ExpectedHr = DB_E_BADORDINAL; if(CHECK(pIRowsetInfo->GetReferencedRowset(0, IID_IUnknown, &pReferencedRowset), ExpectedHr)) fPassFail = TEST_PASS; END: // Release the row handle on the 1st rowset CHECK(m_pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL), S_OK); PROVIDER_FREE(rghRows); // Release the Interfaces SAFE_RELEASE(pIRowsetInfo); SAFE_RELEASE(pReferencedRowset); SAFE_RELEASE(pSpecification); SAFE_RELEASE(pSpecification1); // Clear the Property memory FreeProperties(&cPropertySets, &rgPropertySets); // Cleanup Transactions CleanUpTransaction(fRetaining ? S_OK : XACT_E_NOTRANSACTION); return fPassFail; }