Date: Thursday, December 15, 2005 @ 17:43:53
Author: gilles
Path: /cvsroot/carob/carob/test
Modified: TestConnect.cpp (1.9 -> 1.10) TestDriverResultSet.cpp (1.2 ->
1.3) TestExecReadRequest.cpp (1.16 -> 1.17) TestStatement.cpp
(1.17 -> 1.18)
Fixed logging of debug info: now use *only* logging function (and not wcerr
anymore)
-------------------------+
TestConnect.cpp | 17 ++++++++++-------
TestDriverResultSet.cpp | 3 ---
TestExecReadRequest.cpp | 10 +++++++---
TestStatement.cpp | 41 +++++++++++++++++++++++++++++------------
4 files changed, 46 insertions(+), 25 deletions(-)
Index: carob/test/TestConnect.cpp
diff -u carob/test/TestConnect.cpp:1.9 carob/test/TestConnect.cpp:1.10
--- carob/test/TestConnect.cpp:1.9 Mon Dec 12 14:30:10 2005
+++ carob/test/TestConnect.cpp Thu Dec 15 17:43:53 2005
@@ -62,8 +62,9 @@
}
catch (ConnectionException ce)
{
- logError(fctName, L"Connection failed (this is ok). Exception: "
- + ce.description());
+ if (isErrorEnabled())
+ logError(fctName, L"Connection failed (this is ok). Exception: "
+ + ce.description());
CPPUNIT_ASSERT(true);
}
}
@@ -89,14 +90,15 @@
}
catch (ConnectionException ce)
{
- logError(fctName, L"Connection failed (this is ok). Exception: "
- + ce.description());
+ if (isErrorEnabled())
+ logError(fctName, L"Connection failed (this is ok). Exception: "
+ + ce.description());
CPPUNIT_ASSERT(true);
}
}
void TestConnect::testConnectBadDB()
{
- wstring fctName(L"TestConnect::testConnectBadTable");
+ wstring fctName(L"TestConnect::testConnectBadDB");
ConnectionParameters connectionPrms(L"localhost",
25322,
L"dummyDB",
@@ -116,8 +118,9 @@
}
catch (AuthenticationException ae)
{
- logError(fctName, L"Connection failed (this is ok). Exception: "
- + ae.description());
+ if (isErrorEnabled())
+ logError(fctName, L"Connection failed (this is ok). Exception: "
+ + ae.description());
CPPUNIT_ASSERT(true);
}
delete connectionPtr;
Index: carob/test/TestDriverResultSet.cpp
diff -u carob/test/TestDriverResultSet.cpp:1.2
carob/test/TestDriverResultSet.cpp:1.3
--- carob/test/TestDriverResultSet.cpp:1.2 Thu Dec 15 15:55:57 2005
+++ carob/test/TestDriverResultSet.cpp Thu Dec 15 17:43:53 2005
@@ -31,7 +31,6 @@
#include "Statement.hpp"
using std::wstring;
-using std::wcerr;
using std::endl;
using namespace CarobNS;
@@ -97,7 +96,6 @@
//read
DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM address
WHERE id=0");
drsPtr->next();
- wcerr<<L"Int val as string (should be 1234)="<<drsPtr->getAsInt(2)<<endl;
CPPUNIT_ASSERT(drsPtr->getAsInt(2) == 1234);
//2. Negative numbers
@@ -110,7 +108,6 @@
//Read it
drsPtr = statementPtr->executeQuery(L"SELECT * FROM address WHERE id=1");
drsPtr->next();
- wcerr<<L"Int val as string (should be -1)="<<drsPtr->getAsInt(2)<<endl;
CPPUNIT_ASSERT(drsPtr->getAsInt(2) == -1);
//3. Not a number
Index: carob/test/TestExecReadRequest.cpp
diff -u carob/test/TestExecReadRequest.cpp:1.16
carob/test/TestExecReadRequest.cpp:1.17
--- carob/test/TestExecReadRequest.cpp:1.16 Thu Dec 15 15:55:57 2005
+++ carob/test/TestExecReadRequest.cpp Thu Dec 15 17:43:53 2005
@@ -29,7 +29,6 @@
#include "RequestWithResultSetParameters.hpp"
using std::wstring;
-using std::wcerr;
using std::endl;
using namespace CarobNS;
@@ -101,14 +100,19 @@
//Display 50 rows for debugging...
// wcerr<<L"Row\tId\tName\t\tCost"<<endl;
- wcerr<<L"Row\tId\tFirstName\tLastName"<<endl;
+ std::wostringstream buffer;
+ buffer<<L"Row\tId\tFirstName\tLastName"<<endl;
for (int i=0; i<50; i++)
{
drsPtr->next();
- wcerr<<i+1<<L"\t"<<drsPtr->getInt32(1)
+ buffer<<i+1<<L"\t"<<drsPtr->getInt32(1)
<<L"\t"<<drsPtr->getString(2)
<<L"\t\t"<<drsPtr->getString(3)<<endl;
}
+ if (isDebugEnabled())
+ {
+ logDebug(fctName, buffer.str());
+ }
//We have to free the allocated result...
delete drsPtr;
}
Index: carob/test/TestStatement.cpp
diff -u carob/test/TestStatement.cpp:1.17 carob/test/TestStatement.cpp:1.18
--- carob/test/TestStatement.cpp:1.17 Thu Dec 15 15:55:57 2005
+++ carob/test/TestStatement.cpp Thu Dec 15 17:43:53 2005
@@ -31,7 +31,6 @@
#include "Statement.hpp"
using std::wstring;
-using std::wcerr;
using std::endl;
using namespace CarobNS;
@@ -107,14 +106,18 @@
}
//Display 50 rows using metadata and toString
ResultSetMetaData rsmd(drsPtr);
+ std::wostringstream buffer;
for (int i=0; i<50; i++)
{
drsPtr->next();
- wcerr<<i+1<<L"\t";
+ buffer<<i+1<<L"\t";
for (int j=0; j<rsmd.getColumnCount(); j++)
- wcerr<<drsPtr->getAsString(j+1)<<L"\t";
- wcerr<<endl;
+ buffer<<drsPtr->getAsString(j+1)<<L"\t";
+ buffer<<endl;
}
+ if (isDebugEnabled())
+ logDebug(fctName, buffer.str());
+
delete statementPtr;
}
@@ -210,12 +213,16 @@
logDebug(fctName, L"executeQuery succeeded. Displaying first row.");
}
//wcerr<<L"Row\tId\tName\t\tCost"<<endl;
- wcerr<<L"Id\tFirstName\tLastName"<<endl;
+ std::wostringstream buffer;
+ buffer<<L"Id\tFirstName\tLastName"<<endl;
CPPUNIT_ASSERT(drsPtr->next() == true);
- wcerr<<drsPtr->getInt32(1)
+ buffer<<drsPtr->getInt32(1)
<<L"\t"<<drsPtr->getString(2)
<<L"\t\t"<<drsPtr->getString(3)<<endl;
-
+ if (isDebugEnabled())
+ {
+ logDebug(fctName, buffer.str());
+ }
//This next() should return false because we asked just 1 row
CPPUNIT_ASSERT(drsPtr->next() == false);
delete drsPtr;
@@ -285,13 +292,18 @@
}
//Display 50 rows using metadata and toString
ResultSetMetaData rsmd(drsPtr);
+ std::wostringstream buffer;
for (int i=0; i<50; i++)
{
drsPtr->next();
- wcerr<<i+1<<L"\t";
+ buffer<<i+1<<L"\t";
for (int j=0; j<rsmd.getColumnCount(); j++)
- wcerr<<drsPtr->getAsString(j+1)<<L"\t";
- wcerr<<endl;
+ buffer<<drsPtr->getAsString(j+1)<<L"\t";
+ buffer<<endl;
+ }
+ if (isDebugEnabled())
+ {
+ logDebug(fctName, buffer.str());
}
delete statementPtr;
}
@@ -334,12 +346,17 @@
logDebug(fctName, L"Read succeeded. Displaying 50 rows:");
}
//Display rows using metadata and toString
+ std::wostringstream buffer;
while (drsPtr->next())
{
ResultSetMetaData rsmd(drsPtr);
for (int j=0; j<rsmd.getColumnCount(); j++)
- wcerr<<drsPtr->getString(j+1)<<L"\t";
- wcerr<<endl;
+ buffer<<drsPtr->getString(j+1)<<L"\t";
+ buffer<<endl;
+ }
+ if (isDebugEnabled())
+ {
+ logDebug(fctName, buffer.str());
}
delete statementPtr;
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits