Tests tidy-up, DSN-less connections, preparation ODBCColumn pos fix

This commit is contained in:
Aleksandar Fabijanic
2007-05-22 00:02:40 +00:00
parent 85864b5fc2
commit a9f476da0b
18 changed files with 666 additions and 820 deletions

View File

@@ -314,7 +314,7 @@ inline std::size_t Preparation::maxDataSize(std::size_t pos) const
try try
{ {
sz = ODBCColumn(_rStmt, pos).length(); sz = ODBCColumn(_rStmt, pos-1).length();
} }
catch (StatementException&) catch (StatementException&)
{ {

View File

@@ -58,43 +58,13 @@ using Poco::NotFoundException;
Poco::SharedPtr<Poco::Data::Session> ODBCAccessTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> ODBCAccessTest::_pSession = 0;
std::string ODBCAccessTest::_dsn = "PocoDataAccessTest";
std::string ODBCAccessTest::_dbConnString; std::string ODBCAccessTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers;
Poco::Data::ODBC::Utility::DSNMap ODBCAccessTest::_dataSources;
ODBCAccessTest::ODBCAccessTest(const std::string& name): ODBCAccessTest::ODBCAccessTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
ODBC::Connector::registerConnector();
if (_drivers.empty() || _dataSources.empty())
{
Utility::drivers(_drivers);
Utility::dataSources(_dataSources);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. Access tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
//N.B. Access driver does not suport check for connection.
if (_pSession) std::cout << "*** Connected to " << _dsn << '(' << _dbConnString << ')' << std::endl;
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. Access tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -169,57 +139,39 @@ void ODBCAccessTest::recreatePersonTable()
} }
void ODBCAccessTest::checkODBCSetup() bool ODBCAccessTest::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false;
if (!beenHere)
{
beenHere = true;
bool driverFound = false;
bool dsnFound = false;
Utility::DriverMap::iterator itDrv = _drivers.begin(); Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv) for (; itDrv != _drivers.end(); ++itDrv)
{ {
if (((itDrv->first).find("Microsoft Access Driver") != std::string::npos)) if (((itDrv->first).find(dbName) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "Driver NOT found, will throw." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
throw NotFoundException("Microsoft Access ODBC driver."); return false;
} }
Utility::DSNMap::iterator itDSN = _dataSources.begin(); _dbConnString = "DRIVER=Microsoft Access Driver (*.mdb);"
for (; itDSN != _dataSources.end(); ++itDSN) "UID=admin;"
{ "UserCommitSync=Yes;"
if (((itDSN->first).find(_dsn) != std::string::npos) && "Threads=3;"
((itDSN->second).find("Microsoft Access Driver") != std::string::npos)) "SafeTransactions=0;"
{ "PageTimeout=5;"
std::cout << "DSN found: " << itDSN->first "MaxScanRows=8;"
<< " (" << itDSN->second << ')' << std::endl; "MaxBufferSize=2048;"
dsnFound = true; "FIL=MS Access;"
break; "DriverId=25;"
} "DefaultDir=C:\\;"
} "DBQ=C:\\test.mdb;";
if (!dsnFound) return true;
{
std::cout << "Access DSN NOT found, tests will fail." << std::endl;
return;
}
}
if (!_pSession)
format(_dbConnString, "DSN=%s;Uid=Admin;Pwd=;", _dsn);
} }
@@ -234,7 +186,31 @@ void ODBCAccessTest::tearDown()
} }
bool ODBCAccessTest::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
//N.B. Access driver does not suport check for connection.
std::cout << "*** Connected to " << dbName << std::endl;
return true;
}
CppUnit::Test* ODBCAccessTest::suite() CppUnit::Test* ODBCAccessTest::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCAccessTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCAccessTest");
@@ -242,3 +218,6 @@ CppUnit::Test* ODBCAccessTest::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -64,13 +64,13 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
static bool init(const std::string& dbName = "Microsoft Access Driver");
static bool checkODBCSetup(const std::string& dbName = "Microsoft Access Driver");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static Poco::Data::ODBC::Utility::DSNMap _dataSources;
static std::string _dsn;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;
bool _owner; bool _owner;

View File

@@ -60,46 +60,13 @@ using Poco::NotFoundException;
const bool ODBCDB2Test::bindValues[8] = {true, true, true, false, false, true, false, false}; const bool ODBCDB2Test::bindValues[8] = {true, true, true, false, false, true, false, false};
Poco::SharedPtr<Poco::Data::Session> ODBCDB2Test::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> ODBCDB2Test::_pSession = 0;
Poco::SharedPtr<SQLExecutor> ODBCDB2Test::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> ODBCDB2Test::_pExecutor = 0;
std::string ODBCDB2Test::_dsn = "PocoDataDB2Test";
std::string ODBCDB2Test::_dbConnString; std::string ODBCDB2Test::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCDB2Test::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCDB2Test::_drivers;
Poco::Data::ODBC::Utility::DSNMap ODBCDB2Test::_dataSources;
ODBCDB2Test::ODBCDB2Test(const std::string& name): ODBCDB2Test::ODBCDB2Test(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
if (_drivers.empty() || _dataSources.empty())
{
Utility::drivers(_drivers);
Utility::dataSources(_dataSources);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. DB2 tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << _dsn << '(' << _dbConnString << ')' << std::endl;
if (!_pExecutor)
_pExecutor = new SQLExecutor("DB2 SQL Executor", _pSession);
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. DB2 tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -832,57 +799,28 @@ void ODBCDB2Test::recreateVectorsTable()
} }
void ODBCDB2Test::checkODBCSetup() bool ODBCDB2Test::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false;
if (!beenHere)
{
beenHere = true;
bool driverFound = false;
bool dsnFound = false;
Utility::DriverMap::iterator itDrv = _drivers.begin(); Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv) for (; itDrv != _drivers.end(); ++itDrv)
{ {
if (((itDrv->first).find("IBM DB2") != std::string::npos)) if (((itDrv->first).find(dbName) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "DB2 driver NOT found, tests will fail." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
return; return false;
} }
Utility::DSNMap::iterator itDSN = _dataSources.begin(); _dbConnString = "DSN=PocoDataDB2Test;Uid=db2admin;Pwd=db2admin;";
for (; itDSN != _dataSources.end(); ++itDSN)
{
if (((itDSN->first).find(_dsn) != std::string::npos) &&
((itDSN->second).find("IBM DB2") != std::string::npos))
{
std::cout << "DSN found: " << itDSN->first
<< " (" << itDSN->second << ')' << std::endl;
dsnFound = true;
break;
}
}
if (!dsnFound) return true;
{
std::cout << "DB2 DSN NOT found, tests will fail." << std::endl;
return;
}
}
if (!_pSession)
format(_dbConnString, "DSN=%s;Uid=db2admin;Pwd=db2admin;", _dsn);
} }
@@ -898,7 +836,33 @@ void ODBCDB2Test::tearDown()
} }
bool ODBCDB2Test::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
return true;
}
CppUnit::Test* ODBCDB2Test::suite() CppUnit::Test* ODBCDB2Test::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCDB2Test"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCDB2Test");
@@ -945,3 +909,6 @@ CppUnit::Test* ODBCDB2Test::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -111,7 +111,6 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
void recreatePersonBLOBTable(); void recreatePersonBLOBTable();
@@ -121,9 +120,10 @@ private:
void recreateTuplesTable(); void recreateTuplesTable();
void recreateVectorsTable(); void recreateVectorsTable();
static bool init(const std::string& dbName = "IBM DB2");
static bool checkODBCSetup(const std::string& dbName = "IBM DB2");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static Poco::Data::ODBC::Utility::DSNMap _dataSources;
static std::string _dsn;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;
static Poco::SharedPtr<SQLExecutor> _pExecutor; static Poco::SharedPtr<SQLExecutor> _pExecutor;

View File

@@ -60,46 +60,13 @@ using Poco::NotFoundException;
const bool ODBCMySQLTest::bindValues[8] = {true, true, true, false, false, true, false, false}; const bool ODBCMySQLTest::bindValues[8] = {true, true, true, false, false, true, false, false};
Poco::SharedPtr<Poco::Data::Session> ODBCMySQLTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> ODBCMySQLTest::_pSession = 0;
Poco::SharedPtr<SQLExecutor> ODBCMySQLTest::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> ODBCMySQLTest::_pExecutor = 0;
std::string ODBCMySQLTest::_dsn = "PocoDataMySQLTest";
std::string ODBCMySQLTest::_dbConnString; std::string ODBCMySQLTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCMySQLTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCMySQLTest::_drivers;
Poco::Data::ODBC::Utility::DSNMap ODBCMySQLTest::_dataSources;
ODBCMySQLTest::ODBCMySQLTest(const std::string& name): ODBCMySQLTest::ODBCMySQLTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
if (_drivers.empty() || _dataSources.empty())
{
Utility::drivers(_drivers);
Utility::dataSources(_dataSources);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. MySQL tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << _dsn << '(' << _dbConnString << ')' << std::endl;
if (!_pExecutor)
_pExecutor = new SQLExecutor("MySQL SQL Executor", _pSession);
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. MySQL tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -130,16 +97,6 @@ void ODBCMySQLTest::testSimpleAccess()
{ {
if (!_pSession) fail ("Test not available."); if (!_pSession) fail ("Test not available.");
int count = 0;
//recreatePersonTable();
//try { *_pSession << "SELECT count(*) FROM sys.tables WHERE name = 'Person'", into(count), use(tableName), now; }
//catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("testSimpleAccess()"); }
//catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("testSimpleAccess()"); }
//assert (1 == count);
for (int i = 0; i < 8;) for (int i = 0; i < 8;)
{ {
recreatePersonTable(); recreatePersonTable();
@@ -831,57 +788,32 @@ void ODBCMySQLTest::recreateVectorsTable()
} }
void ODBCMySQLTest::checkODBCSetup() bool ODBCMySQLTest::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false;
if (!beenHere)
{
beenHere = true;
bool driverFound = false;
bool dsnFound = false;
Utility::DriverMap::iterator itDrv = _drivers.begin(); Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv) for (; itDrv != _drivers.end(); ++itDrv)
{ {
if (((itDrv->first).find("MySQL") != std::string::npos)) if (((itDrv->first).find(dbName) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "MySQL driver NOT found, tests will fail." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
return; return false;
} }
Utility::DSNMap::iterator itDSN = _dataSources.begin(); _dbConnString = "DRIVER=MySQL ODBC 3.51 Driver;"
for (; itDSN != _dataSources.end(); ++itDSN) "DATABASE=test;"
{ "SERVER=localhost;"
if (((itDSN->first).find(_dsn) != std::string::npos) && "UID=root;"
((itDSN->second).find("MySQL") != std::string::npos)) "PWD=mysql;";
{
std::cout << "DSN found: " << itDSN->first
<< " (" << itDSN->second << ')' << std::endl;
dsnFound = true;
break;
}
}
if (!dsnFound) return true;
{
std::cout << "SQL Server DSN NOT found, tests will fail." << std::endl;
return;
}
}
if (!_pSession)
format(_dbConnString, "DSN=%s;", _dsn);
} }
@@ -897,7 +829,33 @@ void ODBCMySQLTest::tearDown()
} }
bool ODBCMySQLTest::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
return true;
}
CppUnit::Test* ODBCMySQLTest::suite() CppUnit::Test* ODBCMySQLTest::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest");
@@ -944,3 +902,6 @@ CppUnit::Test* ODBCMySQLTest::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -113,7 +113,6 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
void recreatePersonBLOBTable(); void recreatePersonBLOBTable();
@@ -123,9 +122,10 @@ private:
void recreateTuplesTable(); void recreateTuplesTable();
void recreateVectorsTable(); void recreateVectorsTable();
static bool checkODBCSetup(const std::string& dbName = "MySQL");
static bool init(const std::string& dbName = "MySQL");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static Poco::Data::ODBC::Utility::DSNMap _dataSources;
static std::string _dsn;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;
static Poco::SharedPtr<SQLExecutor> _pExecutor; static Poco::SharedPtr<SQLExecutor> _pExecutor;

