mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
improved URI support; added tests
This commit is contained in:
@@ -221,10 +221,10 @@ void MongoDBTest::testDeleteRequest()
|
||||
void MongoDBTest::testCursorRequest()
|
||||
{
|
||||
Poco::MongoDB::Database db("team");
|
||||
|
||||
|
||||
Poco::SharedPtr<Poco::MongoDB::DeleteRequest> deleteRequest = db.createDeleteRequest("numbers");
|
||||
_mongo->sendRequest(*deleteRequest);
|
||||
|
||||
|
||||
Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = db.createInsertRequest("numbers");
|
||||
for(int i = 0; i < 10000; ++i)
|
||||
{
|
||||
@@ -395,6 +395,51 @@ void MongoDBTest::testUUID()
|
||||
}
|
||||
|
||||
|
||||
void MongoDBTest::testConnectURI()
|
||||
{
|
||||
Poco::MongoDB::Connection conn;
|
||||
Poco::MongoDB::Connection::SocketFactory sf;
|
||||
|
||||
conn.connect("mongodb://127.0.0.1", sf);
|
||||
conn.disconnect();
|
||||
|
||||
try
|
||||
{
|
||||
conn.connect("http://127.0.0.1", sf);
|
||||
fail("invalid URI scheme - must throw");
|
||||
}
|
||||
catch (Poco::UnknownURISchemeException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
conn.connect("mongodb://127.0.0.1?ssl=true", sf);
|
||||
fail("SSL not supported, must throw");
|
||||
}
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
}
|
||||
|
||||
conn.connect("mongodb://127.0.0.1/admin?ssl=false&connectTimeoutMS=10000&socketTimeoutMS=10000", sf);
|
||||
conn.disconnect();
|
||||
|
||||
try
|
||||
{
|
||||
conn.connect("mongodb://127.0.0.1/admin?connectTimeoutMS=foo", sf);
|
||||
fail("invalid parameter - must throw");
|
||||
}
|
||||
catch (Poco::Exception&)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MONGODB_TEST_AUTH
|
||||
conn.connect("mongodb://admin:admin@127.0.0.1/admin", sf);
|
||||
conn.disconnect();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* MongoDBTest::suite()
|
||||
{
|
||||
try
|
||||
@@ -423,6 +468,7 @@ CppUnit::Test* MongoDBTest::suite()
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testObjectID);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testCommand);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testUUID);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testConnectURI);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ public:
|
||||
void testObjectID();
|
||||
void testCommand();
|
||||
void testUUID();
|
||||
void testConnectURI();
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
|
Reference in New Issue
Block a user