Date: Friday, January 13, 2006 @ 12:53:59
  Author: gilles
    Path: /cvsroot/carob/carob/test/40-Parameter-PreparedStatement

Modified: TestPreparedStatement.cpp (1.2 -> 1.3) TestPreparedStatement.hpp
          (1.1 -> 1.2)

Added missing tests on getMetaData in the 'normal situation' (getting metadata 
before executing anything, but with a request to analyse)
Fixed javadoc and logging


---------------------------+
 TestPreparedStatement.cpp |   45 +++++++++++++++++++++++++++++++++++++++-----
 TestPreparedStatement.hpp |   24 +++++++++++++++--------
 2 files changed, 56 insertions(+), 13 deletions(-)


Index: carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.cpp
diff -u carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.cpp:1.2 
carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.cpp:1.3
--- carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.cpp:1.2     
Thu Jan 12 17:33:46 2006
+++ carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.cpp Fri Jan 
13 12:53:59 2006
@@ -102,6 +102,7 @@
     }
   }
 }
+
 void TestPreparedStatement::testPrepareUpdateParameterStatement()
 {
   wstring fctName(L"testPrepareUpdateParameterStatement");
@@ -110,7 +111,7 @@
   psPtr->executeUpdate();
   if (isDebugEnabled())
   {
-    logDebug(fctName, L"Executing getMetaData() on empty parameter statement");
+    logDebug(fctName, L"Executing getMetaData() on update parameter statement 
- should return null");
   }
   ResultSetMetaData* rsmdPtr = psPtr->getMetaData();
   CPPUNIT_ASSERT(rsmdPtr == NULL);
@@ -123,7 +124,7 @@
   statementPtr->executeQuery(L"SELECT * FROM address");
   if (isDebugEnabled())
   {
-    logDebug(fctName, L"Executing getMetaData() on empty statement");
+    logDebug(fctName, L"Executing getMetaData() on query statement");
   }
   ResultSetMetaData* rsmdPtr = statementPtr->getMetaData();
   CPPUNIT_ASSERT(rsmdPtr != NULL); //just to avoid warning on unsused var
@@ -138,7 +139,7 @@
   psPtr->executeQuery();
   if (isDebugEnabled())
   {
-    logDebug(fctName, L"Executing getMetaData() on empty parameter statement");
+    logDebug(fctName, L"Executing getMetaData() on query parameter statement");
   }
   ResultSetMetaData* rsmdPtr = psPtr->getMetaData();
   CPPUNIT_ASSERT(rsmdPtr != NULL);
@@ -152,7 +153,7 @@
   statementPtr->execute(L"SELECT * FROM address");
   if (isDebugEnabled())
   {
-    logDebug(fctName, L"Executing getMetaData() on empty statement");
+    logDebug(fctName, L"Executing getMetaData() on execute statement");
   }
   ResultSetMetaData* rsmdPtr = statementPtr->getMetaData();
   CPPUNIT_ASSERT(rsmdPtr != NULL); //just to avoid warning on unsused var
@@ -167,7 +168,35 @@
   psPtr->execute();
   if (isDebugEnabled())
   {
-    logDebug(fctName, L"Executing getMetaData() on empty parameter statement");
+    logDebug(fctName, L"Executing getMetaData() on execute parameter 
statement");
+  }
+  ResultSetMetaData* rsmdPtr = psPtr->getMetaData();
+  CPPUNIT_ASSERT(rsmdPtr != NULL);
+  CPPUNIT_ASSERT(rsmdPtr->getColumnType(3) == SQLT_VARCHAR);
+}
+
+void TestPreparedStatement::testPrepareStatement()
+{
+  wstring fctName(L"testPrepareStatement");
+  Statement* statementPtr = connectionPtr->createStatement();
+  statementPtr->setRequest(L"SELECT * FROM address");
+  if (isDebugEnabled())
+  {
+    logDebug(fctName, L"Executing getMetaData() on statement");
+  }
+  ResultSetMetaData* rsmdPtr = statementPtr->getMetaData();
+  CPPUNIT_ASSERT(rsmdPtr != NULL); //just to avoid warning on unsused var
+  CPPUNIT_ASSERT(rsmdPtr->getTableName(2) == L"ADDRESS");
+}
+
+void TestPreparedStatement::testPrepareParameterStatement()
+{
+  wstring fctName(L"testPrepareParameterStatement");
+  ParameterStatement* psPtr = connectionPtr->createParameterStatement(L"SELECT 
* FROM address where id=?");
+  psPtr->setInt(1,0);
+  if (isDebugEnabled())
+  {
+    logDebug(fctName, L"Executing getMetaData() on parameter statement");
   }
   ResultSetMetaData* rsmdPtr = psPtr->getMetaData();
   CPPUNIT_ASSERT(rsmdPtr != NULL);
@@ -203,5 +232,11 @@
   suiteOfTests->addTest(new CppUnit::TestCaller<TestPreparedStatement>(
                                  "testPrepareExecuteParameterStatement",
                                  
&TestPreparedStatement::testPrepareExecuteParameterStatement));
+  suiteOfTests->addTest(new CppUnit::TestCaller<TestPreparedStatement>(
+                                 "testPrepareStatement",
+                                 
&TestPreparedStatement::testPrepareStatement));
+  suiteOfTests->addTest(new CppUnit::TestCaller<TestPreparedStatement>(
+                                 "testPrepareParameterStatement",
+                                 
&TestPreparedStatement::testPrepareParameterStatement));
   return suiteOfTests;
 }
Index: carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.hpp
diff -u carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.hpp:1.1 
carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.hpp:1.2
--- carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.hpp:1.1     
Wed Jan 11 20:16:19 2006
+++ carob/test/40-Parameter-PreparedStatement/TestPreparedStatement.hpp Fri Jan 
13 12:53:59 2006
@@ -39,37 +39,45 @@
   static CppUnit::Test* suite();
 
   /**
-   * Creates a Statement and prepares it without setting the query first
+   * Creates a Statement and prepares it without setting the query first 
(should throw an exception)
    */
   void testPrepareEmptyStatement();
   /**
-   * Creates a ParameterStatement and prepares it without setting the query 
first
+   * Creates a ParameterStatement and prepares it without setting the query 
first (should throw an exception)
    */
   void testPrepareEmptyParameterStatement();
   /**
-   * Creates a Statement, executes an update and prepares it
+   * Creates a Statement, executes an update and tries to prepare it (should 
throw an exception)
    */
   void testPrepareUpdateStatement();
   /**
-   * Creates a ParameterStatement, executes an update and prepares it
+   * Creates a ParameterStatement, executes an update and tries to prepare it 
(should return NULL)
    */
   void testPrepareUpdateParameterStatement();
   /**
-   * Creates a Statement, set the query and prepares it
+   * Creates a Statement, executes a query and tries to prepare it (should 
return the result's metadata)
    */
   void testPrepareExecuteQueryStatement();
   /**
-   * Creates a ParameterStatement, set the query and prepares it
+   * Creates a ParameterStatement, executes a query and tries to prepare it 
(should return the result's metadata)
    */
   void testPrepareExecuteQueryParameterStatement();
   /**
-   * Creates a Statement, set the query and prepares it
+   * Creates a Statement, executes a query with execute and tries to prepare 
it (should return the result's metadata)
    */
   void testPrepareExecuteStatement();
   /**
-   * Creates a ParameterStatement, set the query and prepares it
+   * Creates a ParameterStatement, executes a query with execute and tries to 
prepare it (should return the result's metadata)
    */
   void testPrepareExecuteParameterStatement();
+  /**
+   * Creates a Statement, set the query and prepares it
+   */
+  void testPrepareStatement();
+  /**
+   * Creates a ParameterStatement, set the query and prepares it
+   */
+  void testPrepareParameterStatement();
 
 };
 

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

Reply via email to