mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-26 00:20:34 +01:00
PostgreSQL: added test case for failed connection attempt.
This commit is contained in:
parent
c7b6fa17be
commit
148affed30
Data/PostgreSQL/testsuite/src
@ -140,6 +140,33 @@ void PostgreSQLTest::testConnectNoDB()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PostgreSQLTest::testFailedConnect()
|
||||
{
|
||||
std::string dbConnString;
|
||||
dbConnString += "host=" + getHost();
|
||||
dbConnString += " user=invalid";
|
||||
dbConnString += " password=invalid";
|
||||
dbConnString += " port=" + getPort();
|
||||
|
||||
Poco::SharedPtr<Poco::Data::Session> pInvalidSession;
|
||||
try
|
||||
{
|
||||
std::cout << "Attempting to Connect to [" << dbConnString << "] with invalid credentials: " << std::endl;
|
||||
Session session(PostgreSQL::Connector::KEY, dbConnString);
|
||||
fail ("must fail");
|
||||
}
|
||||
catch (ConnectionFailedException& ex)
|
||||
{
|
||||
std::cout << ex.displayText() << std::endl;
|
||||
}
|
||||
catch (ConnectionException& ex)
|
||||
{
|
||||
std::cout << ex.displayText() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PostgreSQLTest::testPostgreSQLOIDs()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
@ -309,6 +336,7 @@ void PostgreSQLTest::testBarebonePostgreSQL()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PostgreSQLTest::testSimpleAccess()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
@ -775,7 +803,7 @@ void PostgreSQLTest::testSqlState()
|
||||
}
|
||||
catch (const Poco::Data::PostgreSQL::PostgreSQLException & exception)
|
||||
{
|
||||
assertTrue(exception.sqlState() == std::string("42601"));
|
||||
assertTrue(exception.sqlState() == std::string("42601"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1236,6 +1264,7 @@ CppUnit::Test* PostgreSQLTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("PostgreSQLTest");
|
||||
|
||||
CppUnit_addTest(pSuite, PostgreSQLTest, testConnectNoDB);
|
||||
CppUnit_addTest(pSuite, PostgreSQLTest, testFailedConnect);
|
||||
CppUnit_addTest(pSuite, PostgreSQLTest, testPostgreSQLOIDs);
|
||||
//CppUnit_addTest(pSuite, PostgreSQLTest, testBarebonePostgreSQL);
|
||||
CppUnit_addTest(pSuite, PostgreSQLTest, testSimpleAccess);
|
||||
|
@ -36,9 +36,11 @@ public:
|
||||
~PostgreSQLTest();
|
||||
|
||||
void testConnectNoDB();
|
||||
void testFailedConnect();
|
||||
void testPostgreSQLOIDs();
|
||||
void testBarebonePostgreSQL();
|
||||
|
||||
|
||||
void testSimpleAccess();
|
||||
void testComplexType();
|
||||
void testSimpleAccessVector();
|
||||
|
Loading…
x
Reference in New Issue
Block a user