View File

@@ -60,46 +60,13 @@ using Poco::NotFoundException;
const bool ODBCOracleTest::bindValues[8] = {true, true, true, false, false, true, false, false}; const bool ODBCOracleTest::bindValues[8] = {true, true, true, false, false, true, false, false};
Poco::SharedPtr<Poco::Data::Session> ODBCOracleTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> ODBCOracleTest::_pSession = 0;
Poco::SharedPtr<SQLExecutor> ODBCOracleTest::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> ODBCOracleTest::_pExecutor = 0;
std::string ODBCOracleTest::_dsn = "PocoDataOracleTest";
std::string ODBCOracleTest::_dbConnString; std::string ODBCOracleTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCOracleTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCOracleTest::_drivers;
Poco::Data::ODBC::Utility::DSNMap ODBCOracleTest::_dataSources;
ODBCOracleTest::ODBCOracleTest(const std::string& name): ODBCOracleTest::ODBCOracleTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
if (_drivers.empty() || _dataSources.empty())
{
Utility::drivers(_drivers);
Utility::dataSources(_dataSources);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. Oracle tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << _dsn << '(' << _dbConnString << ')' << std::endl;
if (!_pExecutor)
_pExecutor = new SQLExecutor("Oracle SQL Executor", _pSession);
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. Oracle tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -829,58 +796,28 @@ void ODBCOracleTest::recreateVectorsTable()
} }
void ODBCOracleTest::checkODBCSetup() bool ODBCOracleTest::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false;
if (!beenHere)
{
beenHere = true;
bool driverFound = false;
bool dsnFound = false;
Utility::DriverMap::iterator itDrv = _drivers.begin(); Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv) for (; itDrv != _drivers.end(); ++itDrv)
{ {
if (((itDrv->first).find("Oracle") != std::string::npos) && if (((itDrv->first).find(dbName) != std::string::npos))
((itDrv->first).find("Microsoft") == std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "Oracle driver NOT found, tests will fail." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
return; return false;
} }
Utility::DSNMap::iterator itDSN = _dataSources.begin(); _dbConnString = "DSN=PocoDataOracleTest;Uid=Scott;Pwd=Tiger;";
for (; itDSN != _dataSources.end(); ++itDSN)
{
if (((itDSN->first).find(_dsn) != std::string::npos) &&
((itDSN->second).find("Oracle") != std::string::npos))
{
std::cout << "DSN found: " << itDSN->first
<< " (" << itDSN->second << ')' << std::endl;
dsnFound = true;
break;
}
}
if (!dsnFound) return true;
{
std::cout << "Oracle DSN NOT found, tests will fail." << std::endl;
return;
}
}
if (!_pSession)
format(_dbConnString, "DSN=%s;Uid=Scott;Pwd=Tiger;", _dsn);
} }
@@ -896,7 +833,33 @@ void ODBCOracleTest::tearDown()
} }
bool ODBCOracleTest::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
return true;
}
CppUnit::Test* ODBCOracleTest::suite() CppUnit::Test* ODBCOracleTest::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCOracleTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCOracleTest");
@@ -943,3 +906,6 @@ CppUnit::Test* ODBCOracleTest::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -112,7 +112,6 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
void recreatePersonBLOBTable(); void recreatePersonBLOBTable();
@@ -122,9 +121,10 @@ private:
void recreateTuplesTable(); void recreateTuplesTable();
void recreateVectorsTable(); void recreateVectorsTable();
static bool checkODBCSetup(const std::string& dbName = "Oracle");
static bool init(const std::string& dbName = "Oracle");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static Poco::Data::ODBC::Utility::DSNMap _dataSources;
static std::string _dsn;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;
static Poco::SharedPtr<SQLExecutor> _pExecutor; static Poco::SharedPtr<SQLExecutor> _pExecutor;

View File

