mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 02:06:04 +02:00
Tests tidy-up, DSN-less connections, preparation ODBCColumn pos fix
This commit is contained in:
@@ -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&)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
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;
|
|
||||||
bool dsnFound = false;
|
|
||||||
|
|
||||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
|
||||||
for (; itDrv != _drivers.end(); ++itDrv)
|
|
||||||
{
|
{
|
||||||
if (((itDrv->first).find("Microsoft Access Driver") != std::string::npos))
|
std::cout << "Driver found: " << itDrv->first
|
||||||
{
|
<< " (" << itDrv->second << ')' << std::endl;
|
||||||
std::cout << "Driver found: " << itDrv->first
|
break;
|
||||||
<< " (" << itDrv->second << ')' << std::endl;
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "Driver NOT found, will throw." << std::endl;
|
|
||||||
throw NotFoundException("Microsoft Access ODBC driver.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DSNMap::iterator itDSN = _dataSources.begin();
|
|
||||||
for (; itDSN != _dataSources.end(); ++itDSN)
|
|
||||||
{
|
|
||||||
if (((itDSN->first).find(_dsn) != std::string::npos) &&
|
|
||||||
((itDSN->second).find("Microsoft Access Driver") != std::string::npos))
|
|
||||||
{
|
|
||||||
std::cout << "DSN found: " << itDSN->first
|
|
||||||
<< " (" << itDSN->second << ')' << std::endl;
|
|
||||||
dsnFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dsnFound)
|
|
||||||
{
|
|
||||||
std::cout << "Access DSN NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
format(_dbConnString, "DSN=%s;Uid=Admin;Pwd=;", _dsn);
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "DRIVER=Microsoft Access Driver (*.mdb);"
|
||||||
|
"UID=admin;"
|
||||||
|
"UserCommitSync=Yes;"
|
||||||
|
"Threads=3;"
|
||||||
|
"SafeTransactions=0;"
|
||||||
|
"PageTimeout=5;"
|
||||||
|
"MaxScanRows=8;"
|
||||||
|
"MaxBufferSize=2048;"
|
||||||
|
"FIL=MS Access;"
|
||||||
|
"DriverId=25;"
|
||||||
|
"DefaultDir=C:\\;"
|
||||||
|
"DBQ=C:\\test.mdb;";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,11 +186,38 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCAccessTest");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCAccessTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCAccessTest, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCAccessTest, testSimpleAccess);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
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;
|
|
||||||
bool dsnFound = false;
|
|
||||||
|
|
||||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
|
||||||
for (; itDrv != _drivers.end(); ++itDrv)
|
|
||||||
{
|
{
|
||||||
if (((itDrv->first).find("IBM DB2") != std::string::npos))
|
std::cout << "Driver found: " << itDrv->first
|
||||||
{
|
<< " (" << itDrv->second << ')' << std::endl;
|
||||||
std::cout << "Driver found: " << itDrv->first
|
break;
|
||||||
<< " (" << itDrv->second << ')' << std::endl;
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "DB2 driver NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DSNMap::iterator itDSN = _dataSources.begin();
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
std::cout << "DB2 DSN NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
format(_dbConnString, "DSN=%s;Uid=db2admin;Pwd=db2admin;", _dsn);
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "DSN=PocoDataDB2Test;Uid=db2admin;Pwd=db2admin;";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -898,50 +836,79 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCDB2Test");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCDB2Test");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testBareboneODBC);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testBareboneODBC);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSimpleAccess);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testComplexType);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testComplexType);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSimpleAccessVector);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSimpleAccessVector);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testComplexTypeVector);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testComplexTypeVector);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertVector);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertVector);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertEmptyVector);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertEmptyVector);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertSingleBulk);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertSingleBulk);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertSingleBulkVec);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testInsertSingleBulkVec);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testLimit);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testLimit);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testLimitOnce);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testLimitOnce);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testLimitPrepare);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testLimitPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testLimitZero);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testLimitZero);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testPrepare);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSetSimple);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSetComplex);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSetComplexUnique);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSetComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testMultiSetSimple);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testMultiSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testMultiSetComplex);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testMultiSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testMapComplex);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testMapComplexUnique);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testMapComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testMultiMapComplex);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testMultiMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSelectIntoSingle);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSelectIntoSingle);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSelectIntoSingleStep);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSelectIntoSingleStep);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSelectIntoSingleFail);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSelectIntoSingleFail);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testLowerLimitOk);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testLowerLimitOk);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testLowerLimitFail);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testLowerLimitFail);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testCombinedLimits);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testCombinedLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testCombinedIllegalLimits);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testCombinedIllegalLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testRange);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testRange);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testIllegalRange);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testSingleSelect);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testEmptyDB);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testEmptyDB);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testBLOB);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testBLOB);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testBLOBStmt);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testBLOBStmt);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testFloat);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testFloat);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testDouble);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testDouble);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testTuple);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testTuple);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testTupleVector);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testTupleVector);
|
||||||
CppUnit_addTest(pSuite, ODBCDB2Test, testInternalExtraction);
|
CppUnit_addTest(pSuite, ODBCDB2Test, testInternalExtraction);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
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;
|
|
||||||
bool dsnFound = false;
|
|
||||||
|
|
||||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
|
||||||
for (; itDrv != _drivers.end(); ++itDrv)
|
|
||||||
{
|
{
|
||||||
if (((itDrv->first).find("MySQL") != std::string::npos))
|
std::cout << "Driver found: " << itDrv->first
|
||||||
{
|
<< " (" << itDrv->second << ')' << std::endl;
|
||||||
std::cout << "Driver found: " << itDrv->first
|
break;
|
||||||
<< " (" << itDrv->second << ')' << std::endl;
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "MySQL driver NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DSNMap::iterator itDSN = _dataSources.begin();
|
|
||||||
for (; itDSN != _dataSources.end(); ++itDSN)
|
|
||||||
{
|
|
||||||
if (((itDSN->first).find(_dsn) != std::string::npos) &&
|
|
||||||
((itDSN->second).find("MySQL") != std::string::npos))
|
|
||||||
{
|
|
||||||
std::cout << "DSN found: " << itDSN->first
|
|
||||||
<< " (" << itDSN->second << ')' << std::endl;
|
|
||||||
dsnFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dsnFound)
|
|
||||||
{
|
|
||||||
std::cout << "SQL Server DSN NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
format(_dbConnString, "DSN=%s;", _dsn);
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "DRIVER=MySQL ODBC 3.51 Driver;"
|
||||||
|
"DATABASE=test;"
|
||||||
|
"SERVER=localhost;"
|
||||||
|
"UID=root;"
|
||||||
|
"PWD=mysql;";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -897,50 +829,79 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testBareboneODBC);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testBareboneODBC);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSimpleAccess);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexType);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexType);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSimpleAccessVector);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSimpleAccessVector);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexTypeVector);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexTypeVector);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertVector);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertVector);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertEmptyVector);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertEmptyVector);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertSingleBulk);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertSingleBulk);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertSingleBulkVec);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertSingleBulkVec);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimit);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimit);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitOnce);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitOnce);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitPrepare);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitZero);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitZero);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testPrepare);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetSimple);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetComplex);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetComplexUnique);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testMultiSetSimple);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testMultiSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testMultiSetComplex);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testMultiSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testMapComplex);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testMapComplexUnique);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testMapComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testMultiMapComplex);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testMultiMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSelectIntoSingle);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSelectIntoSingle);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSelectIntoSingleStep);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSelectIntoSingleStep);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSelectIntoSingleFail);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSelectIntoSingleFail);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testLowerLimitOk);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testLowerLimitOk);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testLowerLimitFail);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testLowerLimitFail);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testCombinedLimits);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testCombinedLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testCombinedIllegalLimits);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testCombinedIllegalLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testRange);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testRange);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testIllegalRange);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testSingleSelect);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testEmptyDB);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testEmptyDB);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testBLOB);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testBLOB);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testBLOBStmt);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testBLOBStmt);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testFloat);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testFloat);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testDouble);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testDouble);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testTuple);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testTuple);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testTupleVector);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testTupleVector);
|
||||||
CppUnit_addTest(pSuite, ODBCMySQLTest, testInternalExtraction);
|
CppUnit_addTest(pSuite, ODBCMySQLTest, testInternalExtraction);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
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;
|
|
||||||
bool dsnFound = false;
|
|
||||||
|
|
||||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
|
||||||
for (; itDrv != _drivers.end(); ++itDrv)
|
|
||||||
{
|
{
|
||||||
if (((itDrv->first).find("Oracle") != std::string::npos) &&
|
std::cout << "Driver found: " << itDrv->first
|
||||||
((itDrv->first).find("Microsoft") == std::string::npos))
|
<< " (" << itDrv->second << ')' << std::endl;
|
||||||
{
|
break;
|
||||||
std::cout << "Driver found: " << itDrv->first
|
|
||||||
<< " (" << itDrv->second << ')' << std::endl;
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "Oracle driver NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DSNMap::iterator itDSN = _dataSources.begin();
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
std::cout << "Oracle DSN NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
format(_dbConnString, "DSN=%s;Uid=Scott;Pwd=Tiger;", _dsn);
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "DSN=PocoDataOracleTest;Uid=Scott;Pwd=Tiger;";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -896,50 +833,79 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCOracleTest");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCOracleTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testBareboneODBC);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testBareboneODBC);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSimpleAccess);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testComplexType);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testComplexType);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSimpleAccessVector);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSimpleAccessVector);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testComplexTypeVector);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testComplexTypeVector);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertVector);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertVector);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertEmptyVector);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertEmptyVector);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertSingleBulk);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertSingleBulk);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertSingleBulkVec);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testInsertSingleBulkVec);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testLimit);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testLimit);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testLimitOnce);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testLimitOnce);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testLimitPrepare);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testLimitPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testLimitZero);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testLimitZero);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testPrepare);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSetSimple);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSetComplex);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSetComplexUnique);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSetComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testMultiSetSimple);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testMultiSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testMultiSetComplex);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testMultiSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testMapComplex);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testMapComplexUnique);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testMapComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testMultiMapComplex);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testMultiMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSelectIntoSingle);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSelectIntoSingle);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSelectIntoSingleStep);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSelectIntoSingleStep);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSelectIntoSingleFail);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSelectIntoSingleFail);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testLowerLimitOk);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testLowerLimitOk);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testLowerLimitFail);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testLowerLimitFail);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testCombinedLimits);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testCombinedLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testCombinedIllegalLimits);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testCombinedIllegalLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testRange);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testRange);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testIllegalRange);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testSingleSelect);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testEmptyDB);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testEmptyDB);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testBLOB);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testBLOB);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testBLOBStmt);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testBLOBStmt);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testFloat);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testFloat);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testDouble);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testDouble);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testTuple);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testTuple);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testTupleVector);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testTupleVector);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testInternalExtraction);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testInternalExtraction);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
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;
|
|
||||||
bool dsnFound = false;
|
|
||||||
|
|
||||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
|
||||||
for (; itDrv != _drivers.end(); ++itDrv)
|
|
||||||
{
|
{
|
||||||
if (((itDrv->first).find("PostgreSQL") != std::string::npos))
|
std::cout << "Driver found: " << itDrv->first
|
||||||
{
|
<< " (" << itDrv->second << ')' << std::endl;
|
||||||
std::cout << "Driver found: " << itDrv->first
|
break;
|
||||||
<< " (" << itDrv->second << ')' << std::endl;
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "PostgreSQL driver NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DSNMap::iterator itDSN = _dataSources.begin();
|
|
||||||
for (; itDSN != _dataSources.end(); ++itDSN)
|
|
||||||
{
|
|
||||||
if (((itDSN->first).find(_dsn) != std::string::npos) &&
|
|
||||||
((itDSN->second).find("PostgreSQL") != std::string::npos))
|
|
||||||
{
|
|
||||||
std::cout << "DSN found: " << itDSN->first
|
|
||||||
<< " (" << itDSN->second << ')' << std::endl;
|
|
||||||
dsnFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dsnFound)
|
|
||||||
{
|
|
||||||
std::cout << "PostgreSQL DSN NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
format(_dbConnString, "DSN=%s;", _dsn);
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "DRIVER=PostgreSQL ANSI;"
|
||||||
|
"DATABASE=postgres;"
|
||||||
|
"SERVER=localhost;"
|
||||||
|
"PORT=5432;"
|
||||||
|
"UID=postgres;"
|
||||||
|
"PWD=postgres;"
|
||||||
|
"SSLMODE=prefer;"
|
||||||
|
"LowerCaseIdentifier=0;"
|
||||||
|
"UseServerSidePrepare=0;"
|
||||||
|
"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;";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -881,50 +854,79 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testBareboneODBC);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testBareboneODBC);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSimpleAccess);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexType);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexType);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSimpleAccessVector);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSimpleAccessVector);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexTypeVector);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexTypeVector);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertVector);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertVector);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertEmptyVector);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertEmptyVector);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertSingleBulk);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertSingleBulk);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertSingleBulkVec);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertSingleBulkVec);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimit);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimit);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimitOnce);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimitOnce);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimitPrepare);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimitPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimitZero);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimitZero);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testPrepare);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSetSimple);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSetComplex);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSetComplexUnique);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSetComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMultiSetSimple);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMultiSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMultiSetComplex);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMultiSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMapComplex);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMapComplexUnique);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMapComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMultiMapComplex);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testMultiMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSelectIntoSingle);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSelectIntoSingle);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSelectIntoSingleStep);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSelectIntoSingleStep);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSelectIntoSingleFail);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSelectIntoSingleFail);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLowerLimitOk);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLowerLimitOk);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLowerLimitFail);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLowerLimitFail);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testCombinedLimits);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testCombinedLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testCombinedIllegalLimits);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testCombinedIllegalLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testRange);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testRange);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testIllegalRange);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSingleSelect);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testEmptyDB);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testEmptyDB);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testBLOB);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testBLOB);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testBLOBStmt);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testBLOBStmt);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testFloat);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testFloat);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testDouble);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testDouble);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testTuple);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testTuple);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testTupleVector);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testTupleVector);
|
||||||
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInternalExtraction);
|
CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInternalExtraction);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
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;
|
|
||||||
bool dsnFound = false;
|
|
||||||
|
|
||||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
|
||||||
for (; itDrv != _drivers.end(); ++itDrv)
|
|
||||||
{
|
{
|
||||||
if (((itDrv->first).find("SQL Server") != std::string::npos))
|
std::cout << "Driver found: " << itDrv->first
|
||||||
{
|
<< " (" << itDrv->second << ')' << std::endl;
|
||||||
std::cout << "Driver found: " << itDrv->first
|
break;
|
||||||
<< " (" << itDrv->second << ')' << std::endl;
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "SQL Server driver NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DSNMap::iterator itDSN = _dataSources.begin();
|
|
||||||
for (; itDSN != _dataSources.end(); ++itDSN)
|
|
||||||
{
|
|
||||||
if (((itDSN->first).find(_dsn) != std::string::npos) &&
|
|
||||||
(((itDSN->second).find("SQL Server") != std::string::npos) ||
|
|
||||||
((itDSN->second).find("SQL Native Client") != std::string::npos)))
|
|
||||||
{
|
|
||||||
std::cout << "DSN found: " << itDSN->first
|
|
||||||
<< " (" << itDSN->second << ')' << std::endl;
|
|
||||||
dsnFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dsnFound)
|
|
||||||
{
|
|
||||||
std::cout << "SQL Server DSN NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
format(_dbConnString, "DSN=%s;Uid=test;Pwd=test;", _dsn);
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "DRIVER=SQL Server;"
|
||||||
|
"UID=test;"
|
||||||
|
"PWD=test;"
|
||||||
|
"DATABASE=test;"
|
||||||
|
"SERVER=(local);";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -909,50 +850,79 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLServerTest");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLServerTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBareboneODBC);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBareboneODBC);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSimpleAccess);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexType);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexType);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSimpleAccessVector);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSimpleAccessVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexTypeVector);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexTypeVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertVector);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertEmptyVector);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertEmptyVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertSingleBulk);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertSingleBulk);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertSingleBulkVec);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertSingleBulkVec);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimit);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimit);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimitOnce);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimitOnce);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimitPrepare);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimitPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimitZero);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimitZero);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testPrepare);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSetSimple);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSetComplex);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSetComplexUnique);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSetComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMultiSetSimple);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMultiSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMultiSetComplex);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMultiSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMapComplex);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMapComplexUnique);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMapComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMultiMapComplex);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testMultiMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSelectIntoSingle);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSelectIntoSingle);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSelectIntoSingleStep);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSelectIntoSingleStep);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSelectIntoSingleFail);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSelectIntoSingleFail);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLowerLimitOk);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLowerLimitOk);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLowerLimitFail);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testLowerLimitFail);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testCombinedLimits);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testCombinedLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testCombinedIllegalLimits);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testCombinedIllegalLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testRange);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testRange);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testIllegalRange);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSingleSelect);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testEmptyDB);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testEmptyDB);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOB);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOB);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOBStmt);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testBLOBStmt);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testFloat);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testFloat);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testDouble);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testDouble);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testTuple);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testTuple);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testTupleVector);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testTupleVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInternalExtraction);
|
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInternalExtraction);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
break;
|
||||||
<< " (" << itDriver->second << ')' << std::endl;
|
|
||||||
|
|
||||||
driverFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!driverFound)
|
|
||||||
{
|
|
||||||
std::cout << "SQLite3 driver NOT found, tests will fail." << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_pSession)
|
if (_drivers.end() == itDrv)
|
||||||
_dbConnString = "Driver=SQLite3 ODBC Driver;Database=dummy.db;";
|
{
|
||||||
|
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dbConnString = "Driver=SQLite3 ODBC Driver;Database=dummy.db;";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -854,50 +815,79 @@ 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()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLiteTest");
|
if (init())
|
||||||
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLiteTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testBareboneODBC);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testBareboneODBC);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSimpleAccess);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSimpleAccess);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexType);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexType);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSimpleAccessVector);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSimpleAccessVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexTypeVector);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexTypeVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertVector);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertEmptyVector);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertEmptyVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertSingleBulk);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertSingleBulk);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertSingleBulkVec);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertSingleBulkVec);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimit);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimit);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimitOnce);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimitOnce);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimitPrepare);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimitPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimitZero);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimitZero);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testPrepare);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testPrepare);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSetSimple);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSetComplex);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSetComplexUnique);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSetComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMultiSetSimple);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMultiSetSimple);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMultiSetComplex);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMultiSetComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMapComplex);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMapComplexUnique);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMapComplexUnique);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMultiMapComplex);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testMultiMapComplex);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSelectIntoSingle);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSelectIntoSingle);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSelectIntoSingleStep);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSelectIntoSingleStep);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSelectIntoSingleFail);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSelectIntoSingleFail);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLowerLimitOk);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLowerLimitOk);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLowerLimitFail);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testLowerLimitFail);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testCombinedLimits);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testCombinedLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testCombinedIllegalLimits);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testCombinedIllegalLimits);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testRange);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testRange);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testIllegalRange);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testIllegalRange);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSingleSelect);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testSingleSelect);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testEmptyDB);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testEmptyDB);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testBLOB);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testBLOB);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testBLOBStmt);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testBLOBStmt);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testFloat);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testFloat);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testDouble);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testDouble);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testTuple);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testTuple);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testTupleVector);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testTupleVector);
|
||||||
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInternalExtraction);
|
CppUnit_addTest(pSuite, ODBCSQLiteTest, testInternalExtraction);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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); }
|
||||||
|
|||||||
Reference in New Issue
Block a user