|
|
Choosing A Webhost: |
CVS update of carob/test (5 files): msg#00108db.carob.cvs
Date: Monday, February 27, 2006 @ 16:54:11 Author: gilles Path: /cvsroot/carob/carob/test Added: 10-Connection/TestBeginCommitRollback.cpp (1.1) 10-Connection/TestBeginCommitRollback.hpp (1.1) Modified: CarobTestLauncher.cpp (1.25 -> 1.26) Removed: TestBeginCommitRollback.cpp (1.14) TestBeginCommitRollback.hpp (1.6) Moved TestBeginCommitRollback into Connection test-dir -------------------------------------------+ 10-Connection/TestBeginCommitRollback.cpp | 116 ++++++++++++++++++++++++++++ 10-Connection/TestBeginCommitRollback.hpp | 61 ++++++++++++++ CarobTestLauncher.cpp | 2 TestBeginCommitRollback.cpp | 116 ---------------------------- TestBeginCommitRollback.hpp | 62 -------------- 5 files changed, 178 insertions(+), 179 deletions(-) Index: carob/test/10-Connection/TestBeginCommitRollback.cpp diff -u /dev/null carob/test/10-Connection/TestBeginCommitRollback.cpp:1.1 --- /dev/null Mon Feb 27 16:54:11 2006 +++ carob/test/10-Connection/TestBeginCommitRollback.cpp Mon Feb 27 16:54:11 2006 @@ -0,0 +1,116 @@ +/* + * 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 "TestBeginCommitRollback.hpp" + +#include "Statement.hpp" +#include "DriverResultSet.hpp" + +#include "Common.hpp" + +using std::wstring; + +using namespace CarobNS; + +void TestBeginCommitRollback::setUp() +{ + ConnectionSetup::setUp(); + connectionPtr->setAutoCommit(false); +} + +void TestBeginCommitRollback::testReadRequestAndCommit() +{ + wstring fctName(L"TestBeginCommitRollback::testReadRequestAndCommit"); + Statement* stPtr = connectionPtr->createStatement(); + stPtr->executeQuery(L"select * from address"); + connectionPtr->commit(); + if (isInfoEnabled()) + { + logInfo(fctName, L"Read and commit succeeded"); + } +} + +void TestBeginCommitRollback::testReadRequestAndRollback() +{ + wstring fctName(L"TestBeginCommitRollback::testReadRequestAndRollback"); + Statement* stPtr = connectionPtr->createStatement(); + stPtr->executeQuery(L"select * from address"); + connectionPtr->rollback(); + if (isInfoEnabled()) + { + logInfo(fctName, L"Read and rollback succeeded"); + } +} + +void TestBeginCommitRollback::testWriteRequestAndCommit() +{ + wstring fctName(L"TestBeginCommitRollback::testWriteRequestAndCommit"); + Statement* stPtr = connectionPtr->createStatement(); + stPtr->executeUpdate(L"update product set name='commited' where id=0"); + connectionPtr->commit(); + DriverResultSet* drsPtr = stPtr->executeQuery(L"select * from product where id=0"); + drsPtr->next(); + // check written data + wstring strRead = drsPtr->getString(2); + CPPUNIT_ASSERT(strRead == L"commited"); + if (isInfoEnabled()) + { + logInfo(fctName, L"Write and commit succeeded"); + } +} + +void TestBeginCommitRollback::testWriteRequestAndRollback() +{ + wstring fctName(L"TestBeginCommitRollback::testWriteRequestAndRollback"); + Statement* stPtr = connectionPtr->createStatement(); + stPtr->executeUpdate(L"update product set name='rollbacked' where id=0"); + connectionPtr->rollback(); + DriverResultSet* drsPtr = stPtr->executeQuery(L"select * from product where id=0"); + drsPtr->next(); + // check written data + wstring strRead = drsPtr->getString(2); + CPPUNIT_ASSERT(strRead != L"rollbacked"); + if (isInfoEnabled()) + { + logInfo(fctName, L"Write and rollback succeeded"); + } +} + +CppUnit::Test* TestBeginCommitRollback::suite() +{ + CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "TestExecReadRequest" ); + suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( + "testReadRequestAndCommit", + &TestBeginCommitRollback::testReadRequestAndCommit)); + suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( + "testReadRequestAndRollback", + &TestBeginCommitRollback::testReadRequestAndRollback)); + suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( + "testWriteRequestAndCommit", + &TestBeginCommitRollback::testWriteRequestAndCommit)); + suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( + "testWriteRequestAndRollback", + &TestBeginCommitRollback::testWriteRequestAndRollback)); + + return suiteOfTests; +} Index: carob/test/10-Connection/TestBeginCommitRollback.hpp diff -u /dev/null carob/test/10-Connection/TestBeginCommitRollback.hpp:1.1 --- /dev/null Mon Feb 27 16:54:11 2006 +++ carob/test/10-Connection/TestBeginCommitRollback.hpp Mon Feb 27 16:54:11 2006 @@ -0,0 +1,61 @@ +/* + * 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 TESTBEGINCOMMITROLLBACK_H_ +#define TESTBEGINCOMMITROLLBACK_H_ + +#include "../ConnectionSetup.hpp" + +/** + * Test class for Begin/Commit/Rollback commands. + * Runs read and write requests inside transactions. + * A controller *MUST* run locally for test success !!! + */ +class TestBeginCommitRollback : public ConnectionSetup +{ +public: + /** Suite of tests to be run */ + static CppUnit::Test* suite(); + + /** Calls ConnectionSetup::setUp() then set connection autocommit=false */ + virtual void setUp(); + + /** + * Sends a read request and a checks that a commit won't raise an error + */ + void testReadRequestAndCommit(); + /** + * Sends a read request and a checks that a roolback won't raise an error + */ + void testReadRequestAndRollback(); + /** + * Sends a write request and a commit inside a transaction and checks that + * the value has been written correctly. + */ + void testWriteRequestAndCommit(); + /** + * Sends a write request and a rollback inside a transaction and checks that + * the value has not been written. + */ + void testWriteRequestAndRollback(); +}; + +#endif /*TESTBEGINCOMMITROLLBACK_H_*/ Index: carob/test/CarobTestLauncher.cpp diff -u carob/test/CarobTestLauncher.cpp:1.25 carob/test/CarobTestLauncher.cpp:1.26 --- carob/test/CarobTestLauncher.cpp:1.25 Mon Feb 27 15:41:37 2006 +++ carob/test/CarobTestLauncher.cpp Mon Feb 27 16:54:11 2006 @@ -37,12 +37,12 @@ #include "CarobProtector.hpp" -#include "TestBeginCommitRollback.hpp" #include "TestDriverResultSet.hpp" #include "01-Unit/TestStringCodecs.hpp" #include "10-Connection/TestConnect.hpp" #include "10-Connection/TestControllerConnectPolicy.hpp" #include "10-Connection/TestFailOver.hpp" +#include "10-Connection/TestBeginCommitRollback.hpp" #include "20-Write/TestExecWriteRequest.hpp" #include "30-ResultSet/TestSimpleUnicode.hpp" #include "30-ResultSet/TestExecReadRequest.hpp" Index: carob/test/TestBeginCommitRollback.cpp diff -u carob/test/TestBeginCommitRollback.cpp:1.14 carob/test/TestBeginCommitRollback.cpp:removed --- carob/test/TestBeginCommitRollback.cpp:1.14 Mon Feb 27 16:49:46 2006 +++ carob/test/TestBeginCommitRollback.cpp Mon Feb 27 16:54:11 2006 @@ -1,116 +0,0 @@ -/* - * 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 "TestBeginCommitRollback.hpp" - -#include "Statement.hpp" -#include "DriverResultSet.hpp" - -#include "Common.hpp" - -using std::wstring; - -using namespace CarobNS; - -void TestBeginCommitRollback::setUp() -{ - ConnectionSetup::setUp(); - connectionPtr->setAutoCommit(false); -} - -void TestBeginCommitRollback::testReadRequestAndCommit() -{ - wstring fctName(L"TestBeginCommitRollback::testReadRequestAndCommit"); - Statement* stPtr = connectionPtr->createStatement(); - stPtr->executeQuery(L"select * from address"); - connectionPtr->commit(); - if (isInfoEnabled()) - { - logInfo(fctName, L"Read and commit succeeded"); - } -} - -void TestBeginCommitRollback::testReadRequestAndRollback() -{ - wstring fctName(L"TestBeginCommitRollback::testReadRequestAndRollback"); - Statement* stPtr = connectionPtr->createStatement(); - stPtr->executeQuery(L"select * from address"); - connectionPtr->rollback(); - if (isInfoEnabled()) - { - logInfo(fctName, L"Read and rollback succeeded"); - } -} - -void TestBeginCommitRollback::testWriteRequestAndCommit() -{ - wstring fctName(L"TestBeginCommitRollback::testWriteRequestAndCommit"); - Statement* stPtr = connectionPtr->createStatement(); - stPtr->executeUpdate(L"update product set name='commited' where id=0"); - connectionPtr->commit(); - DriverResultSet* drsPtr = stPtr->executeQuery(L"select * from product where id=0"); - drsPtr->next(); - // check written data - wstring strRead = drsPtr->getString(2); - CPPUNIT_ASSERT(strRead == L"commited"); - if (isInfoEnabled()) - { - logInfo(fctName, L"Write and commit succeeded"); - } -} - -void TestBeginCommitRollback::testWriteRequestAndRollback() -{ - wstring fctName(L"TestBeginCommitRollback::testWriteRequestAndRollback"); - Statement* stPtr = connectionPtr->createStatement(); - stPtr->executeUpdate(L"update product set name='rollbacked' where id=0"); - connectionPtr->rollback(); - DriverResultSet* drsPtr = stPtr->executeQuery(L"select * from product where id=0"); - drsPtr->next(); - // check written data - wstring strRead = drsPtr->getString(2); - CPPUNIT_ASSERT(strRead != L"rollbacked"); - if (isInfoEnabled()) - { - logInfo(fctName, L"Write and rollback succeeded"); - } -} - -CppUnit::Test* TestBeginCommitRollback::suite() -{ - CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "TestExecReadRequest" ); - suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( - "testReadRequestAndCommit", - &TestBeginCommitRollback::testReadRequestAndCommit)); - suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( - "testReadRequestAndRollback", - &TestBeginCommitRollback::testReadRequestAndRollback)); - suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( - "testWriteRequestAndCommit", - &TestBeginCommitRollback::testWriteRequestAndCommit)); - suiteOfTests->addTest(new CppUnit::TestCaller<TestBeginCommitRollback>( - "testWriteRequestAndRollback", - &TestBeginCommitRollback::testWriteRequestAndRollback)); - - return suiteOfTests; -} Index: carob/test/TestBeginCommitRollback.hpp diff -u carob/test/TestBeginCommitRollback.hpp:1.6 carob/test/TestBeginCommitRollback.hpp:removed --- carob/test/TestBeginCommitRollback.hpp:1.6 Mon Feb 27 16:49:46 2006 +++ carob/test/TestBeginCommitRollback.hpp Mon Feb 27 16:54:11 2006 @@ -1,62 +0,0 @@ -/* - * 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 TESTBEGINCOMMITROLLBACK_H_ -#define TESTBEGINCOMMITROLLBACK_H_ - -#include "Connection.hpp" -#include "ConnectionSetup.hpp" - -/** - * Test class for Begin/Commit/Rollback commands. - * Runs read and write requests inside transactions. - * A controller *MUST* run locally for test success !!! - */ -class TestBeginCommitRollback : public ConnectionSetup -{ -public: - /** Suite of tests to be run */ - static CppUnit::Test* suite(); - - /** Calls ConnectionSetup::setUp() then set connection autocommit=false */ - virtual void setUp(); - - /** - * Sends a read request and a checks that a commit won't raise an error - */ - void testReadRequestAndCommit(); - /** - * Sends a read request and a checks that a roolback won't raise an error - */ - void testReadRequestAndRollback(); - /** - * Sends a write request and a commit inside a transaction and checks that - * the value has been written correctly. - */ - void testWriteRequestAndCommit(); - /** - * Sends a write request and a rollback inside a transaction and checks that - * the value has not been written. - */ - void testWriteRequestAndRollback(); -}; - -#endif /*TESTBEGINCOMMITROLLBACK_H_*/
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob/test (2 files), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/test (TestDriverResultSet.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/test (5 files), 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.
|