Date: Monday, February 27, 2006 @ 17:05:33
Author: gilles
Path: /cvsroot/carob/carob/test
Added: 30-ResultSet/TestDriverResultSet.cpp (1.1)
30-ResultSet/TestDriverResultSet.hpp (1.1)
Modified: CarobTestLauncher.cpp (1.26 -> 1.27)
Removed: TestDriverResultSet.cpp (1.6) TestDriverResultSet.hpp (1.4)
Moved TestDriverResultSet in ResulSet test dir
--------------------------------------+
30-ResultSet/TestDriverResultSet.cpp | 148 +++++++++++++++++++++++++++++++++
30-ResultSet/TestDriverResultSet.hpp | 50 +++++++++++
CarobTestLauncher.cpp | 2
TestDriverResultSet.cpp | 148 ---------------------------------
TestDriverResultSet.hpp | 50 -----------
5 files changed, 199 insertions(+), 199 deletions(-)
Index: carob/test/30-ResultSet/TestDriverResultSet.cpp
diff -u /dev/null carob/test/30-ResultSet/TestDriverResultSet.cpp:1.1
--- /dev/null Mon Feb 27 17:05:33 2006
+++ carob/test/30-ResultSet/TestDriverResultSet.cpp Mon Feb 27 17:05:33 2006
@@ -0,0 +1,148 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005-2006 Continuent, Inc.
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Gilles Rayrat
+ * Contributor(s):
+ */
+
+#include "TestDriverResultSet.hpp"
+
+#include "Statement.hpp"
+#include "DriverResultSet.hpp"
+
+#include "CarobException.hpp"
+#include "Common.hpp"
+
+#include <string>
+#include <iostream>
+
+using std::wstring;
+using std::endl;
+
+using namespace CarobNS;
+
+void TestDriverResultSet::testNullValueRetrieval()
+{
+ wstring fctName(L"TestStatement::testNullValueRetrieval");
+ Statement* statementPtr = NULL;
+ //1. Update table: set a value to null
+ statementPtr = connectionPtr->createStatement();
+ if (isInfoEnabled())
+ {
+ logInfo(fctName, L"Creating a NULL value");
+ }
+ statementPtr->executeUpdate(L"UPDATE address SET firstname=NULL WHERE id=0");
+
+ //2. try to read the value with getString
+ DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM address
WHERE id=0");
+ drsPtr->next();
+ try
+ {
+ drsPtr->getString(2); //should fail
+ // We should receive an exception instead of coming here
+ CPPUNIT_ASSERT(false);
+ }
+ catch (NullValueException nve)
+ {
+ if (isErrorEnabled())
+ {
+ logError(fctName, L"Read failed (this is ok). Exception: "
+ + nve.description());
+ }
+ }
+ //3. lets do it again with getAsInt
+ try
+ {
+ drsPtr->getAsInt(2); //should fail
+ // We should receive an exception instead of coming here
+ CPPUNIT_ASSERT(false);
+ }
+ catch (NullValueException nve)
+ {
+ if (isErrorEnabled())
+ {
+ logError(fctName, L"Read failed (this is ok). Exception: "
+ + nve.description());
+ }
+ }
+}
+
+void TestDriverResultSet::testGetAsIntOnString()
+{
+ wstring fctName(L"TestStatement::testGetAsIntOnString");
+ Statement* statementPtr = NULL;
+ //1. Set a string to an int an read it
+ statementPtr = connectionPtr->createStatement();
+ if (isInfoEnabled())
+ {
+ logInfo(fctName, L"Writing an int in a string");
+ }
+ statementPtr->executeUpdate(L"UPDATE address SET firstname='1234' WHERE
id=0");
+ //read
+ DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM address
WHERE id=0");
+ drsPtr->next();
+ CPPUNIT_ASSERT(drsPtr->getAsInt(2) == 1234);
+
+ //2. Negative numbers
+ statementPtr = connectionPtr->createStatement();
+ if (isInfoEnabled())
+ {
+ logInfo(fctName, L"Writing a negative int in a string");
+ }
+ statementPtr->executeUpdate(L"UPDATE address SET firstname='-1' WHERE id=1");
+ //Read it
+ drsPtr = statementPtr->executeQuery(L"SELECT * FROM address WHERE id=1");
+ drsPtr->next();
+ CPPUNIT_ASSERT(drsPtr->getAsInt(2) == -1);
+
+ //3. Not a number
+ statementPtr = connectionPtr->createStatement();
+ if (isInfoEnabled())
+ {
+ logInfo(fctName, L"Writing a non-number in a string");
+ }
+ statementPtr->executeUpdate(L"UPDATE address SET firstname='hello' WHERE
id=1");
+ //Read it
+ drsPtr = statementPtr->executeQuery(L"SELECT * FROM address WHERE id=1");
+ drsPtr->next();
+ try
+ {
+ drsPtr->getAsInt(2);
+ CPPUNIT_ASSERT(false);
+ }
+ catch (DriverException de)
+ {
+ if (isErrorEnabled())
+ {
+ logError(fctName, L"Read failed (this is ok). Exception: "
+ + de.description());
+ }
+ }
+}
+
+CppUnit::Test* TestDriverResultSet::suite()
+{
+ CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite(
"TestDriverResultSet" );
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestDriverResultSet>(
+ "testNullValueRetrieval",
+
&TestDriverResultSet::testNullValueRetrieval));
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestDriverResultSet>(
+ "testGetAsIntOnString",
+ &TestDriverResultSet::testGetAsIntOnString));
+ return suiteOfTests;
+}
+
Index: carob/test/30-ResultSet/TestDriverResultSet.hpp
diff -u /dev/null carob/test/30-ResultSet/TestDriverResultSet.hpp:1.1
--- /dev/null Mon Feb 27 17:05:33 2006
+++ carob/test/30-ResultSet/TestDriverResultSet.hpp Mon Feb 27 17:05:33 2006
@@ -0,0 +1,50 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005-2006 Continuent, Inc.
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Gilles Rayrat
+ * Contributor(s):
+ */
+
+#ifndef TESTDRIVERRESULTSET_H_
+#define TESTDRIVERRESULTSET_H_
+
+#include "../ConnectionSetup.hpp"
+
+/**
+ * Test class for Statement class.
+ * This is basically a copy of exec read and exec write commands testing
+ * A controller *MUST* run locally for test success !!!
+ */
+class TestDriverResultSet : public ConnectionSetup
+{
+public:
+ /** Suite of tests to be run */
+ static CppUnit::Test* suite();
+
+ /**
+ * Sets a null value in a table and tries to read it. Checks that a
+ * NullValueException is thrown
+ */
+ void testNullValueRetrieval();
+ /**
+ * Sets a string entry to various numbers as strings and tries to read it
+ * using getAsInt function
+ */
+ void testGetAsIntOnString();
+};
+
+#endif /*TESTDRIVERRESULTSET_H_*/
Index: carob/test/CarobTestLauncher.cpp
diff -u carob/test/CarobTestLauncher.cpp:1.26
carob/test/CarobTestLauncher.cpp:1.27
--- carob/test/CarobTestLauncher.cpp:1.26 Mon Feb 27 16:54:11 2006
+++ carob/test/CarobTestLauncher.cpp Mon Feb 27 17:05:33 2006
@@ -37,7 +37,6 @@
#include "CarobProtector.hpp"
-#include "TestDriverResultSet.hpp"
#include "01-Unit/TestStringCodecs.hpp"
#include "10-Connection/TestConnect.hpp"
#include "10-Connection/TestControllerConnectPolicy.hpp"
@@ -46,6 +45,7 @@
#include "20-Write/TestExecWriteRequest.hpp"
#include "30-ResultSet/TestSimpleUnicode.hpp"
#include "30-ResultSet/TestExecReadRequest.hpp"
+#include "30-ResultSet/TestDriverResultSet.hpp"
#include "35-ResultList/TestExec.hpp"
#include "40-Parameter-PreparedStatement/TestParameterStatement.hpp"
#include "40-Parameter-PreparedStatement/TestPreparedStatement.hpp"
Index: carob/test/TestDriverResultSet.cpp
diff -u carob/test/TestDriverResultSet.cpp:1.6
carob/test/TestDriverResultSet.cpp:removed
--- carob/test/TestDriverResultSet.cpp:1.6 Mon Feb 27 17:02:34 2006
+++ carob/test/TestDriverResultSet.cpp Mon Feb 27 17:05:33 2006
@@ -1,148 +0,0 @@
-/*
- * Sequoia: Database clustering technology.
- * Copyright (C) 2005-2006 Continuent, Inc.
- * Contact: [EMAIL PROTECTED]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Initial developer(s): Gilles Rayrat
- * Contributor(s):
- */
-
-#include "TestDriverResultSet.hpp"
-
-#include "Statement.hpp"
-#include "DriverResultSet.hpp"
-
-#include "CarobException.hpp"
-#include "Common.hpp"
-
-#include <string>
-#include <iostream>
-
-using std::wstring;
-using std::endl;
-
-using namespace CarobNS;
-
-void TestDriverResultSet::testNullValueRetrieval()
-{
- wstring fctName(L"TestStatement::testNullValueRetrieval");
- Statement* statementPtr = NULL;
- //1. Update table: set a value to null
- statementPtr = connectionPtr->createStatement();
- if (isInfoEnabled())
- {
- logInfo(fctName, L"Creating a NULL value");
- }
- statementPtr->executeUpdate(L"UPDATE address SET firstname=NULL WHERE id=0");
-
- //2. try to read the value with getString
- DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM address
WHERE id=0");
- drsPtr->next();
- try
- {
- drsPtr->getString(2); //should fail
- // We should receive an exception instead of coming here
- CPPUNIT_ASSERT(false);
- }
- catch (NullValueException nve)
- {
- if (isErrorEnabled())
- {
- logError(fctName, L"Read failed (this is ok). Exception: "
- + nve.description());
- }
- }
- //3. lets do it again with getAsInt
- try
- {
- drsPtr->getAsInt(2); //should fail
- // We should receive an exception instead of coming here
- CPPUNIT_ASSERT(false);
- }
- catch (NullValueException nve)
- {
- if (isErrorEnabled())
- {
- logError(fctName, L"Read failed (this is ok). Exception: "
- + nve.description());
- }
- }
-}
-
-void TestDriverResultSet::testGetAsIntOnString()
-{
- wstring fctName(L"TestStatement::testGetAsIntOnString");
- Statement* statementPtr = NULL;
- //1. Set a string to an int an read it
- statementPtr = connectionPtr->createStatement();
- if (isInfoEnabled())
- {
- logInfo(fctName, L"Writing an int in a string");
- }
- statementPtr->executeUpdate(L"UPDATE address SET firstname='1234' WHERE
id=0");
- //read
- DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM address
WHERE id=0");
- drsPtr->next();
- CPPUNIT_ASSERT(drsPtr->getAsInt(2) == 1234);
-
- //2. Negative numbers
- statementPtr = connectionPtr->createStatement();
- if (isInfoEnabled())
- {
- logInfo(fctName, L"Writing a negative int in a string");
- }
- statementPtr->executeUpdate(L"UPDATE address SET firstname='-1' WHERE id=1");
- //Read it
- drsPtr = statementPtr->executeQuery(L"SELECT * FROM address WHERE id=1");
- drsPtr->next();
- CPPUNIT_ASSERT(drsPtr->getAsInt(2) == -1);
-
- //3. Not a number
- statementPtr = connectionPtr->createStatement();
- if (isInfoEnabled())
- {
- logInfo(fctName, L"Writing a non-number in a string");
- }
- statementPtr->executeUpdate(L"UPDATE address SET firstname='hello' WHERE
id=1");
- //Read it
- drsPtr = statementPtr->executeQuery(L"SELECT * FROM address WHERE id=1");
- drsPtr->next();
- try
- {
- drsPtr->getAsInt(2);
- CPPUNIT_ASSERT(false);
- }
- catch (DriverException de)
- {
- if (isErrorEnabled())
- {
- logError(fctName, L"Read failed (this is ok). Exception: "
- + de.description());
- }
- }
-}
-
-CppUnit::Test* TestDriverResultSet::suite()
-{
- CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite(
"TestDriverResultSet" );
- suiteOfTests->addTest(new CppUnit::TestCaller<TestDriverResultSet>(
- "testNullValueRetrieval",
-
&TestDriverResultSet::testNullValueRetrieval));
- suiteOfTests->addTest(new CppUnit::TestCaller<TestDriverResultSet>(
- "testGetAsIntOnString",
- &TestDriverResultSet::testGetAsIntOnString));
- return suiteOfTests;
-}
-
Index: carob/test/TestDriverResultSet.hpp
diff -u carob/test/TestDriverResultSet.hpp:1.4
carob/test/TestDriverResultSet.hpp:removed
--- carob/test/TestDriverResultSet.hpp:1.4 Fri Dec 16 17:41:08 2005
+++ carob/test/TestDriverResultSet.hpp Mon Feb 27 17:05:33 2006
@@ -1,50 +0,0 @@
-/*
- * Sequoia: Database clustering technology.
- * Copyright (C) 2005 Emic Networks
- * Contact: [EMAIL PROTECTED]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Initial developer(s): Gilles Rayrat
- * Contributor(s):
- */
-
-#ifndef TESTDRIVERRESULTSET_H_
-#define TESTDRIVERRESULTSET_H_
-
-#include "ConnectionSetup.hpp"
-
-/**
- * Test class for Statement class.
- * This is basically a copy of exec read and exec write commands testing
- * A controller *MUST* run locally for test success !!!
- */
-class TestDriverResultSet : public ConnectionSetup
-{
-public:
- /** Suite of tests to be run */
- static CppUnit::Test* suite();
-
- /**
- * Sets a null value in a table and tries to read it. Checks that a
- * NullValueException is thrown
- */
- void testNullValueRetrieval();
- /**
- * Sets a string entry to various numbers as strings and tries to read it
- * using getAsInt function
- */
- void testGetAsIntOnString();
-};
-
-#endif /*TESTDRIVERRESULTSET_H_*/
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits