|
|
Choosing A Webhost: |
CVS update of carob/test (2 files): msg#00107db.carob.cvs
Date: Monday, February 27, 2006 @ 16:49:46 Author: gilles Path: /cvsroot/carob/carob/test Modified: TestBeginCommitRollback.cpp (1.13 -> 1.14) TestBeginCommitRollback.hpp (1.5 -> 1.6) Added setUp to put connection in autocommit mode only once Extended write tests to check commited and rollbacked values (now does a read) Removed use of Request (use Statement instead) -----------------------------+ TestBeginCommitRollback.cpp | 47 ++++++++++++++++++++++++------------------ TestBeginCommitRollback.hpp | 15 +++++++------ 2 files changed, 35 insertions(+), 27 deletions(-) Index: carob/test/TestBeginCommitRollback.cpp diff -u carob/test/TestBeginCommitRollback.cpp:1.13 carob/test/TestBeginCommitRollback.cpp:1.14 --- carob/test/TestBeginCommitRollback.cpp:1.13 Tue Feb 14 18:35:47 2006 +++ carob/test/TestBeginCommitRollback.cpp Mon Feb 27 16:49:46 2006 @@ -23,52 +23,56 @@ #include "TestBeginCommitRollback.hpp" +#include "Statement.hpp" +#include "DriverResultSet.hpp" + #include "Common.hpp" -#include "Request.hpp" -#include "RequestWithResultSetParameters.hpp" using std::wstring; using namespace CarobNS; +void TestBeginCommitRollback::setUp() +{ + ConnectionSetup::setUp(); + connectionPtr->setAutoCommit(false); +} + void TestBeginCommitRollback::testReadRequestAndCommit() { wstring fctName(L"TestBeginCommitRollback::testReadRequestAndCommit"); - connectionPtr->setAutoCommit(false); - RequestWithResultSetParameters readReq(L"select * from address"); - readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - DriverResultSet* drsPtr = connectionPtr->statementExecuteQuery(readReq); + Statement* stPtr = connectionPtr->createStatement(); + stPtr->executeQuery(L"select * from address"); connectionPtr->commit(); if (isInfoEnabled()) { logInfo(fctName, L"Read and commit succeeded"); } - delete drsPtr; } void TestBeginCommitRollback::testReadRequestAndRollback() { wstring fctName(L"TestBeginCommitRollback::testReadRequestAndRollback"); - connectionPtr->setAutoCommit(false); - RequestWithResultSetParameters readReq(L"select * from address"); - readReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - DriverResultSet* drsPtr = connectionPtr->statementExecuteQuery(readReq); + Statement* stPtr = connectionPtr->createStatement(); + stPtr->executeQuery(L"select * from address"); connectionPtr->rollback(); if (isInfoEnabled()) { logInfo(fctName, L"Read and rollback succeeded"); } - delete drsPtr; } void TestBeginCommitRollback::testWriteRequestAndCommit() { wstring fctName(L"TestBeginCommitRollback::testWriteRequestAndCommit"); - connectionPtr->setAutoCommit(false); - Request updtReq(L"update product set name='commited' where id=0"); - updtReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - connectionPtr->statementExecuteUpdate(updtReq); + 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"); @@ -78,11 +82,14 @@ void TestBeginCommitRollback::testWriteRequestAndRollback() { wstring fctName(L"TestBeginCommitRollback::testWriteRequestAndRollback"); - connectionPtr->setAutoCommit(false); - Request updtReq(L"update product set name='rollbacked' where id=0"); - updtReq.setEscapeProcessing(false).setTimeoutInSeconds(2); - connectionPtr->statementExecuteUpdate(updtReq); + 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"); Index: carob/test/TestBeginCommitRollback.hpp diff -u carob/test/TestBeginCommitRollback.hpp:1.5 carob/test/TestBeginCommitRollback.hpp:1.6 --- carob/test/TestBeginCommitRollback.hpp:1.5 Fri Dec 16 17:41:08 2005 +++ carob/test/TestBeginCommitRollback.hpp Mon Feb 27 16:49:46 2006 @@ -1,6 +1,6 @@ /* * Sequoia: Database clustering technology. - * Copyright (C) 2005 Emic Networks + * Copyright (C) 2005-2006 Continuent, Inc. * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,24 +36,25 @@ /** 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 commit inside a transaction and checks that - * there is no error. + * Sends a read request and a checks that a commit won't raise an error */ void testReadRequestAndCommit(); /** - * Sends a read request and a roolback inside a transaction and checks that - * there is no error. + * 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 - * there is no error. + * the value has been written correctly. */ void testWriteRequestAndCommit(); /** * Sends a write request and a rollback inside a transaction and checks that - * there is no error. + * the value has not been written. */ void testWriteRequestAndRollback(); };
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob/test (ConnectionSetup.cpp ConnectionSetup.hpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/test (5 files), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/test (ConnectionSetup.cpp ConnectionSetup.hpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/test (TestDriverResultSet.cpp), 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.
|