Date: Monday, December 12, 2005 @ 14:30:10
  Author: gilles
    Path: /cvsroot/carob/carob/test

Modified: TestConnect.cpp (1.8 -> 1.9) TestConnect.hpp (1.5 -> 1.6)

Added test of connection on a bad database


-----------------+
 TestConnect.cpp |   35 ++++++++++++++++++++++++++++++++++-
 TestConnect.hpp |    5 +++++
 2 files changed, 39 insertions(+), 1 deletion(-)


Index: carob/test/TestConnect.cpp
diff -u carob/test/TestConnect.cpp:1.8 carob/test/TestConnect.cpp:1.9
--- carob/test/TestConnect.cpp:1.8      Fri Dec  2 15:53:07 2005
+++ carob/test/TestConnect.cpp  Mon Dec 12 14:30:10 2005
@@ -94,6 +94,35 @@
     CPPUNIT_ASSERT(true);
   }
 }
+void TestConnect::testConnectBadDB()
+{
+  wstring fctName(L"TestConnect::testConnectBadTable");
+  ConnectionParameters connectionPrms(L"localhost",
+                                      25322,
+                                      L"dummyDB",
+                                      L"user",
+                                      L"",
+                                      DEBUG_LEVEL_DEBUG);  
+  try
+  {
+    connectionPtr = connectionPoolPtr->connectToController(connectionPrms);
+    if (isDebugEnabled())
+    {
+      logDebug(fctName, L"Connecting to controller - sould fail");
+    }
+    
+    // We should receive an exception instead of coming here
+    CPPUNIT_ASSERT(false);
+  }
+  catch (AuthenticationException ae)
+  {
+    logError(fctName, L"Connection failed (this is ok). Exception: "
+        + ae.description());
+    CPPUNIT_ASSERT(true);
+  }
+  delete connectionPtr;
+  connectionPtr = NULL;
+}
 
 void TestConnect::testConnectGood()
 {
@@ -108,7 +137,7 @@
   {
     logDebug(fctName, L"Connecting to controller - this should succeed");
   }
-  connectionPtr = connectionPoolPtr->connectToController(connectionPrms);
+    connectionPtr = connectionPoolPtr->connectToController(connectionPrms);
   if (isDebugEnabled())
   {
     logDebug(fctName, L"Connection succeeded");
@@ -124,6 +153,10 @@
   suiteOfTests->addTest(new CppUnit::TestCaller<TestConnect>(
                                  "Connects to a correct address with bad 
port", 
                                  &TestConnect::testConnectBadPort));
+
+  suiteOfTests->addTest(new CppUnit::TestCaller<TestConnect>(
+                                 "Connects to a bad db", 
+                                 &TestConnect::testConnectBadDB));
   suiteOfTests->addTest(new CppUnit::TestCaller<TestConnect>(
                                  "Connects to a running controller", 
                                  &TestConnect::testConnectGood));
Index: carob/test/TestConnect.hpp
diff -u carob/test/TestConnect.hpp:1.5 carob/test/TestConnect.hpp:1.6
--- carob/test/TestConnect.hpp:1.5      Fri Dec  2 15:53:07 2005
+++ carob/test/TestConnect.hpp  Mon Dec 12 14:30:10 2005
@@ -57,6 +57,11 @@
    */
   void testConnectBadPort();
   /**
+   * Tries to connect to a controller on a dummy DB and checks that there is
+   * a failure.
+   */
+  void testConnectBadDB();
+  /**
    * Connects to a controller on a local machine (that must be running !) with
    * the default port and checks everything went good.
    */

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to