mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-25 18:22:59 +02:00 
			
		
		
		
	PostgreSQL: added test case for failed connection attempt.
This commit is contained in:
		| @@ -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."); | ||||
| @@ -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(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Friedrich Wilckens
					Friedrich Wilckens