Date: Thursday, June 7, 2007 @ 18:23:45
  Author: marc
    Path: /cvsroot/carob/carob/test/10-Connection

Modified: TestConnect.cpp (1.15 -> 1.16)

Fixed logs levels and messages


-----------------+
 TestConnect.cpp |   46 ++++++++++++++++++++++++++--------------------
 1 files changed, 26 insertions(+), 20 deletions(-)


Index: carob/test/10-Connection/TestConnect.cpp
diff -u carob/test/10-Connection/TestConnect.cpp:1.15 
carob/test/10-Connection/TestConnect.cpp:1.16
--- carob/test/10-Connection/TestConnect.cpp:1.15       Thu Feb  8 11:06:49 2007
+++ carob/test/10-Connection/TestConnect.cpp    Thu Jun  7 18:23:45 2007
@@ -41,6 +41,12 @@
 {
 }
 
+namespace
+{
+  const std::string UNEXPECTED_EXCEPTION("Failed as expected BUT with 
unexpected exception, check logs");
+  const std::string UNEXPECTED_SUCCESS("This negative test should have 
failed");
+}
+
 void TestConnect::testConnectBadAddress()
 {
   const wstring fctName(L"TestConnect::testConnectBadAddress");
@@ -49,18 +55,18 @@
   {
     logInfo(fctName, L"Creating controller info - should fail");
     ctrls.push_back(ControllerInfo(L"dummyAddress", 
ConnectionSetup::DEFAULT_PORT1));
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_SUCCESS);
   }
   catch (ConnectionException ce)
   {
-    logError(fctName, L"Connection failed (this is ok). Exception: "
+    logInfo(fctName, L"Connection failed (this is ok). Exception: "
         + ce.description());
   }
   catch (CarobException unexpected)
   {
-    logInfo(fctName, L"Caught other exception: " + unexpected.description());
+    logError(fctName, L"Caught other exception: " + unexpected.description());
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_EXCEPTION);
   }
 }
 
@@ -78,18 +84,18 @@
   {
     connectionPtr = new Connection(connectionPrms);
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_SUCCESS);
   }
   catch (NoMoreControllerException nmce)
   {
-    logError(fctName, L"Connection failed (this is ok). Exception: "
+    logInfo(fctName, L"Connection failed (this is ok). Exception: "
         + nmce.description());
   }
   catch (CarobException unexpected)
   {
-    logInfo(fctName, L"Caught other exception: " + unexpected.description());
+    logError(fctName, L"Caught other exception: " + unexpected.description());
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_EXCEPTION);
   }
 }
 void TestConnect::testConnectBadDB()
@@ -107,18 +113,18 @@
     logInfo(fctName, L"Connecting to controller - should fail");
 
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_SUCCESS);
   }
   catch (VirtualDatabaseUnavailableException ae)
   {
-    logError(fctName, L"Connection failed (this is ok). Exception: "
+    logInfo(fctName, L"Connection failed (this is ok). Exception: "
         + ae.description());
   }
   catch (CarobException unexpected)
   {
-    logInfo(fctName, L"Caught other exception: " + unexpected.description());
+    logError(fctName, L"Caught other exception: " + unexpected.description());
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_EXCEPTION);
   }
 }
 
@@ -137,18 +143,18 @@
     logInfo(fctName, L"Connecting to controller - should fail");
     
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_SUCCESS);
   }
   catch (AuthenticationException ae)
   {
-    logError(fctName, L"Connection failed (this is ok). Exception: "
+    logInfo(fctName, L"Connection failed (this is ok). Exception: "
         + ae.description());
   }
   catch (CarobException unexpected)
   {
-    logInfo(fctName, L"Caught other exception: " + unexpected.description());
+    logError(fctName, L"Caught other exception: " + unexpected.description());
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_EXCEPTION);
   }
 }
 
@@ -167,18 +173,18 @@
     logInfo(fctName, L"Connecting to controller - should fail");
     
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_SUCCESS);
   }
   catch (AuthenticationException ae)
   {
-    logError(fctName, L"Connection failed (this is ok). Exception: "
+    logInfo(fctName, L"Connection failed (this is ok). Exception: "
         + ae.description());
   }
   catch (CarobException unexpected)
   {
-    logInfo(fctName, L"Caught other exception: " + unexpected.description());
+    logError(fctName, L"Caught other exception: " + unexpected.description());
     // We should receive an exception instead of coming here
-    CPPUNIT_ASSERT(false);
+    CPPUNIT_FAIL(UNEXPECTED_EXCEPTION);
   }
 }
 

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

Reply via email to