mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 02:06:04 +02:00
Tidying up the tests
This commit is contained in:
@@ -16,7 +16,8 @@ endif
|
||||
|
||||
objects = ODBCTestSuite Driver \
|
||||
ODBCDB2Test ODBCMySQLTest ODBCOracleTest \
|
||||
ODBCPostgreSQLTest ODBCSQLiteTest SQLExecutor
|
||||
ODBCPostgreSQLTest ODBCSQLiteTest ODBCSQLServerTest \
|
||||
SQLExecutor
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
|
||||
@@ -139,12 +139,12 @@ void ODBCAccessTest::recreatePersonTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCAccessTest::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCAccessTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -154,11 +154,26 @@ bool ODBCAccessTest::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "DRIVER=Microsoft Access Driver (*.mdb);"
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "DRIVER=%s;"
|
||||
"UID=admin;"
|
||||
"UserCommitSync=Yes;"
|
||||
"Threads=3;"
|
||||
@@ -168,8 +183,7 @@ bool ODBCAccessTest::checkODBCSetup(const std::string& dbName)
|
||||
"MaxBufferSize=2048;"
|
||||
"FIL=MS Access;"
|
||||
"DriverId=25;"
|
||||
"DefaultDir=C:\\;"
|
||||
"DBQ=C:\\test.mdb;";
|
||||
"DBQ=test.mdb;", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -186,10 +200,10 @@ void ODBCAccessTest::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCAccessTest::init(const std::string& dbName)
|
||||
bool ODBCAccessTest::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -202,7 +216,7 @@ bool ODBCAccessTest::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
//N.B. Access driver does not suport check for connection.
|
||||
std::cout << "*** Connected to " << dbName << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -210,7 +224,7 @@ bool ODBCAccessTest::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCAccessTest::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("Microsoft Access Driver (*.mdb)", "PocoDataAccessTest"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCAccessTest");
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ private:
|
||||
void dropTable(const std::string& tableName);
|
||||
void recreatePersonTable();
|
||||
|
||||
static bool init(const std::string& dbName = "Microsoft Access Driver");
|
||||
static bool checkODBCSetup(const std::string& dbName = "Microsoft Access Driver");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -799,12 +799,12 @@ void ODBCDB2Test::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCDB2Test::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCDB2Test::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -814,11 +814,32 @@ bool ODBCDB2Test::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "DSN=PocoDataDB2Test;Uid=db2admin;Pwd=db2admin;";
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "Driver=%s;"
|
||||
"Database=POCOTEST;"
|
||||
"Hostname=localhost;"
|
||||
"Port=50000;"
|
||||
"Protocol=TCPIP;"
|
||||
"Uid=db2admin;"
|
||||
"Pwd=db2admin;", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -836,10 +857,10 @@ void ODBCDB2Test::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCDB2Test::init(const std::string& dbName)
|
||||
bool ODBCDB2Test::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -852,9 +873,9 @@ bool ODBCDB2Test::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
if (_pSession && _pSession->isConnected())
|
||||
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
|
||||
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -862,7 +883,7 @@ bool ODBCDB2Test::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCDB2Test::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("IBM DB2 ODBC DRIVER - DB2COPY1", "PocoDataDB2Test"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCDB2Test");
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ private:
|
||||
void recreateTuplesTable();
|
||||
void recreateVectorsTable();
|
||||
|
||||
static bool init(const std::string& dbName = "IBM DB2");
|
||||
static bool checkODBCSetup(const std::string& dbName = "IBM DB2");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -788,12 +788,12 @@ void ODBCMySQLTest::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCMySQLTest::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCMySQLTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -803,15 +803,30 @@ bool ODBCMySQLTest::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "DRIVER=MySQL ODBC 3.51 Driver;"
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "DRIVER=%s;"
|
||||
"DATABASE=test;"
|
||||
"SERVER=localhost;"
|
||||
"UID=root;"
|
||||
"PWD=mysql;";
|
||||
"PWD=mysql;", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -829,10 +844,10 @@ void ODBCMySQLTest::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCMySQLTest::init(const std::string& dbName)
|
||||
bool ODBCMySQLTest::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -845,9 +860,9 @@ bool ODBCMySQLTest::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
if (_pSession && _pSession->isConnected())
|
||||
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
|
||||
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -855,7 +870,7 @@ bool ODBCMySQLTest::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCMySQLTest::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("MySQL ODBC 3.51 Driver", "PocoDataMySQLTest"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest");
|
||||
|
||||
|
||||
@@ -122,8 +122,8 @@ private:
|
||||
void recreateTuplesTable();
|
||||
void recreateVectorsTable();
|
||||
|
||||
static bool checkODBCSetup(const std::string& dbName = "MySQL");
|
||||
static bool init(const std::string& dbName = "MySQL");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -796,12 +796,12 @@ void ODBCOracleTest::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCOracleTest::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCOracleTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -811,11 +811,54 @@ bool ODBCOracleTest::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "DSN=PocoDataOracleTest;Uid=Scott;Pwd=Tiger;";
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "DRIVER={%s};"
|
||||
"UID=Scott;"
|
||||
"PWD=Tiger;"
|
||||
"TLO=O;"
|
||||
"FBS=60000;"
|
||||
"FWC=F;"
|
||||
"CSR=F;"
|
||||
"MDI=Me;"
|
||||
"MTS=T;"
|
||||
"DPM=F;"
|
||||
"NUM=NLS;"
|
||||
"BAM=IfAllSuccessful;"
|
||||
"BTD=F;"
|
||||
"RST=T;"
|
||||
"LOB=T;"
|
||||
"FDL=10;"
|
||||
"FRC=10;"
|
||||
"QTO=T;"
|
||||
"FEN=T;"
|
||||
"XSM=Default;"
|
||||
"EXC=F;"
|
||||
"APA=T;"
|
||||
"DBA=W;"
|
||||
"DBQ=XE;"
|
||||
"SERVER="
|
||||
"(DESCRIPTION="
|
||||
" (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))"
|
||||
" (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE))"
|
||||
");", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -833,10 +876,10 @@ void ODBCOracleTest::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCOracleTest::init(const std::string& dbName)
|
||||
bool ODBCOracleTest::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -849,9 +892,9 @@ bool ODBCOracleTest::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
if (_pSession && _pSession->isConnected())
|
||||
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
|
||||
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -859,7 +902,7 @@ bool ODBCOracleTest::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCOracleTest::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("Oracle in XE", "PocoDataOracleTest"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCOracleTest");
|
||||
|
||||
|
||||
@@ -121,8 +121,8 @@ private:
|
||||
void recreateTuplesTable();
|
||||
void recreateVectorsTable();
|
||||
|
||||
static bool checkODBCSetup(const std::string& dbName = "Oracle");
|
||||
static bool init(const std::string& dbName = "Oracle");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -782,12 +782,12 @@ void ODBCPostgreSQLTest::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCPostgreSQLTest::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCPostgreSQLTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -797,11 +797,26 @@ bool ODBCPostgreSQLTest::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "DRIVER=PostgreSQL ANSI;"
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "DRIVER=%s;"
|
||||
"DATABASE=postgres;"
|
||||
"SERVER=localhost;"
|
||||
"PORT=5432;"
|
||||
@@ -836,7 +851,7 @@ bool ODBCPostgreSQLTest::checkODBCSetup(const std::string& dbName)
|
||||
"RowVersioning=0;"
|
||||
"ShowOidColumn=0;"
|
||||
"FakeOidIndex=0;"
|
||||
"ReadOnly=0;";
|
||||
"ReadOnly=0;", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -854,10 +869,10 @@ void ODBCPostgreSQLTest::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCPostgreSQLTest::init(const std::string& dbName)
|
||||
bool ODBCPostgreSQLTest::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -870,9 +885,9 @@ bool ODBCPostgreSQLTest::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
if (_pSession && _pSession->isConnected())
|
||||
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
|
||||
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -880,7 +895,7 @@ bool ODBCPostgreSQLTest::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCPostgreSQLTest::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("PostgreSQL ANSI", "PocoDataPostgreSQLTest"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest");
|
||||
|
||||
|
||||
@@ -122,8 +122,8 @@ private:
|
||||
void recreateTuplesTable();
|
||||
void recreateVectorsTable();
|
||||
|
||||
static bool init(const std::string& dbName = "PostgreSQL");
|
||||
static bool checkODBCSetup(const std::string& dbName = "PostgreSQL");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -809,12 +809,12 @@ void ODBCSQLServerTest::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCSQLServerTest::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCSQLServerTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -824,15 +824,30 @@ bool ODBCSQLServerTest::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "DRIVER=SQL Server;"
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "DRIVER=%s;"
|
||||
"UID=test;"
|
||||
"PWD=test;"
|
||||
"DATABASE=test;"
|
||||
"SERVER=(local);";
|
||||
"SERVER=(local);", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -850,10 +865,10 @@ void ODBCSQLServerTest::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCSQLServerTest::init(const std::string& dbName)
|
||||
bool ODBCSQLServerTest::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -866,9 +881,9 @@ bool ODBCSQLServerTest::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
if (_pSession && _pSession->isConnected())
|
||||
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
|
||||
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -876,7 +891,7 @@ bool ODBCSQLServerTest::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCSQLServerTest::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("SQL Server", "PocoDataSQLServerTest"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLServerTest");
|
||||
|
||||
|
||||
@@ -124,8 +124,8 @@ private:
|
||||
void recreateVectorTable();
|
||||
void recreateVectorsTable();
|
||||
|
||||
static bool checkODBCSetup(const std::string& dbName = "SQL Server");
|
||||
static bool init(const std::string& dbName = "SQL Server");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -778,12 +778,12 @@ void ODBCSQLiteTest::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCSQLiteTest::checkODBCSetup(const std::string& dbName)
|
||||
bool ODBCSQLiteTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
for (; itDrv != _drivers.end(); ++itDrv)
|
||||
{
|
||||
if (((itDrv->first).find(dbName) != std::string::npos))
|
||||
if (((itDrv->first).find(driver) != std::string::npos))
|
||||
{
|
||||
std::cout << "Driver found: " << itDrv->first
|
||||
<< " (" << itDrv->second << ')' << std::endl;
|
||||
@@ -793,11 +793,26 @@ bool ODBCSQLiteTest::checkODBCSetup(const std::string& dbName)
|
||||
|
||||
if (_drivers.end() == itDrv)
|
||||
{
|
||||
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||
std::cout << driver << " driver NOT found, tests not available." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbConnString = "Driver=SQLite3 ODBC Driver;Database=dummy.db;";
|
||||
Utility::DSNMap dataSources;
|
||||
Utility::dataSources(dataSources);
|
||||
Utility::DSNMap::iterator itDSN = dataSources.begin();
|
||||
for (; itDSN != dataSources.end(); ++itDSN)
|
||||
{
|
||||
if (itDSN->first == dsn && itDSN->second == driver)
|
||||
{
|
||||
std::cout << "DSN found: " << itDSN->first
|
||||
<< " (" << itDSN->second << ')' << std::endl;
|
||||
format(_dbConnString, "DSN=%s", dsn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// DSN not found, try connect without it
|
||||
format(_dbConnString, "Driver=%s;Database=dummy.db;", driver);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -815,10 +830,10 @@ void ODBCSQLiteTest::tearDown()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCSQLiteTest::init(const std::string& dbName)
|
||||
bool ODBCSQLiteTest::init(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!checkODBCSetup()) return false;
|
||||
if (!canConnect(driver, dsn)) return false;
|
||||
|
||||
ODBC::Connector::registerConnector();
|
||||
try
|
||||
@@ -831,9 +846,9 @@ bool ODBCSQLiteTest::init(const std::string& dbName)
|
||||
}
|
||||
|
||||
if (_pSession && _pSession->isConnected())
|
||||
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
|
||||
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
|
||||
|
||||
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
|
||||
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -841,7 +856,7 @@ bool ODBCSQLiteTest::init(const std::string& dbName)
|
||||
|
||||
CppUnit::Test* ODBCSQLiteTest::suite()
|
||||
{
|
||||
if (init())
|
||||
if (init("SQLite3 ODBC Driver", "PocoDataSQLiteTest"))
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLiteTest");
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ private:
|
||||
void recreateTuplesTable();
|
||||
void recreateVectorsTable();
|
||||
|
||||
static bool checkODBCSetup(const std::string& dbName = "SQLite3");
|
||||
static bool init(const std::string& dbName = "SQLite3");
|
||||
static bool init(const std::string& driver, const std::string& dsn);
|
||||
static bool canConnect(const std::string& driver, const std::string& dsn);
|
||||
|
||||
static Poco::Data::ODBC::Utility::DriverMap _drivers;
|
||||
static std::string _dbConnString;
|
||||
|
||||
@@ -67,8 +67,10 @@ CppUnit::Test* ODBCTestSuite::suite()
|
||||
addTest(pSuite, ODBCDB2Test::suite());
|
||||
addTest(pSuite, ODBCMySQLTest::suite());
|
||||
addTest(pSuite, ODBCSQLiteTest::suite());
|
||||
addTest(pSuite, ODBCAccessTest::suite());
|
||||
addTest(pSuite, ODBCSQLServerTest::suite());
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
addTest(pSuite, ODBCAccessTest::suite());
|
||||
#endif
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user