[fdo-commits] r728 - in
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest: Common Odbc
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Tue Feb 6 08:07:57 EST 2007
Author: pierredalcourt
Date: 2007-02-06 08:07:56 -0500 (Tue, 06 Feb 2007)
New Revision: 728
Modified:
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.h
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.h
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoMultiThreadTest.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.cpp
branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.h
Log:
ODBC: fix & enhance unit tests
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.cpp 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.cpp 2007-02-06 13:07:56 UTC (rev 728)
@@ -29,12 +29,6 @@
#define NUMBER_OF_THREADS 10
static bool use_threads = true;
-struct ConnectInfo {
- int connectionId;
- FdoIConnection *mConn;
- FdoStringP msgException;
-};
-
FdoMultiThreadTest::FdoMultiThreadTest(void)
{
}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.h 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Common/FdoMultiThreadTest.h 2007-02-06 13:07:56 UTC (rev 728)
@@ -29,6 +29,13 @@
#endif
};
+struct ConnectInfo {
+ int connectionId;
+ FdoIConnection *mConn;
+ FdoStringP msgException;
+};
+
+
class FdoMultiThreadTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE( FdoMultiThreadTest );
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp 2007-02-06 13:07:56 UTC (rev 728)
@@ -20,8 +20,9 @@
#include "OdbcBaseSetup.h"
#include "UnitTestUtil.h"
-bool OdbcBaseSetup::OracleDataSupportCreated = false;
+FdoPtr<FdoStringCollection> OdbcBaseSetup::OracleDataSupportCreated = FdoStringCollection::Create();
+
void OdbcBaseSetup::DestroyDataStore(FdoIConnection* pConnection, FdoString *suffix)
{
FdoStringP pDatastore = UnitTestUtil::GetEnviron("datastore", suffix);
@@ -53,7 +54,7 @@
void OdbcBaseSetup::CreateDataStore(FdoIConnection* pConnection, FdoString *suffix)
{
- if (DataBaseType_Oracle == m_typeDB && OdbcBaseSetup::OracleDataSupportCreated == true)
+ if (DataBaseType_Oracle == m_typeDB && OdbcBaseSetup::OracleDataSupportCreated->IndexOf(suffix)!=-1)
return;
FdoStringP pDatastore = UnitTestUtil::GetEnviron("datastore", suffix);
// clean the before start
@@ -62,7 +63,7 @@
FdoStringP pQueryStringDrp;
if (DataBaseType_Oracle == m_typeDB)
{
- OdbcBaseSetup::OracleDataSupportCreated = true;
+ OdbcBaseSetup::OracleDataSupportCreated->Add(suffix);
FdoStringP pUDatastore = pDatastore;
pUDatastore = pUDatastore.Upper();
pQueryStringDrp = (FdoStringP)L"CREATE USER \"" + pUDatastore + L"\" PROFILE \"DEFAULT\" IDENTIFIED BY \"";
@@ -75,6 +76,8 @@
UnitTestUtil::Sql2Db( (const wchar_t*) pQueryStringDrp, pConnection );
pQueryStringDrp = (FdoStringP)L"GRANT CREATE SEQUENCE TO " + pUDatastore;
UnitTestUtil::Sql2Db( (const wchar_t*) pQueryStringDrp, pConnection );
+ pQueryStringDrp = (FdoStringP)L"GRANT CREATE TRIGGER TO " + pUDatastore;
+ UnitTestUtil::Sql2Db( (const wchar_t*) pQueryStringDrp, pConnection );
pQueryStringDrp = (FdoStringP)L"GRANT CREATE SESSION TO " + pUDatastore;
UnitTestUtil::Sql2Db( (const wchar_t*) pQueryStringDrp, pConnection );
pQueryStringDrp = (FdoStringP)L"GRANT CREATE SYNONYM TO " + pUDatastore;
@@ -97,7 +100,7 @@
UnitTestUtil::Sql2Db( (const wchar_t*) pQueryStringDrp, pConnection );
pConnection->Close();
- pConnection->SetConnectionString ( UnitTestUtil::GetConnectionString(Connection_NoDatastore) );
+ pConnection->SetConnectionString ( UnitTestUtil::GetConnectionString(Connection_NoDatastore, suffix) );
pConnection->Open();
UnitTestUtil::Sql2Db( (const wchar_t**) mOracleAcadTestData, pConnection );
UnitTestUtil::Sql2Db( (const wchar_t**) mOracleNonAcadTest, pConnection );
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.h 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.h 2007-02-06 13:07:56 UTC (rev 728)
@@ -85,7 +85,7 @@
static const wchar_t* mOracleAcadTestData[];
static const wchar_t* mOracleNonAcadTest[];
- static bool OracleDataSupportCreated;
+ static FdoPtr<FdoStringCollection> OracleDataSupportCreated;
};
#endif // ODBC_BASESETUP_H
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoMultiThreadTest.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoMultiThreadTest.cpp 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoMultiThreadTest.cpp 2007-02-06 13:07:56 UTC (rev 728)
@@ -40,10 +40,6 @@
UnitTestUtil::SetProvider( "OdbcOracle" );
}
-struct ConnectInfo {
- int connectionId;
- FdoIConnection *mConn;
-};
#ifdef _WIN32
DWORD WINAPI StartOdbcQuery(LPVOID lpParameter)
@@ -86,7 +82,8 @@
}
catch (FdoException* e)
{
- TestCommonFail (e);
+ cnInfo->msgException = e->GetExceptionMessage();
+ e->Release();
}
}
return 0;
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.cpp 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.cpp 2007-02-06 13:07:56 UTC (rev 728)
@@ -28,6 +28,11 @@
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcMySqlFdoSchemaTest, "OdbcMySqlFdoSchemaTest");
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcMySqlFdoSchemaTest, "OdbcMySqlTests");
+CPPUNIT_TEST_SUITE_REGISTRATION( OdbcOracleFdoSchemaTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcOracleFdoSchemaTest, "FdoSchemaTest");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcOracleFdoSchemaTest, "OdbcOracleFdoSchemaTest");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcOracleFdoSchemaTest, "OdbcOracleTests");
+
#ifdef _WIN32
CPPUNIT_TEST_SUITE_REGISTRATION( OdbcSqlServerFdoSchemaTest );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcSqlServerFdoSchemaTest, "FdoSchemaTest");
@@ -40,30 +45,19 @@
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OdbcAccessFdoSchemaTest, "OdbcAccessTests");
#endif
-void OdbcFdoSchemaTest::DropDatastore()
-{
- // Drop the old datastore, if it exists:
- try
- {
- FdoStringP userConnectString = UnitTestUtil::GetConnectionString(Connection_NoDatastore);
- FdoPtr<FdoIConnection> connection = UnitTestUtil::GetProviderConnectionObject();
- connection->SetConnectionString( userConnectString );
- connection->Open();
- m_OdbcSetup.DestroyDataStore( connection.p, DB_SUFFIX );
- connection->Close();
- }
- catch(...) { }
-}
void OdbcFdoSchemaTest::CreateFreshDb()
{
if (!m_bDatabaseCreated)
{
- DropDatastore();
// Create a datastore (will create metaschema tables automatically, unfortunately):
try
{
- FdoStringP userConnectString = UnitTestUtil::GetConnectionString(Connection_NoDatastore);
+ FdoStringP userConnectString;
+ if (DataBaseType_Oracle == m_OdbcSetup.GetTypeDB())
+ userConnectString = UnitTestUtil::GetConnectionString(Connection_OraSetup);
+ else
+ userConnectString = UnitTestUtil::GetConnectionString(Connection_NoDatastore);
FdoPtr<FdoIConnection> connection = UnitTestUtil::GetProviderConnectionObject();
connection->SetConnectionString( userConnectString );
connection->Open();
@@ -81,10 +75,17 @@
if (DataBaseType_MySQL == m_OdbcSetup.GetTypeDB())
UnitTestUtil::Sql2Db( (const wchar_t**) mApplySchemaMySqlCt, connection.p );
- else
- if (DataBaseType_SqlServer == m_OdbcSetup.GetTypeDB())
+ else if (DataBaseType_SqlServer == m_OdbcSetup.GetTypeDB())
UnitTestUtil::Sql2Db( (const wchar_t**) mApplySchemaSqlServerCt, connection.p );
+ else if (DataBaseType_Oracle == m_OdbcSetup.GetTypeDB())
+ {
+ UnitTestUtil::Sql2Db( (const wchar_t**) mApplySchemaOracleCt, connection.p );
+ // NOTE: since Sql2Db(const wchar_t**) strips out ";" terminators that are vital to trigger
+ // definitions, we have to use the other Sql2Db(const wchar_t*) to create the trigger:
+ UnitTestUtil::Sql2Db( mApplySchemaOracleCtTrigger, connection.p );
+ }
+
// Insert some data:
FdoPtr<FdoISQLCommand> sql = (FdoISQLCommand*)connection->CreateCommand(FdoCommandType_SQLCommand);
sql->SetSQLStatement(L"insert into lowercaseclass (x, y, z, id, revisionnumber, classid) values (5.0, 5.0, 0.0, 1, 0, 1)");
@@ -156,10 +157,35 @@
NULL
};
+const wchar_t* OdbcFdoSchemaTest::mApplySchemaOracleCt[] = {
+ L"create table lowercaseclass (",
+ L"classid NUMBER(20) NOT NULL,",
+ L"featid NUMBER(20) NOT NULL UNIQUE,",
+ L"revisionnumber NUMBER NOT NULL,",
+ L"z NUMBER NOT NULL,",
+ L"y NUMBER NOT NULL,",
+ L"x NUMBER NOT NULL,",
+ L"id NUMBER(10) NOT NULL PRIMARY KEY,",
+ L"realgeometry MDSYS.SDO_GEOMETRY",
+ L");",
+ L"CREATE SEQUENCE lowercaseclass_sequence START WITH 1 INCREMENT BY 1;",
+ NULL
+};
+const wchar_t* OdbcFdoSchemaTest::mApplySchemaOracleCtTrigger =
+ L"CREATE OR REPLACE TRIGGER lowercaseclass_seq_trigger BEFORE INSERT ON lowercaseclass REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT lowercaseclass_sequence.nextval INTO :NEW.FEATID FROM dual; END;";
+
+
+
void OdbcMySqlFdoSchemaTest::set_provider()
{
UnitTestUtil::SetProvider( "OdbcMySql" );
}
+
+void OdbcOracleFdoSchemaTest::set_provider()
+{
+ UnitTestUtil::SetProvider( "OdbcOracle" );
+}
+
#ifdef _WIN32
void OdbcSqlServerFdoSchemaTest::set_provider()
{
Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.h 2007-02-02 21:58:26 UTC (rev 727)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSchemaTest.h 2007-02-06 13:07:56 UTC (rev 728)
@@ -29,7 +29,6 @@
{
m_OdbcSetup.SetTypeDB(typeDB);
}
- virtual void DropDatastore();
virtual void CreateFreshDb();
virtual void OverrideXmlAllTest() {};
@@ -38,9 +37,10 @@
protected:
OdbcBaseSetup m_OdbcSetup;
- static const wchar_t* mApplySchema[];
static const wchar_t* mApplySchemaSqlServerCt[];
static const wchar_t* mApplySchemaMySqlCt[];
+ static const wchar_t* mApplySchemaOracleCt[];
+ static const wchar_t* mApplySchemaOracleCtTrigger;
};
class OdbcMySqlFdoSchemaTest : public OdbcFdoSchemaTest
@@ -55,6 +55,18 @@
virtual void set_provider();
};
+class OdbcOracleFdoSchemaTest : public OdbcFdoSchemaTest
+{
+ CPPUNIT_TEST_SUB_SUITE (OdbcOracleFdoSchemaTest, FdoSchemaTest);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+ OdbcOracleFdoSchemaTest() : OdbcFdoSchemaTest(DataBaseType_Oracle){}
+
+protected:
+ virtual void set_provider();
+};
+
#ifdef _WIN32
class OdbcSqlServerFdoSchemaTest : public OdbcFdoSchemaTest
{
More information about the fdo-commits
mailing list