@@ -60,46 +60,13 @@ using Poco::NotFoundException;
const bool ODBCPostgreSQLTest::bindValues[8] = {true, true, true, false, false, true, false, false}; const bool ODBCPostgreSQLTest::bindValues[8] = {true, true, true, false, false, true, false, false};
Poco::SharedPtr<Poco::Data::Session> ODBCPostgreSQLTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> ODBCPostgreSQLTest::_pSession = 0;
Poco::SharedPtr<SQLExecutor> ODBCPostgreSQLTest::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> ODBCPostgreSQLTest::_pExecutor = 0;
std::string ODBCPostgreSQLTest::_dsn = "PocoDataPgSQLTest";
std::string ODBCPostgreSQLTest::_dbConnString; std::string ODBCPostgreSQLTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCPostgreSQLTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCPostgreSQLTest::_drivers;
Poco::Data::ODBC::Utility::DSNMap ODBCPostgreSQLTest::_dataSources;
ODBCPostgreSQLTest::ODBCPostgreSQLTest(const std::string& name): ODBCPostgreSQLTest::ODBCPostgreSQLTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
if (_drivers.empty() || _dataSources.empty())
{
Utility::drivers(_drivers);
Utility::dataSources(_dataSources);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. PostgreSQL tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << _dsn << '(' << _dbConnString << ')' << std::endl;
if (!_pExecutor)
_pExecutor = new SQLExecutor("PostgreSQL SQL Executor", _pSession);
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. PostgreSQL tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -815,57 +782,63 @@ void ODBCPostgreSQLTest::recreateVectorsTable()
} }
void ODBCPostgreSQLTest::checkODBCSetup() bool ODBCPostgreSQLTest::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false;
if (!beenHere)
{
beenHere = true;
bool driverFound = false;
bool dsnFound = false;
Utility::DriverMap::iterator itDrv = _drivers.begin(); Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv) for (; itDrv != _drivers.end(); ++itDrv)
{ {
if (((itDrv->first).find("PostgreSQL") != std::string::npos)) if (((itDrv->first).find(dbName) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "PostgreSQL driver NOT found, tests will fail." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
return; return false;
} }
Utility::DSNMap::iterator itDSN = _dataSources.begin(); _dbConnString = "DRIVER=PostgreSQL ANSI;"
for (; itDSN != _dataSources.end(); ++itDSN) "DATABASE=postgres;"
{ "SERVER=localhost;"
if (((itDSN->first).find(_dsn) != std::string::npos) && "PORT=5432;"
((itDSN->second).find("PostgreSQL") != std::string::npos)) "UID=postgres;"
{ "PWD=postgres;"
std::cout << "DSN found: " << itDSN->first "SSLMODE=prefer;"
<< " (" << itDSN->second << ')' << std::endl; "LowerCaseIdentifier=0;"
dsnFound = true; "UseServerSidePrepare=0;"
break; "ByteaAsLongVarBinary=1;"
} "BI=0;"
} "TrueIsMinus1=0;"
"DisallowPremature=0;"
"UpdatableCursors=0;"
"LFConversion=1;"
"CancelAsFreeStmt=0;"
"Parse=0;"
"BoolsAsChar=1;"
"UnknownsAsLongVarchar=0;"
"TextAsLongVarchar=1;"
"UseDeclareFetch=0;"
"Ksqo=1;"
"Optimizer=1;"
"CommLog=0;"
"Debug=0;"
"MaxLongVarcharSize=8190;"
"MaxVarcharSize=254;"
"UnknownSizes=0;"
"Socket=8192;"
"Fetch=100;"
"ConnSettings=;"
"ShowSystemTables=0;"
"RowVersioning=0;"
"ShowOidColumn=0;"
"FakeOidIndex=0;"
"ReadOnly=0;";
if (!dsnFound) return true;
{
std::cout << "PostgreSQL DSN NOT found, tests will fail." << std::endl;
return;
}
}
if (!_pSession)
format(_dbConnString, "DSN=%s;", _dsn);
} }
@@ -881,7 +854,33 @@ void ODBCPostgreSQLTest::tearDown()
} }
bool ODBCPostgreSQLTest::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
return true;
}
CppUnit::Test* ODBCPostgreSQLTest::suite() CppUnit::Test* ODBCPostgreSQLTest::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest");
@@ -928,3 +927,6 @@ CppUnit::Test* ODBCPostgreSQLTest::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -113,7 +113,6 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
void recreatePersonBLOBTable(); void recreatePersonBLOBTable();
@@ -123,9 +122,10 @@ private:
void recreateTuplesTable(); void recreateTuplesTable();
void recreateVectorsTable(); void recreateVectorsTable();
static bool init(const std::string& dbName = "PostgreSQL");
static bool checkODBCSetup(const std::string& dbName = "PostgreSQL");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static Poco::Data::ODBC::Utility::DSNMap _dataSources;
static std::string _dsn;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;
static Poco::SharedPtr<SQLExecutor> _pExecutor; static Poco::SharedPtr<SQLExecutor> _pExecutor;

