[fdo-commits] r788 - in
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest: . Common Odbc
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Thu Mar 8 16:24:38 EST 2007
Author: brentrobinson
Date: 2007-03-08 16:24:38 -0500 (Thu, 08 Mar 2007)
New Revision: 788
Added:
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/tm_802102.xml
Modified:
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.h
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoDatastoreTest.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.h
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.h
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.h
Log:
Added another XML test case.
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.cpp 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.cpp 2007-03-08 21:24:38 UTC (rev 788)
@@ -18,6 +18,7 @@
#include "Pch.h"
#include "ConnectionUtil.h"
+#include <FdoCommonFile.h>
#ifndef RDBI_DEF_SA_ORA
extern void ut_thread_mutex_init ();
@@ -275,29 +276,32 @@
}
}
+char *ConnectionUtil::CommandFilesDirectory;
+
ConnectionUtil::ConnectionUtil(void)
{
m_SetupDone = false;
+ CommandFilesDirectory = NULL;
}
ConnectionUtil::~ConnectionUtil(void)
{
-
+ if (NULL != CommandFilesDirectory)
+ delete[] CommandFilesDirectory;
}
-wchar_t *ConnectionUtil::GetConnectionString(StringConnTypeRequest pTypeReq, FdoString *suffix)
+wchar_t *ConnectionUtil::GetConnectionString(StringConnTypeRequest pTypeReq, FdoString *suffix, bool bAddExtraneousSpaces)
{
FdoStringP service = UnitTestUtil::GetEnviron("service");
FdoStringP username = UnitTestUtil::GetEnviron("username");
FdoStringP password = UnitTestUtil::GetEnviron("password");
FdoStringP datastore = UnitTestUtil::GetEnviron("datastore", suffix);
- static wchar_t connectString[200];
- connectString[0] = L'\0';
+ FdoStringP connectString;
+ static wchar_t retConnectString[200];
if (Connection_WithDatastore == pTypeReq)
- swprintf( connectString,
- sizeof(connectString)/sizeof(wchar_t),
+ connectString = FdoStringP::Format(
L"service=%ls;username=%ls;password=%ls;datastore=%ls",
(FdoString*) service,
(FdoString*) username,
@@ -305,16 +309,19 @@
(FdoString*) datastore
);
else
- swprintf(
- connectString,
- sizeof(connectString)/sizeof(wchar_t),
+ connectString = FdoStringP::Format(
L"service=%ls;username=%ls;password=%ls;",
(FdoString*) service,
(FdoString*) username,
(FdoString*) password
);
- return connectString;
+ if ( bAddExtraneousSpaces )
+ connectString = FdoStringP(L" ") + connectString.Replace(L"=",L" = ").Replace(L";",L" ; ") + L" ";
+
+ wcscpy(retConnectString, connectString);
+
+ return retConnectString;
}
FdoStringP ConnectionUtil::GetEnviron(const char *name, FdoString *suffix)
@@ -358,6 +365,54 @@
{
return GetEnv("dsnname");
}
+ else if (_stricmp(name, "comdir") == 0)
+ {
+#ifdef _WIN32
+ char com_dir[MAX_PATH];
+ wchar_t wcom_dir[MAX_PATH];
+ DWORD result;
+ char* last;
+ char buffer[1024];
+
+ if (NULL == CommandFilesDirectory)
+ {
+ strcpy (com_dir, ".\\");
+ result = GetModuleFileName (
+ NULL, // handle to module
+ com_dir, // path buffer
+ MAX_PATH // size of buffer
+ );
+ if (0 != result)
+ {
+ // scan the string for the last occurrence of a slash
+ last = strrchr (com_dir, '\\');
+ if (NULL != last)
+ {
+ last++; // move past the slash
+ *last = '\0'; // null terminate it there
+ }
+ }
+ strcat (com_dir, "com\\");
+
+ swprintf (wcom_dir, MAX_PATH - 1, L"%hs", com_dir );
+
+ if ( (!FdoCommonFile::FileExists(wcom_dir)) || (!FdoCommonFile::IsDirectory(wcom_dir)) )
+ {
+ sprintf (buffer, "Command files directory '%s' doesn't exist.", com_dir);
+ CPPUNIT_FAIL (buffer);
+ }
+ else
+ {
+ CommandFilesDirectory = new char[strlen (com_dir) + 1];
+ strcpy (CommandFilesDirectory, com_dir);
+ }
+ }
+ return (CommandFilesDirectory);
+#else
+ char* getComDir ();
+ return getComDir();
+#endif
+ }
return L"";
}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.h 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/ConnectionUtil.h 2007-03-08 21:24:38 UTC (rev 788)
@@ -72,7 +72,7 @@
public:
ConnectionUtil(void);
- virtual wchar_t *GetConnectionString(StringConnTypeRequest pTypeReq = Connection_WithDatastore, FdoString *suffix = L"");
+ virtual wchar_t *GetConnectionString(StringConnTypeRequest pTypeReq = Connection_WithDatastore, FdoString *suffix = L"", bool bAddExtraneousSpaces = false);
virtual FdoStringP GetEnviron( const char *name, FdoString *suffix = L"" );
virtual FdoStringP GetEnv( const char* name );
virtual StaticConnection* NewStaticConnection() = 0;
@@ -85,6 +85,9 @@
virtual ~ConnectionUtil(void);
protected:
bool m_SetupDone;
+
+private:
+ static char *CommandFilesDirectory;
};
#endif // CPP_UNIT_CONNECTIONUTIL_H
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoDatastoreTest.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoDatastoreTest.cpp 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoDatastoreTest.cpp 2007-03-08 21:24:38 UTC (rev 788)
@@ -121,6 +121,7 @@
connection->SetConnectionString ( connectString);
connection->Open();
+ FdoPtr<FdoIConnectionCapabilities> connectionCapabilities = connection->GetConnectionCapabilities();
FdoPtr<FdoIListDataStores> pListDataStoresCmd = (FdoIListDataStores*) connection->CreateCommand(FdoCommandType_ListDataStores);
@@ -147,12 +148,15 @@
FdoPtr<FdoIDataStorePropertyDictionary> dictionary = pReader->GetDataStoreProperties();
ListDatabaseProperties( dictionary );
- //FdoStringP ltmode = dictionary->GetProperty(L"LtMode");
- //FdoStringP lckmode = dictionary->GetProperty(L"LockMode");
+ if ( connectionCapabilities->SupportsLongTransactions() )
+ {
+ FdoStringP ltmode = dictionary->GetProperty(L"LtMode");
+ CPPUNIT_ASSERT_MESSAGE("Wrong LT mode", ( wcscmp( ltmode, get_lt_mode() ) == 0 ));
+ }
+ //FdoStringP lckmode = dictionary->GetProperty(L"LockMode");
CPPUNIT_ASSERT_MESSAGE("Description doesn't match", ( wcscmp( string2, UNIT_TEST_DB_DESCRIPTION) == 0));
CPPUNIT_ASSERT_MESSAGE("Database is not FDO enabled", bVal == true );
- //CPPUNIT_ASSERT_MESSAGE("Wrong LT mode", ( wcscmp( ltmode, get_lt_mode() ) == 0 ));
//CPPUNIT_ASSERT_MESSAGE("Wrong LT mode", ( wcscmp( lckmode, get_lt_mode()) == 0 ));
}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.cpp 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.cpp 2007-03-08 21:24:38 UTC (rev 788)
@@ -991,4 +991,20 @@
}
}
-
+void FdoSchemaTest::Test_Defect802102()
+{
+ try
+ {
+ FdoSchemaMappingsP mappings = FdoPhysicalSchemaMappingCollection::Create();
+ mappings->ReadXml( L"tm_802102.xml" );
+ mappings->WriteXml( L"tm_802102_2.xml" );
+ mappings->Clear();
+ mappings->ReadXml( L"tm_802102_2.xml" );
+ mappings->WriteXml( L"tm_802102_3.xml" );
+ UnitTestUtil::CheckOutput( "tm_802102_3.xml", "tm_802102_2.xml" );
+ }
+ catch ( FdoException* e )
+ {
+ UnitTestUtil::FailOnException( e );
+ }
+}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.h 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoSchemaTest.h 2007-03-08 21:24:38 UTC (rev 788)
@@ -32,6 +32,7 @@
CPPUNIT_TEST( OverrideXmlAllTest );
CPPUNIT_TEST( OverrideXmlErrTest );
CPPUNIT_TEST( OverrideTablesWithOddAsciiChars );
+ CPPUNIT_TEST( Test_Defect802102 );
CPPUNIT_TEST_SUITE_END();
public:
@@ -49,6 +50,7 @@
virtual void OverrideXmlAllTest();
virtual void OverrideXmlErrTest();
virtual void OverrideTablesWithOddAsciiChars();
+ void Test_Defect802102();
// Helper methods:
virtual void CreateFreshDb();
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.cpp 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.cpp 2007-03-08 21:24:38 UTC (rev 788)
@@ -666,7 +666,7 @@
// If it does, check if it has the current version. The version is kept in
// the Schema Attribute dictionary.
-/*
+
if ( pSchema ) {
if ( (!FdoSADP(pSchema->GetAttributes())->ContainsAttribute(L"version")) ||
(wcscmp(FdoSADP(pSchema->GetAttributes())->GetAttributeValue(L"version"), currVersion) != 0) ) {
@@ -679,7 +679,7 @@
pSchema = NULL;
}
}
-*/
+
if ( !pSchema )
{
FdoPtr<FdoIApplySchema> pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema);
@@ -861,9 +861,13 @@
char *UnitTestUtil::w2a(const wchar_t* wString)
{
- char* retVal = NULL;
- wide_to_multibyte(retVal, wString);
- return retVal;
+ static char string[2048];
+
+ FdoCommonThreadMutex mutex;
+ mutex.Enter();
+ wcstombs(string, wString, sizeof(string));
+ mutex.Leave();
+ return string;
}
FdoIConnection* UnitTestUtil::GetProviderConnectionObject()
@@ -890,9 +894,9 @@
return (ret);
}
-wchar_t *UnitTestUtil::GetConnectionString(StringConnTypeRequest pTypeReq, FdoString *suffix)
+wchar_t *UnitTestUtil::GetConnectionString(StringConnTypeRequest pTypeReq, FdoString *suffix, bool bAddExtraneousSpaces)
{
- return UnitTestUtil::InfoUtilConnection->GetConnectionString(pTypeReq, suffix);
+ return UnitTestUtil::InfoUtilConnection->GetConnectionString(pTypeReq, suffix, bAddExtraneousSpaces);
}
void UnitTestUtil::CreateDB(bool addSchema, bool useBaseMapping, FdoString *suffix, int lt_method, bool lt_method_fixed)
@@ -1238,12 +1242,12 @@
return(connection);
}
-void UnitTestUtil::DropDb()
+void UnitTestUtil::DropDb(FdoString *suffix)
{
FdoStringP service = UnitTestUtil::GetEnviron("service");
FdoStringP username = UnitTestUtil::GetEnviron("username");
FdoStringP password = UnitTestUtil::GetEnviron("password");
- FdoStringP datastore = UnitTestUtil::GetEnviron("datastore");
+ FdoStringP datastore = UnitTestUtil::GetEnviron("datastore", suffix);
bool bExists = DatastoreExists();
if (bExists)
@@ -1290,14 +1294,14 @@
FdoStringP datastore = GetEnviron("datastore", suffix);
bool found = false;
- FdoSchemaManagerP mgr = staticConn->CreateSchemaManager();
- FdoSmPhMgrP ph = mgr->GetPhysicalSchema();
+ {
+ FdoSchemaManagerP mgr = staticConn->CreateSchemaManager();
+ FdoSmPhMgrP ph = mgr->GetPhysicalSchema();
- if ( FdoSmPhOwnerP(ph->FindOwner(datastore, L"", false)) )
- found = true;
+ if ( FdoSmPhOwnerP(ph->FindOwner(datastore, L"", false)) )
+ found = true;
+ }
- ph = NULL;
- mgr = NULL;
staticConn->disconnect();
delete staticConn;
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.h 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/UnitTestUtil.h 2007-03-08 21:24:38 UTC (rev 788)
@@ -81,9 +81,9 @@
static const char* GetEnv( const char* pVar, const char* pDefault );
static FdoIConnection* GetProviderConnectionObject();
- static wchar_t *GetConnectionString(StringConnTypeRequest pTypeReq = Connection_WithDatastore, FdoString *suffix = L"");
+ static wchar_t *GetConnectionString(StringConnTypeRequest pTypeReq = Connection_WithDatastore, FdoString *suffix = L"", bool bAddExtraneousSpaces = false);
static void CreateDB(bool addSchema = true, bool useBaseMapping=false, FdoString *suffix = L"", int lt_method = 0, bool lt_method_fixed = false );
- static void CreateDB( FdoIConnection* connection, FdoString *username, FdoString *description, FdoString *password, char *schemaType, int local_lt_method );
+ static void CreateDB( FdoIConnection* connection, FdoString *datastore, FdoString *description, FdoString *password, char *schemaType, int local_lt_method );
static FdoStringP GetEnviron(const char *name, FdoString *suffix = L"");
static void SetProvider( const char *providerName );
@@ -137,7 +137,7 @@
bool bDelete,
FdoString *suffix
);
- static void DropDb();
+ static void DropDb(FdoString *suffix = L"" );
static void DropDb( FdoIConnection *connection, FdoString* pDatastore, FdoString* pPassword, FdoString* pService );
// Check if the given connect contains the given datastore.
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.cpp 2007-03-08 21:24:38 UTC (rev 788)
@@ -412,7 +412,7 @@
}
}
-wchar_t *OdbcConnectionUtil::GetConnectionString(StringConnTypeRequest pTypeReq, FdoString *suffix)
+wchar_t *OdbcConnectionUtil::GetConnectionString(StringConnTypeRequest pTypeReq, FdoString *suffix, bool bAddExtraneousSpaces)
{
FdoStringP service = UnitTestUtil::GetEnviron("service");
FdoStringP username = UnitTestUtil::GetEnviron("username");
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.h 2007-03-08 19:52:19 UTC (rev 787)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcConnectionUtil.h 2007-03-08 21:24:38 UTC (rev 788)
@@ -53,7 +53,7 @@
virtual StaticConnection* NewStaticConnection ();
virtual FdoInsertTest* GetInsertTest ();
virtual FdoStringP GetOutputFileName (FdoString* pBaseFileName);
- virtual wchar_t* GetConnectionString(StringConnTypeRequest pTypeReq = Connection_WithDatastore, FdoString *suffix = L"");
+ virtual wchar_t* GetConnectionString(StringConnTypeRequest pTypeReq = Connection_WithDatastore, FdoString *suffix = L"", bool bAddExtraneousSpaces = false);
virtual const char* GetSuffixTest(){return "_odbc";};
protected:
Added: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/tm_802102.xml
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/tm_802102.xml (rev 0)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/tm_802102.xml 2007-03-08 21:24:38 UTC (rev 788)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fdo:DataStore xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:fdo="http://fdo.osgeo.org/schemas" xmlns:fds="http://fdo.osgeo.org/schemas/fds">
+ <SchemaMapping xmlns:rdb="http://fdordbms.osgeo.org/schemas" xmlns="http://www.autodesk.com/isd/fdo/OracleProvider" provider="Autodesk.Oracle.3.1" name="OverridesA" database="oxy" owner="fdo_br_apply_overrides">
+ <complexType name="OvClassDType" tableMapping="Base">
+ <Table pkeyName="PK_OV_TABLE_C" name="OV_TABLE_C"/>
+ <element name="DataD">
+ <Column name="OV_COL_D" sequenceName="OV_SEQ_1"/>
+ </element>
+ </complexType>
+ </SchemaMapping>
+</fdo:DataStore>
More information about the fdo-commits
mailing list