|
|
Choosing A Webhost: |
CVS update of carob/test (5 files): msg#00102db.carob.cvs
Date: Friday, February 24, 2006 @ 19:07:42 Author: gilles Path: /cvsroot/carob/carob/test Added: 30-ResultSet/TestExecReadRequest.cpp (1.1) 30-ResultSet/TestExecReadRequest.hpp (1.1) Modified: CarobTestLauncher.cpp (1.23 -> 1.24) Removed: TestExecReadRequest.cpp (1.18) TestExecReadRequest.hpp (1.7) Changed readok to deserialize BigDecimals (just for debugging for now) Good occasion to move the test files to the appropriate directory --------------------------------------+ 30-ResultSet/TestExecReadRequest.cpp | 134 +++++++++++++++++++++++++++++++++ 30-ResultSet/TestExecReadRequest.hpp | 56 +++++++++++++ CarobTestLauncher.cpp | 2 TestExecReadRequest.cpp | 134 --------------------------------- TestExecReadRequest.hpp | 56 ------------- 5 files changed, 191 insertions(+), 191 deletions(-) Index: carob/test/30-ResultSet/TestExecReadRequest.cpp diff -u /dev/null carob/test/30-ResultSet/TestExecReadRequest.cpp:1.1 --- /dev/null Fri Feb 24 19:07:42 2006 +++ carob/test/30-ResultSet/TestExecReadRequest.cpp Fri Feb 24 19:07:41 2006 @@ -0,0 +1,134 @@ +/* + * Sequoia: Database clustering technology. + * Copyright (C) 2005-2006 Continuent, Inc. + * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx + * + * 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 <iostream> + +#include "Common.hpp" +#include "CarobException.hpp" +#include "Connection.hpp" +#include "DriverResultSet.hpp" +#include "TestExecReadRequest.hpp" +#include "RequestWithResultSetParameters.hpp" + +using std::wstring; +using std::endl; + +using namespace CarobNS; + +void TestExecReadRequest::testReadBadRequest() +{ + wstring fctName(L"TestExecReadRequest::testReadBadRequest"); + try + { + RequestWithResultSetParameters readReq(L"dummy request"); + readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); + if (isInfoEnabled()) + { + logInfo(fctName, L"Executing read - this should fail"); + } + connectionPtr->statementExecuteQuery(readReq); + // We should receive an exception instead of coming here + CPPUNIT_ASSERT(false); + } + catch (ControllerException ce) + { + if (isErrorEnabled()) + { + logError(fctName, L"Read failed (this is ok). Exception: "+ce.description()); + } + } +} + +void TestExecReadRequest::testReadBadTable() +{ + wstring fctName(L"TestExecReadRequest::testReadBadTable"); + try + { + RequestWithResultSetParameters readReq(L"select * from dummy"); + readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); + + if (isInfoEnabled()) + { + logInfo(fctName, L"Executing read - this should fail"); + } + connectionPtr->statementExecuteQuery(readReq); + // We should receive an exception instead of coming here + CPPUNIT_ASSERT(false); + } + catch (BackendException be) + { + if (isErrorEnabled()) + { + logError(fctName, L"Read failed (this is ok). Exception: " + + be.description()); + } + } +} + +void TestExecReadRequest::testReadGood() +{ + wstring fctName(L"TestExecReadRequest::testReadGood"); + RequestWithResultSetParameters readReq(L"select * from product"); + readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); + if (isInfoEnabled()) + { + logInfo(fctName, L"Executing read - this should succeed"); + } + DriverResultSet* drsPtr = connectionPtr->statementExecuteQuery(readReq); + if (isInfoEnabled()) + { + logInfo(fctName, L"Read succeeded. Displaying 50 rows:"); + } + //Display 50 rows for debugging... + +// wcerr<<L"Row\tId\tName\t\tCost"<<endl; + std::wostringstream buffer; + buffer<<L"Row\tId\tFirstName\tLastName"<<endl; + for (int i=0; i<50; i++) + { + drsPtr->next(); + buffer<<i+1<<L"\t"<<drsPtr->getInt32(1) + <<L"\t"<<drsPtr->getString(2) + <<L"\t\t"<<drsPtr->getAsString(3)<<endl; + } + if (isInfoEnabled()) + { + logInfo(fctName, buffer.str()); + } + //We have to free the allocated result... + delete drsPtr; +} + +CppUnit::Test* TestExecReadRequest::suite() +{ + CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "TestExecReadRequest" ); + suiteOfTests->addTest(new CppUnit::TestCaller<TestExecReadRequest>( + "testReadBadRequest", + &TestExecReadRequest::testReadBadRequest)); + suiteOfTests->addTest(new CppUnit::TestCaller<TestExecReadRequest>( + "testReadBadTable", + &TestExecReadRequest::testReadBadTable)); + suiteOfTests->addTest(new CppUnit::TestCaller<TestExecReadRequest>( + "testReadGood", + &TestExecReadRequest::testReadGood)); + + return suiteOfTests; +} Index: carob/test/30-ResultSet/TestExecReadRequest.hpp diff -u /dev/null carob/test/30-ResultSet/TestExecReadRequest.hpp:1.1 --- /dev/null Fri Feb 24 19:07:42 2006 +++ carob/test/30-ResultSet/TestExecReadRequest.hpp Fri Feb 24 19:07:41 2006 @@ -0,0 +1,56 @@ +/* + * Sequoia: Database clustering technology. + * Copyright (C) 2005-2006 Continuent, Inc. + * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx + * + * 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 TESTEXECREADREQUEST_H_ +#define TESTEXECREADREQUEST_H_ + +#include "../ConnectionSetup.hpp" + +/** + * Test class for ExecReadRequest command. + * Tries to run a dummy request, then a request on a dummy table, then a + * correct request and displays the 50 first rows. + * A controller *MUST* run locally for test success !!! + */ +class TestExecReadRequest : public ConnectionSetup +{ +public: + /** Suite of tests to be run */ + static CppUnit::Test* suite(); + + /** + * Tries to send a dummy read request to the controller and checks that the + * error is consistent. + */ + void testReadBadRequest(); + /** + * Tries to do a good read request on a dummy table and checks that the + * error is consistent. + */ + void testReadBadTable(); + /** + * Sends a valid select request to the controller and checks that there is no + * error. Also displays a part of the result for manual check. + */ + void testReadGood(); +}; + +#endif /*TESTEXECREADREQUEST_H_*/ Index: carob/test/CarobTestLauncher.cpp diff -u carob/test/CarobTestLauncher.cpp:1.23 carob/test/CarobTestLauncher.cpp:1.24 --- carob/test/CarobTestLauncher.cpp:1.23 Fri Feb 24 12:58:44 2006 +++ carob/test/CarobTestLauncher.cpp Fri Feb 24 19:07:41 2006 @@ -39,7 +39,6 @@ #include "TestBeginCommitRollback.hpp" #include "TestDriverResultSet.hpp" -#include "TestExecReadRequest.hpp" #include "TestExecWriteRequest.hpp" #include "TestStatement.hpp" #include "01-Unit/TestStringCodecs.hpp" @@ -47,6 +46,7 @@ #include "10-Connection/TestControllerConnectPolicy.hpp" #include "10-Connection/TestFailOver.hpp" #include "30-ResultSet/TestSimpleUnicode.hpp" +#include "30-ResultSet/TestExecReadRequest.hpp" #include "40-Parameter-PreparedStatement/TestParameterStatement.hpp" #include "40-Parameter-PreparedStatement/TestPreparedStatement.hpp" #include "40-Parameter-PreparedStatement/TestIEEE754.hpp" Index: carob/test/TestExecReadRequest.cpp diff -u carob/test/TestExecReadRequest.cpp:1.18 carob/test/TestExecReadRequest.cpp:removed --- carob/test/TestExecReadRequest.cpp:1.18 Tue Feb 14 18:35:47 2006 +++ carob/test/TestExecReadRequest.cpp Fri Feb 24 19:07:42 2006 @@ -1,134 +0,0 @@ -/* - * Sequoia: Database clustering technology. - * Copyright (C) 2005 Emic Networks - * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx - * - * 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 <iostream> - -#include "Common.hpp" -#include "CarobException.hpp" -#include "Connection.hpp" -#include "DriverResultSet.hpp" -#include "TestExecReadRequest.hpp" -#include "RequestWithResultSetParameters.hpp" - -using std::wstring; -using std::endl; - -using namespace CarobNS; - -void TestExecReadRequest::testReadBadRequest() -{ - wstring fctName(L"TestExecReadRequest::testReadBadRequest"); - try - { - RequestWithResultSetParameters readReq(L"dummy request"); - readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - if (isInfoEnabled()) - { - logInfo(fctName, L"Executing read - this should fail"); - } - connectionPtr->statementExecuteQuery(readReq); - // We should receive an exception instead of coming here - CPPUNIT_ASSERT(false); - } - catch (ControllerException ce) - { - if (isErrorEnabled()) - { - logError(fctName, L"Read failed (this is ok). Exception: "+ce.description()); - } - } -} - -void TestExecReadRequest::testReadBadTable() -{ - wstring fctName(L"TestExecReadRequest::testReadBadTable"); - try - { - RequestWithResultSetParameters readReq(L"select * from dummy"); - readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - - if (isInfoEnabled()) - { - logInfo(fctName, L"Executing read - this should fail"); - } - connectionPtr->statementExecuteQuery(readReq); - // We should receive an exception instead of coming here - CPPUNIT_ASSERT(false); - } - catch (BackendException be) - { - if (isErrorEnabled()) - { - logError(fctName, L"Read failed (this is ok). Exception: " - + be.description()); - } - } -} - -void TestExecReadRequest::testReadGood() -{ - wstring fctName(L"TestExecReadRequest::testReadGood"); - RequestWithResultSetParameters readReq(L"select * from address"); - readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - if (isInfoEnabled()) - { - logInfo(fctName, L"Executing read - this should succeed"); - } - DriverResultSet* drsPtr = connectionPtr->statementExecuteQuery(readReq); - if (isInfoEnabled()) - { - logInfo(fctName, L"Read succeeded. Displaying 50 rows:"); - } - //Display 50 rows for debugging... - -// wcerr<<L"Row\tId\tName\t\tCost"<<endl; - std::wostringstream buffer; - buffer<<L"Row\tId\tFirstName\tLastName"<<endl; - for (int i=0; i<50; i++) - { - drsPtr->next(); - buffer<<i+1<<L"\t"<<drsPtr->getInt32(1) - <<L"\t"<<drsPtr->getString(2) - <<L"\t\t"<<drsPtr->getString(3)<<endl; - } - if (isInfoEnabled()) - { - logInfo(fctName, buffer.str()); - } - //We have to free the allocated result... - delete drsPtr; -} - -CppUnit::Test* TestExecReadRequest::suite() -{ - CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "TestExecReadRequest" ); - suiteOfTests->addTest(new CppUnit::TestCaller<TestExecReadRequest>( - "testReadBadRequest", - &TestExecReadRequest::testReadBadRequest)); - suiteOfTests->addTest(new CppUnit::TestCaller<TestExecReadRequest>( - "testReadBadTable", - &TestExecReadRequest::testReadBadTable)); - suiteOfTests->addTest(new CppUnit::TestCaller<TestExecReadRequest>( - "testReadGood", - &TestExecReadRequest::testReadGood)); - - return suiteOfTests; -} Index: carob/test/TestExecReadRequest.hpp diff -u carob/test/TestExecReadRequest.hpp:1.7 carob/test/TestExecReadRequest.hpp:removed --- carob/test/TestExecReadRequest.hpp:1.7 Fri Dec 16 17:41:08 2005 +++ carob/test/TestExecReadRequest.hpp Fri Feb 24 19:07:42 2006 @@ -1,56 +0,0 @@ -/* - * Sequoia: Database clustering technology. - * Copyright (C) 2005 Emic Networks - * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx - * - * 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 TESTEXECREADREQUEST_H_ -#define TESTEXECREADREQUEST_H_ - -#include "ConnectionSetup.hpp" - -/** - * Test class for ExecReadRequest command. - * Tries to run a dummy request, then a request on a dummy table, then a - * correct request and displays the 50 first rows. - * A controller *MUST* run locally for test success !!! - */ -class TestExecReadRequest : public ConnectionSetup -{ -public: - /** Suite of tests to be run */ - static CppUnit::Test* suite(); - - /** - * Tries to send a dummy read request to the controller and checks that the - * error is consistent. - */ - void testReadBadRequest(); - /** - * Tries to do a good read request on a dummy table and checks that the - * error is consistent. - */ - void testReadBadTable(); - /** - * Sends a valid select request to the controller and checks that there is no - * error. Also displays a part of the result for manual check. - */ - void testReadGood(); -}; - -#endif /*TESTEXECREADREQUEST_H_*/
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob/src (DriverResultSet.cpp SQLDataSerialization.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/test/20-Write [new], gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/src (DriverResultSet.cpp SQLDataSerialization.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/test (5 files), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|