View File

@@ -60,47 +60,14 @@ using Poco::NotFoundException;
const bool ODBCSQLServerTest::bindValues[8] = {true, true, true, false, false, true, false, false}; const bool ODBCSQLServerTest::bindValues[8] = {true, true, true, false, false, true, false, false};
Poco::SharedPtr<Poco::Data::Session> ODBCSQLServerTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> ODBCSQLServerTest::_pSession = 0;
Poco::SharedPtr<SQLExecutor> ODBCSQLServerTest::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> ODBCSQLServerTest::_pExecutor = 0;
std::string ODBCSQLServerTest::_dsn = "PocoDataSQLServerTest";
std::string ODBCSQLServerTest::_dbConnString; std::string ODBCSQLServerTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCSQLServerTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCSQLServerTest::_drivers;
Poco::Data::ODBC::Utility::DSNMap ODBCSQLServerTest::_dataSources;
ODBCSQLServerTest::ODBCSQLServerTest(const std::string& name): ODBCSQLServerTest::ODBCSQLServerTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
if (_drivers.empty() || _dataSources.empty())
{
Utility::drivers(_drivers);
Utility::dataSources(_dataSources);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. SQL Server tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << _dsn << '(' << _dbConnString << ')' << std::endl;
if (!_pExecutor)
_pExecutor = new SQLExecutor("SQLServer SQL Executor", _pSession);
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. SQL Server tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -842,58 +809,32 @@ void ODBCSQLServerTest::recreateVectorsTable()
} }
void ODBCSQLServerTest::checkODBCSetup() bool ODBCSQLServerTest::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false;
if (!beenHere)
{
beenHere = true;
bool driverFound = false;
bool dsnFound = false;
Utility::DriverMap::iterator itDrv = _drivers.begin(); Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv) for (; itDrv != _drivers.end(); ++itDrv)
{ {
if (((itDrv->first).find("SQL Server") != std::string::npos)) if (((itDrv->first).find(dbName) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "SQL Server driver NOT found, tests will fail." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
return; return false;
} }
Utility::DSNMap::iterator itDSN = _dataSources.begin(); _dbConnString = "DRIVER=SQL Server;"
for (; itDSN != _dataSources.end(); ++itDSN) "UID=test;"
{ "PWD=test;"
if (((itDSN->first).find(_dsn) != std::string::npos) && "DATABASE=test;"
(((itDSN->second).find("SQL Server") != std::string::npos) || "SERVER=(local);";
((itDSN->second).find("SQL Native Client") != std::string::npos)))
{
std::cout << "DSN found: " << itDSN->first
<< " (" << itDSN->second << ')' << std::endl;
dsnFound = true;
break;
}
}
if (!dsnFound) return true;
{
std::cout << "SQL Server DSN NOT found, tests will fail." << std::endl;
return;
}
}
if (!_pSession)
format(_dbConnString, "DSN=%s;Uid=test;Pwd=test;", _dsn);
} }
@@ -909,7 +850,33 @@ void ODBCSQLServerTest::tearDown()
} }
bool ODBCSQLServerTest::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
return true;
}
CppUnit::Test* ODBCSQLServerTest::suite() CppUnit::Test* ODBCSQLServerTest::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLServerTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLServerTest");
@@ -956,3 +923,6 @@ CppUnit::Test* ODBCSQLServerTest::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -114,7 +114,6 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
void recreatePersonBLOBTable(); void recreatePersonBLOBTable();
@@ -125,9 +124,10 @@ private:
void recreateVectorTable(); void recreateVectorTable();
void recreateVectorsTable(); void recreateVectorsTable();
static bool checkODBCSetup(const std::string& dbName = "SQL Server");
static bool init(const std::string& dbName = "SQL Server");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static Poco::Data::ODBC::Utility::DSNMap _dataSources;
static std::string _dsn;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;
static Poco::SharedPtr<SQLExecutor> _pExecutor; static Poco::SharedPtr<SQLExecutor> _pExecutor;

View File

@@ -67,36 +67,6 @@ Poco::Data::ODBC::Utility::DriverMap ODBCSQLiteTest::_drivers;
ODBCSQLiteTest::ODBCSQLiteTest(const std::string& name): ODBCSQLiteTest::ODBCSQLiteTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
static bool beenHere = false;
if (_drivers.empty())
{
Utility::drivers(_drivers);
checkODBCSetup();
}
if (!_pSession && !_dbConnString.empty() && !beenHere)
{
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(ODBC::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. SQLite tests will fail !!!" << std::endl;
std::cout << ex.toString() << std::endl;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << _dbConnString << std::endl;
if (!_pExecutor)
_pExecutor = new SQLExecutor("SQLite SQL Executor", _pSession);
}
else
if (!_pSession && !beenHere)
std::cout << "!!! WARNING: No driver or DSN found. SQLite tests will fail !!!" << std::endl;
beenHere = true;
} }
@@ -808,37 +778,28 @@ void ODBCSQLiteTest::recreateVectorsTable()
} }
void ODBCSQLiteTest::checkODBCSetup() bool ODBCSQLiteTest::checkODBCSetup(const std::string& dbName)
{ {
static bool beenHere = false; Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv)
if (!beenHere)
{ {
beenHere = true; if (((itDrv->first).find(dbName) != std::string::npos))
bool driverFound = false;
Utility::DriverMap::iterator itDriver = _drivers.begin();
for (; itDriver != _drivers.end(); ++itDriver)
{ {
if (((itDriver->first).find("SQLite3") != std::string::npos)) std::cout << "Driver found: " << itDrv->first
{ << " (" << itDrv->second << ')' << std::endl;
std::cout << "Driver found: " << itDriver->first
<< " (" << itDriver->second << ')' << std::endl;
driverFound = true;
break; break;
} }
} }
if (!driverFound) if (_drivers.end() == itDrv)
{ {
std::cout << "SQLite3 driver NOT found, tests will fail." << std::endl; std::cout << dbName << " driver NOT found, tests not available." << std::endl;
return; return false;
}
} }
if (!_pSession)
_dbConnString = "Driver=SQLite3 ODBC Driver;Database=dummy.db;"; _dbConnString = "Driver=SQLite3 ODBC Driver;Database=dummy.db;";
return true;
} }
@@ -854,7 +815,33 @@ void ODBCSQLiteTest::tearDown()
} }
bool ODBCSQLiteTest::init(const std::string& dbName)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
ODBC::Connector::registerConnector();
try
{
_pSession = new Session(ODBC::Connector::KEY, _dbConnString);
}catch (ConnectionException& ex)
{
std::cout << ex.toString() << std::endl;
return false;
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
return true;
}
CppUnit::Test* ODBCSQLiteTest::suite() CppUnit::Test* ODBCSQLiteTest::suite()
{
if (init())
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLiteTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLiteTest");
@@ -901,3 +888,6 @@ CppUnit::Test* ODBCSQLiteTest::suite()
return pSuite; return pSuite;
} }
return 0;
}

View File

@@ -111,7 +111,6 @@ public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
void checkODBCSetup();
void dropTable(const std::string& tableName); void dropTable(const std::string& tableName);
void recreatePersonTable(); void recreatePersonTable();
void recreatePersonBLOBTable(); void recreatePersonBLOBTable();
@@ -121,6 +120,9 @@ private:
void recreateTuplesTable(); void recreateTuplesTable();
void recreateVectorsTable(); void recreateVectorsTable();
static bool checkODBCSetup(const std::string& dbName = "SQLite3");
static bool init(const std::string& dbName = "SQLite3");
static Poco::Data::ODBC::Utility::DriverMap _drivers; static Poco::Data::ODBC::Utility::DriverMap _drivers;
static std::string _dbConnString; static std::string _dbConnString;
static Poco::SharedPtr<Poco::Data::Session> _pSession; static Poco::SharedPtr<Poco::Data::Session> _pSession;

View File

@@ -38,14 +38,15 @@
#include "ODBCSQLiteTest.h" #include "ODBCSQLiteTest.h"
#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(POCO_OS_FAMILY_WINDOWS)
#include "ODBCAccessTest.h" #include "ODBCAccessTest.h"
#include "ODBCSQLServerTest.h"
#endif #endif
#include "ODBCSQLServerTest.h"
CppUnit::Test* ODBCTestSuite::suite() CppUnit::Test* ODBCTestSuite::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCTestSuite"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCTestSuite");
//!FIXME // WARNING!
// On Win XP Pro: // On Win XP Pro:
// //
// 1) The PostgreSQL connection fails if attempted after DB2 w/ following error: // 1) The PostgreSQL connection fails if attempted after DB2 w/ following error:
@@ -54,20 +55,26 @@ CppUnit::Test* ODBCTestSuite::suite()
// message="Specified driver could not be loaded due to system error 127 (PostgreSQL ANSI)." // message="Specified driver could not be loaded due to system error 127 (PostgreSQL ANSI)."
// nativeError=160 // nativeError=160
// System error 127 is "The specified procedure could not be found." // System error 127 is "The specified procedure could not be found."
// Workaround is to connect to PostgreSQL prior to connecting to DB2.
// //
// 2) When Oracle test is loaded after DB2, the test application does not exit cleanly. // 2) When Oracle test is loaded after DB2, the test application does not exit cleanly.
// All tests pass, though. // All tests pass, though.
// //
// Workaround is to connect to DB2 after connecting to PostgreSQL and Oracle.
// The reason causing these errors is not known.
addTest(pSuite, ODBCOracleTest::suite());
addTest(pSuite, ODBCPostgreSQLTest::suite());
addTest(pSuite, ODBCDB2Test::suite());
addTest(pSuite, ODBCMySQLTest::suite());
addTest(pSuite, ODBCSQLiteTest::suite());
addTest(pSuite, ODBCAccessTest::suite());
addTest(pSuite, ODBCSQLServerTest::suite());
pSuite->addTest(ODBCOracleTest::suite());
pSuite->addTest(ODBCPostgreSQLTest::suite());
pSuite->addTest(ODBCDB2Test::suite());
pSuite->addTest(ODBCMySQLTest::suite());
pSuite->addTest(ODBCSQLiteTest::suite());
#if defined(POCO_OS_FAMILY_WINDOWS)
pSuite->addTest(ODBCAccessTest::suite());
pSuite->addTest(ODBCSQLServerTest::suite());
#endif
return pSuite; return pSuite;
} }
void ODBCTestSuite::addTest(CppUnit::TestSuite* pSuite, CppUnit::Test* pT)
{
if (pSuite && pT) pSuite->addTest(pT);
}

View File

@@ -43,6 +43,9 @@ class ODBCTestSuite
{ {
public: public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private:
static void addTest(CppUnit::TestSuite* pSuite, CppUnit::Test* pT);
}; };

View File

@@ -518,7 +518,6 @@ void SQLExecutor::complexType()
assert (count == 2); assert (count == 2);
Person c1; Person c1;
Person c2;
try { *_pSession << "SELECT * FROM PERSON WHERE LastName = 'LN1'", into(c1), now; } try { *_pSession << "SELECT * FROM PERSON WHERE LastName = 'LN1'", into(c1), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }