Source Code Cross Referenced for TestStatement.java in  » Database-JDBC-Connection-Pool » HA-JDBC » net » sf » hajdbc » sql » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » HA JDBC » net.sf.hajdbc.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * HA-JDBC: High-Availability JDBC
0003:         * Copyright (c) 2004-2007 Paul Ferraro
0004:         * 
0005:         * This library is free software; you can redistribute it and/or modify it 
0006:         * under the terms of the GNU Lesser General Public License as published by the 
0007:         * Free Software Foundation; either version 2.1 of the License, or (at your 
0008:         * option) any later version.
0009:         * 
0010:         * This library is distributed in the hope that it will be useful, but WITHOUT
0011:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
0012:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
0013:         * for more details.
0014:         * 
0015:         * You should have received a copy of the GNU Lesser General Public License
0016:         * along with this library; if not, write to the Free Software Foundation, 
0017:         * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018:         * 
0019:         * Contact: ferraro@users.sourceforge.net
0020:         */
0021:        package net.sf.hajdbc.sql;
0022:
0023:        import java.lang.reflect.Proxy;
0024:        import java.sql.Connection;
0025:        import java.sql.ResultSet;
0026:        import java.sql.SQLException;
0027:        import java.sql.SQLWarning;
0028:        import java.sql.Statement;
0029:        import java.util.Collections;
0030:        import java.util.Map;
0031:        import java.util.Set;
0032:        import java.util.TreeMap;
0033:        import java.util.concurrent.ExecutorService;
0034:        import java.util.concurrent.Executors;
0035:        import java.util.concurrent.locks.Lock;
0036:
0037:        import net.sf.hajdbc.Balancer;
0038:        import net.sf.hajdbc.ColumnProperties;
0039:        import net.sf.hajdbc.Database;
0040:        import net.sf.hajdbc.DatabaseCluster;
0041:        import net.sf.hajdbc.DatabaseMetaDataCache;
0042:        import net.sf.hajdbc.DatabaseProperties;
0043:        import net.sf.hajdbc.Dialect;
0044:        import net.sf.hajdbc.LockManager;
0045:        import net.sf.hajdbc.MockDatabase;
0046:        import net.sf.hajdbc.TableProperties;
0047:        import net.sf.hajdbc.util.reflect.ProxyFactory;
0048:
0049:        import org.easymock.EasyMock;
0050:        import org.easymock.IAnswer;
0051:        import org.testng.annotations.AfterMethod;
0052:        import org.testng.annotations.BeforeClass;
0053:        import org.testng.annotations.DataProvider;
0054:        import org.testng.annotations.Test;
0055:
0056:        /**
0057:         * @author Paul Ferraro
0058:         *
0059:         */
0060:        @Test
0061:        @SuppressWarnings({"unchecked","nls"})
0062:        public class TestStatement implements  java.sql.Statement {
0063:            protected TransactionContext transactionContext = EasyMock
0064:                    .createStrictMock(TransactionContext.class);
0065:            protected Balancer balancer = EasyMock
0066:                    .createStrictMock(Balancer.class);
0067:            protected DatabaseCluster cluster = EasyMock
0068:                    .createStrictMock(DatabaseCluster.class);
0069:            protected FileSupport fileSupport = EasyMock
0070:                    .createStrictMock(FileSupport.class);
0071:            protected Lock sequenceLock = EasyMock.createStrictMock(Lock.class);
0072:            protected Lock tableLock = EasyMock.createStrictMock(Lock.class);
0073:            protected LockManager lockManager = EasyMock
0074:                    .createStrictMock(LockManager.class);
0075:            protected Dialect dialect = EasyMock
0076:                    .createStrictMock(Dialect.class);
0077:            protected DatabaseMetaDataCache metaData = EasyMock
0078:                    .createStrictMock(DatabaseMetaDataCache.class);
0079:            protected DatabaseProperties databaseProperties = EasyMock
0080:                    .createStrictMock(DatabaseProperties.class);
0081:            protected TableProperties tableProperties = EasyMock
0082:                    .createStrictMock(TableProperties.class);
0083:            protected ColumnProperties columnProperties = EasyMock
0084:                    .createStrictMock(ColumnProperties.class);
0085:            protected Connection connection = EasyMock
0086:                    .createStrictMock(Connection.class);
0087:            protected Statement statement1 = EasyMock.createStrictMock(this 
0088:                    .getStatementClass());
0089:            protected Statement statement2 = EasyMock.createStrictMock(this 
0090:                    .getStatementClass());
0091:            protected SQLProxy parent = EasyMock
0092:                    .createStrictMock(SQLProxy.class);
0093:            protected SQLProxy root = EasyMock.createStrictMock(SQLProxy.class);
0094:
0095:            protected Database database1 = new MockDatabase("1");
0096:            protected Database database2 = new MockDatabase("2");
0097:            protected Set<Database> databaseSet;
0098:            protected ExecutorService executor = Executors
0099:                    .newSingleThreadExecutor();
0100:            protected Statement statement;
0101:            protected AbstractStatementInvocationHandler handler;
0102:            protected IAnswer<InvocationStrategy> anwser = new IAnswer<InvocationStrategy>() {
0103:                @Override
0104:                public InvocationStrategy answer() throws Throwable {
0105:                    return (InvocationStrategy) EasyMock.getCurrentArguments()[0];
0106:                }
0107:            };
0108:
0109:            protected Class<? extends java.sql.Statement> getStatementClass() {
0110:                return java.sql.Statement.class;
0111:            }
0112:
0113:            protected AbstractStatementInvocationHandler getInvocationHandler(
0114:                    Map map) throws Exception {
0115:                return new StatementInvocationHandler(this .connection,
0116:                        this .parent, EasyMock.createMock(Invoker.class), map,
0117:                        this .transactionContext, this .fileSupport);
0118:            }
0119:
0120:            @BeforeClass
0121:            void init() throws Exception {
0122:                Map<Database, Statement> map = new TreeMap<Database, Statement>();
0123:                map.put(this .database1, this .statement1);
0124:                map.put(this .database2, this .statement2);
0125:
0126:                this .databaseSet = map.keySet();
0127:
0128:                EasyMock.expect(this .parent.getDatabaseCluster()).andReturn(
0129:                        this .cluster);
0130:
0131:                this .recordConstructor();
0132:
0133:                this .replay();
0134:
0135:                this .handler = this .getInvocationHandler(map);
0136:                this .statement = ProxyFactory.createProxy(this 
0137:                        .getStatementClass(), this .handler);
0138:
0139:                this .verify();
0140:                this .reset();
0141:            }
0142:
0143:            @SuppressWarnings("unused")
0144:            protected void recordConstructor() throws SQLException {
0145:                this .parent.addChild(EasyMock
0146:                        .isA(StatementInvocationHandler.class));
0147:            }
0148:
0149:            private Object[] objects() {
0150:                return new Object[] { this .cluster, this .balancer,
0151:                        this .connection, this .statement1, this .statement2,
0152:                        this .fileSupport, this .sequenceLock, this .tableLock,
0153:                        this .lockManager, this .parent, this .root, this .dialect,
0154:                        this .metaData, this .databaseProperties,
0155:                        this .tableProperties, this .columnProperties,
0156:                        this .transactionContext };
0157:            }
0158:
0159:            void replay() {
0160:                EasyMock.replay(this .objects());
0161:            }
0162:
0163:            void verify() {
0164:                EasyMock.verify(this .objects());
0165:            }
0166:
0167:            @AfterMethod
0168:            void reset() {
0169:                EasyMock.reset(this .objects());
0170:            }
0171:
0172:            @DataProvider(name="string")
0173:            Object[][] stringProvider() {
0174:                return new Object[][] { new Object[] { "sql" } };
0175:            }
0176:
0177:            /**
0178:             * @see java.sql.Statement#addBatch(java.lang.String)
0179:             */
0180:            @Test(dataProvider="string")
0181:            public void addBatch(String sql) throws SQLException {
0182:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0183:
0184:                EasyMock.expect(
0185:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0186:                        .andReturn(false);
0187:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0188:                        .andReturn(false);
0189:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0190:                        .andReturn(false);
0191:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0192:                        .andReturn(false);
0193:
0194:                this .statement1.addBatch(sql);
0195:                this .statement2.addBatch(sql);
0196:
0197:                this .replay();
0198:
0199:                this .statement.addBatch(sql);
0200:
0201:                this .verify();
0202:            }
0203:
0204:            /**
0205:             * @see java.sql.Statement#cancel()
0206:             */
0207:            @Test
0208:            public void cancel() throws SQLException {
0209:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0210:
0211:                EasyMock.expect(this .cluster.getNonTransactionalExecutor())
0212:                        .andReturn(this .executor);
0213:
0214:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0215:                        this .balancer);
0216:                EasyMock.expect(this .balancer.all())
0217:                        .andReturn(this .databaseSet);
0218:
0219:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0220:
0221:                this .root.retain(this .databaseSet);
0222:
0223:                this .statement1.cancel();
0224:                this .statement2.cancel();
0225:
0226:                this .replay();
0227:
0228:                this .statement.cancel();
0229:
0230:                this .verify();
0231:            }
0232:
0233:            /**
0234:             * @see java.sql.Statement#clearBatch()
0235:             */
0236:            @Test
0237:            public void clearBatch() throws SQLException {
0238:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0239:
0240:                this .statement1.clearBatch();
0241:                this .statement2.clearBatch();
0242:
0243:                this .replay();
0244:
0245:                this .statement.clearBatch();
0246:
0247:                this .verify();
0248:            }
0249:
0250:            /**
0251:             * @see java.sql.Statement#clearWarnings()
0252:             */
0253:            @Test
0254:            public void clearWarnings() throws SQLException {
0255:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0256:
0257:                this .statement1.clearWarnings();
0258:                this .statement2.clearWarnings();
0259:
0260:                this .replay();
0261:
0262:                this .statement.clearWarnings();
0263:
0264:                this .verify();
0265:            }
0266:
0267:            /**
0268:             * @see java.sql.Statement#close()
0269:             */
0270:            @Test
0271:            public void close() throws SQLException {
0272:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0273:
0274:                EasyMock.expect(this .cluster.getNonTransactionalExecutor())
0275:                        .andReturn(this .executor);
0276:
0277:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0278:                        this .balancer);
0279:                EasyMock.expect(this .balancer.all())
0280:                        .andReturn(this .databaseSet);
0281:
0282:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0283:
0284:                this .root.retain(this .databaseSet);
0285:
0286:                this .statement1.close();
0287:                this .statement2.close();
0288:
0289:                this .parent.removeChild(this .handler);
0290:
0291:                this .replay();
0292:
0293:                this .statement.close();
0294:
0295:                this .verify();
0296:            }
0297:
0298:            /**
0299:             * @see java.sql.Statement#execute(java.lang.String)
0300:             */
0301:            @Test(dataProvider="string")
0302:            public boolean execute(String sql) throws SQLException {
0303:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0304:
0305:                this .expectIdentifiers(sql, null, null);
0306:
0307:                EasyMock.expect(
0308:                        this .transactionContext.start(EasyMock
0309:                                .isA(InvocationStrategy.class), EasyMock
0310:                                .same(this .connection))).andAnswer(this .anwser);
0311:
0312:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0313:                        .andReturn(this .executor);
0314:
0315:                EasyMock.expect(
0316:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0317:                        .andReturn(false);
0318:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0319:                        .andReturn(false);
0320:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0321:                        .andReturn(false);
0322:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0323:                        .andReturn(false);
0324:
0325:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0326:                        this .balancer);
0327:                EasyMock.expect(this .balancer.all())
0328:                        .andReturn(this .databaseSet);
0329:
0330:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0331:
0332:                this .root.retain(this .databaseSet);
0333:
0334:                EasyMock.expect(this .statement1.execute(sql)).andReturn(true);
0335:                EasyMock.expect(this .statement2.execute(sql)).andReturn(true);
0336:
0337:                this .replay();
0338:
0339:                boolean result = this .statement.execute(sql);
0340:
0341:                this .verify();
0342:
0343:                assert result;
0344:
0345:                this .reset();
0346:
0347:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0348:
0349:                this .expectIdentifiers(sql, "sequence", null);
0350:
0351:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0352:                        .andReturn(this .executor);
0353:
0354:                EasyMock.expect(
0355:                        this .transactionContext.start(EasyMock
0356:                                .isA(InvocationStrategy.class), EasyMock
0357:                                .same(this .connection))).andAnswer(this .anwser);
0358:
0359:                EasyMock.expect(
0360:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0361:                        .andReturn(false);
0362:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0363:                        .andReturn(false);
0364:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0365:                        .andReturn(false);
0366:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0367:                        .andReturn(false);
0368:
0369:                this .sequenceLock.lock();
0370:
0371:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0372:                        this .balancer);
0373:                EasyMock.expect(this .balancer.all())
0374:                        .andReturn(this .databaseSet);
0375:
0376:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0377:
0378:                this .root.retain(this .databaseSet);
0379:
0380:                EasyMock.expect(this .statement1.execute(sql)).andReturn(true);
0381:                EasyMock.expect(this .statement2.execute(sql)).andReturn(true);
0382:
0383:                this .sequenceLock.unlock();
0384:
0385:                this .replay();
0386:
0387:                result = this .statement.execute(sql);
0388:
0389:                this .verify();
0390:
0391:                assert result;
0392:
0393:                this .reset();
0394:
0395:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0396:
0397:                this .expectIdentifiers(sql, null, "table");
0398:
0399:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0400:                        .andReturn(this .executor);
0401:
0402:                EasyMock.expect(
0403:                        this .transactionContext.start(EasyMock
0404:                                .isA(InvocationStrategy.class), EasyMock
0405:                                .same(this .connection))).andAnswer(this .anwser);
0406:
0407:                EasyMock.expect(
0408:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0409:                        .andReturn(false);
0410:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0411:                        .andReturn(false);
0412:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0413:                        .andReturn(false);
0414:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0415:                        .andReturn(false);
0416:
0417:                this .tableLock.lock();
0418:
0419:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0420:                        this .balancer);
0421:                EasyMock.expect(this .balancer.all())
0422:                        .andReturn(this .databaseSet);
0423:
0424:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0425:
0426:                this .root.retain(this .databaseSet);
0427:
0428:                EasyMock.expect(this .statement1.execute(sql)).andReturn(true);
0429:                EasyMock.expect(this .statement2.execute(sql)).andReturn(true);
0430:
0431:                this .tableLock.unlock();
0432:
0433:                this .replay();
0434:
0435:                result = this .statement.execute(sql);
0436:
0437:                this .verify();
0438:
0439:                assert result;
0440:
0441:                this .reset();
0442:
0443:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0444:
0445:                this .expectIdentifiers(sql, "sequence", "table");
0446:
0447:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0448:                        .andReturn(this .executor);
0449:
0450:                EasyMock.expect(
0451:                        this .transactionContext.start(EasyMock
0452:                                .isA(InvocationStrategy.class), EasyMock
0453:                                .same(this .connection))).andAnswer(this .anwser);
0454:
0455:                EasyMock.expect(
0456:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0457:                        .andReturn(false);
0458:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0459:                        .andReturn(false);
0460:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0461:                        .andReturn(false);
0462:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0463:                        .andReturn(false);
0464:
0465:                this .sequenceLock.lock();
0466:                this .tableLock.lock();
0467:
0468:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0469:                        this .balancer);
0470:                EasyMock.expect(this .balancer.all())
0471:                        .andReturn(this .databaseSet);
0472:
0473:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0474:
0475:                this .root.retain(this .databaseSet);
0476:
0477:                EasyMock.expect(this .statement1.execute(sql)).andReturn(true);
0478:                EasyMock.expect(this .statement2.execute(sql)).andReturn(true);
0479:
0480:                this .sequenceLock.unlock();
0481:                this .tableLock.unlock();
0482:
0483:                this .replay();
0484:
0485:                result = this .statement.execute(sql);
0486:
0487:                this .verify();
0488:
0489:                assert result;
0490:
0491:                return result;
0492:            }
0493:
0494:            @DataProvider(name="string-int")
0495:            Object[][] stringIntProvider() {
0496:                return new Object[][] { new Object[] { "sql",
0497:                        java.sql.Statement.NO_GENERATED_KEYS } };
0498:            }
0499:
0500:            /**
0501:             * @see java.sql.Statement#execute(java.lang.String, int)
0502:             */
0503:            @Test(dataProvider="string-int")
0504:            public boolean execute(String sql, int autoGeneratedKeys)
0505:                    throws SQLException {
0506:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0507:
0508:                this .expectIdentifiers(sql, null, null);
0509:
0510:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0511:                        .andReturn(this .executor);
0512:
0513:                EasyMock.expect(
0514:                        this .transactionContext.start(EasyMock
0515:                                .isA(InvocationStrategy.class), EasyMock
0516:                                .same(this .connection))).andAnswer(this .anwser);
0517:
0518:                EasyMock.expect(
0519:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0520:                        .andReturn(false);
0521:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0522:                        .andReturn(false);
0523:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0524:                        .andReturn(false);
0525:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0526:                        .andReturn(false);
0527:
0528:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0529:                        this .balancer);
0530:                EasyMock.expect(this .balancer.all())
0531:                        .andReturn(this .databaseSet);
0532:
0533:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0534:
0535:                this .root.retain(this .databaseSet);
0536:
0537:                EasyMock
0538:                        .expect(this .statement1.execute(sql, autoGeneratedKeys))
0539:                        .andReturn(true);
0540:                EasyMock
0541:                        .expect(this .statement2.execute(sql, autoGeneratedKeys))
0542:                        .andReturn(true);
0543:
0544:                this .replay();
0545:
0546:                boolean result = this .statement.execute(sql, autoGeneratedKeys);
0547:
0548:                this .verify();
0549:
0550:                assert result;
0551:
0552:                this .reset();
0553:
0554:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0555:
0556:                this .expectIdentifiers(sql, "sequence", null);
0557:
0558:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0559:                        .andReturn(this .executor);
0560:
0561:                EasyMock.expect(
0562:                        this .transactionContext.start(EasyMock
0563:                                .isA(InvocationStrategy.class), EasyMock
0564:                                .same(this .connection))).andAnswer(this .anwser);
0565:
0566:                EasyMock.expect(
0567:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0568:                        .andReturn(false);
0569:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0570:                        .andReturn(false);
0571:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0572:                        .andReturn(false);
0573:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0574:                        .andReturn(false);
0575:
0576:                this .sequenceLock.lock();
0577:
0578:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0579:                        this .balancer);
0580:                EasyMock.expect(this .balancer.all())
0581:                        .andReturn(this .databaseSet);
0582:
0583:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0584:
0585:                this .root.retain(this .databaseSet);
0586:
0587:                EasyMock
0588:                        .expect(this .statement1.execute(sql, autoGeneratedKeys))
0589:                        .andReturn(true);
0590:                EasyMock
0591:                        .expect(this .statement2.execute(sql, autoGeneratedKeys))
0592:                        .andReturn(true);
0593:
0594:                this .sequenceLock.unlock();
0595:
0596:                this .replay();
0597:
0598:                result = this .statement.execute(sql, autoGeneratedKeys);
0599:
0600:                this .verify();
0601:
0602:                assert result;
0603:
0604:                this .reset();
0605:
0606:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0607:
0608:                this .expectIdentifiers(sql, null, "table");
0609:
0610:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0611:                        .andReturn(this .executor);
0612:
0613:                EasyMock.expect(
0614:                        this .transactionContext.start(EasyMock
0615:                                .isA(InvocationStrategy.class), EasyMock
0616:                                .same(this .connection))).andAnswer(this .anwser);
0617:
0618:                EasyMock.expect(
0619:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0620:                        .andReturn(false);
0621:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0622:                        .andReturn(false);
0623:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0624:                        .andReturn(false);
0625:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0626:                        .andReturn(false);
0627:
0628:                this .tableLock.lock();
0629:
0630:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0631:                        this .balancer);
0632:                EasyMock.expect(this .balancer.all())
0633:                        .andReturn(this .databaseSet);
0634:
0635:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0636:
0637:                this .root.retain(this .databaseSet);
0638:
0639:                EasyMock
0640:                        .expect(this .statement1.execute(sql, autoGeneratedKeys))
0641:                        .andReturn(true);
0642:                EasyMock
0643:                        .expect(this .statement2.execute(sql, autoGeneratedKeys))
0644:                        .andReturn(true);
0645:
0646:                this .tableLock.unlock();
0647:
0648:                this .replay();
0649:
0650:                result = this .statement.execute(sql, autoGeneratedKeys);
0651:
0652:                this .verify();
0653:
0654:                assert result;
0655:
0656:                this .reset();
0657:
0658:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0659:
0660:                this .expectIdentifiers(sql, "sequence", "table");
0661:
0662:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0663:                        .andReturn(this .executor);
0664:
0665:                EasyMock.expect(
0666:                        this .transactionContext.start(EasyMock
0667:                                .isA(InvocationStrategy.class), EasyMock
0668:                                .same(this .connection))).andAnswer(this .anwser);
0669:
0670:                EasyMock.expect(
0671:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0672:                        .andReturn(false);
0673:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0674:                        .andReturn(false);
0675:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0676:                        .andReturn(false);
0677:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0678:                        .andReturn(false);
0679:
0680:                this .sequenceLock.lock();
0681:                this .tableLock.lock();
0682:
0683:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0684:                        this .balancer);
0685:                EasyMock.expect(this .balancer.all())
0686:                        .andReturn(this .databaseSet);
0687:
0688:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0689:
0690:                this .root.retain(this .databaseSet);
0691:
0692:                EasyMock
0693:                        .expect(this .statement1.execute(sql, autoGeneratedKeys))
0694:                        .andReturn(true);
0695:                EasyMock
0696:                        .expect(this .statement2.execute(sql, autoGeneratedKeys))
0697:                        .andReturn(true);
0698:
0699:                this .sequenceLock.unlock();
0700:                this .tableLock.unlock();
0701:
0702:                this .replay();
0703:
0704:                result = this .statement.execute(sql, autoGeneratedKeys);
0705:
0706:                this .verify();
0707:
0708:                assert result;
0709:
0710:                return result;
0711:            }
0712:
0713:            @DataProvider(name="string-ints")
0714:            Object[][] stringIntsProvider() {
0715:                return new Object[][] { new Object[] { "sql", new int[] { 1 } } };
0716:            }
0717:
0718:            /**
0719:             * @see java.sql.Statement#execute(java.lang.String, int[])
0720:             */
0721:            @Test(dataProvider="string-ints")
0722:            public boolean execute(String sql, int[] columnIndexes)
0723:                    throws SQLException {
0724:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0725:
0726:                this .expectIdentifiers(sql, null, null);
0727:
0728:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0729:                        .andReturn(this .executor);
0730:
0731:                EasyMock.expect(
0732:                        this .transactionContext.start(EasyMock
0733:                                .isA(InvocationStrategy.class), EasyMock
0734:                                .same(this .connection))).andAnswer(this .anwser);
0735:
0736:                EasyMock.expect(
0737:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0738:                        .andReturn(false);
0739:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0740:                        .andReturn(false);
0741:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0742:                        .andReturn(false);
0743:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0744:                        .andReturn(false);
0745:
0746:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0747:                        this .balancer);
0748:                EasyMock.expect(this .balancer.all())
0749:                        .andReturn(this .databaseSet);
0750:
0751:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0752:
0753:                this .root.retain(this .databaseSet);
0754:
0755:                EasyMock.expect(this .statement1.execute(sql, columnIndexes))
0756:                        .andReturn(true);
0757:                EasyMock.expect(this .statement2.execute(sql, columnIndexes))
0758:                        .andReturn(true);
0759:
0760:                this .replay();
0761:
0762:                boolean result = this .statement.execute(sql, columnIndexes);
0763:
0764:                this .verify();
0765:
0766:                assert result;
0767:
0768:                this .reset();
0769:
0770:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0771:
0772:                this .expectIdentifiers(sql, "sequence", null);
0773:
0774:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0775:                        .andReturn(this .executor);
0776:
0777:                EasyMock.expect(
0778:                        this .transactionContext.start(EasyMock
0779:                                .isA(InvocationStrategy.class), EasyMock
0780:                                .same(this .connection))).andAnswer(this .anwser);
0781:
0782:                EasyMock.expect(
0783:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0784:                        .andReturn(false);
0785:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0786:                        .andReturn(false);
0787:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0788:                        .andReturn(false);
0789:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0790:                        .andReturn(false);
0791:
0792:                this .sequenceLock.lock();
0793:
0794:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0795:                        this .balancer);
0796:                EasyMock.expect(this .balancer.all())
0797:                        .andReturn(this .databaseSet);
0798:
0799:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0800:
0801:                this .root.retain(this .databaseSet);
0802:
0803:                EasyMock.expect(this .statement1.execute(sql, columnIndexes))
0804:                        .andReturn(true);
0805:                EasyMock.expect(this .statement2.execute(sql, columnIndexes))
0806:                        .andReturn(true);
0807:
0808:                this .sequenceLock.unlock();
0809:
0810:                this .replay();
0811:
0812:                result = this .statement.execute(sql, columnIndexes);
0813:
0814:                this .verify();
0815:
0816:                assert result;
0817:
0818:                this .reset();
0819:
0820:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0821:
0822:                this .expectIdentifiers(sql, null, "table");
0823:
0824:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0825:                        .andReturn(this .executor);
0826:
0827:                EasyMock.expect(
0828:                        this .transactionContext.start(EasyMock
0829:                                .isA(InvocationStrategy.class), EasyMock
0830:                                .same(this .connection))).andAnswer(this .anwser);
0831:
0832:                EasyMock.expect(
0833:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0834:                        .andReturn(false);
0835:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0836:                        .andReturn(false);
0837:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0838:                        .andReturn(false);
0839:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0840:                        .andReturn(false);
0841:
0842:                this .tableLock.lock();
0843:
0844:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0845:                        this .balancer);
0846:                EasyMock.expect(this .balancer.all())
0847:                        .andReturn(this .databaseSet);
0848:
0849:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0850:
0851:                this .root.retain(this .databaseSet);
0852:
0853:                EasyMock.expect(this .statement1.execute(sql, columnIndexes))
0854:                        .andReturn(true);
0855:                EasyMock.expect(this .statement2.execute(sql, columnIndexes))
0856:                        .andReturn(true);
0857:
0858:                this .tableLock.unlock();
0859:
0860:                this .replay();
0861:
0862:                result = this .statement.execute(sql, columnIndexes);
0863:
0864:                this .verify();
0865:
0866:                assert result;
0867:
0868:                this .reset();
0869:
0870:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0871:
0872:                this .expectIdentifiers(sql, "sequence", "table");
0873:
0874:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0875:                        .andReturn(this .executor);
0876:
0877:                EasyMock.expect(
0878:                        this .transactionContext.start(EasyMock
0879:                                .isA(InvocationStrategy.class), EasyMock
0880:                                .same(this .connection))).andAnswer(this .anwser);
0881:
0882:                EasyMock.expect(
0883:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0884:                        .andReturn(false);
0885:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0886:                        .andReturn(false);
0887:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0888:                        .andReturn(false);
0889:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0890:                        .andReturn(false);
0891:
0892:                this .sequenceLock.lock();
0893:                this .tableLock.lock();
0894:
0895:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0896:                        this .balancer);
0897:                EasyMock.expect(this .balancer.all())
0898:                        .andReturn(this .databaseSet);
0899:
0900:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0901:
0902:                this .root.retain(this .databaseSet);
0903:
0904:                EasyMock.expect(this .statement1.execute(sql, columnIndexes))
0905:                        .andReturn(true);
0906:                EasyMock.expect(this .statement2.execute(sql, columnIndexes))
0907:                        .andReturn(true);
0908:
0909:                this .sequenceLock.unlock();
0910:                this .tableLock.unlock();
0911:
0912:                this .replay();
0913:
0914:                result = this .statement.execute(sql, columnIndexes);
0915:
0916:                this .verify();
0917:
0918:                assert result;
0919:
0920:                return result;
0921:            }
0922:
0923:            @DataProvider(name="string-strings")
0924:            Object[][] stringStringsProvider() {
0925:                return new Object[][] { new Object[] { "sql",
0926:                        new String[] { "name" } } };
0927:            }
0928:
0929:            /**
0930:             * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
0931:             */
0932:            @Test(dataProvider="string-strings")
0933:            public boolean execute(String sql, String[] columnNames)
0934:                    throws SQLException {
0935:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0936:
0937:                this .expectIdentifiers(sql, null, null);
0938:
0939:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0940:                        .andReturn(this .executor);
0941:
0942:                EasyMock.expect(
0943:                        this .transactionContext.start(EasyMock
0944:                                .isA(InvocationStrategy.class), EasyMock
0945:                                .same(this .connection))).andAnswer(this .anwser);
0946:
0947:                EasyMock.expect(
0948:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0949:                        .andReturn(false);
0950:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0951:                        .andReturn(false);
0952:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0953:                        .andReturn(false);
0954:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
0955:                        .andReturn(false);
0956:
0957:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
0958:                        this .balancer);
0959:                EasyMock.expect(this .balancer.all())
0960:                        .andReturn(this .databaseSet);
0961:
0962:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
0963:
0964:                this .root.retain(this .databaseSet);
0965:
0966:                EasyMock.expect(this .statement1.execute(sql, columnNames))
0967:                        .andReturn(true);
0968:                EasyMock.expect(this .statement2.execute(sql, columnNames))
0969:                        .andReturn(true);
0970:
0971:                this .replay();
0972:
0973:                boolean result = this .statement.execute(sql, columnNames);
0974:
0975:                this .verify();
0976:
0977:                assert result;
0978:
0979:                this .reset();
0980:
0981:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
0982:
0983:                this .expectIdentifiers(sql, "sequence", null);
0984:
0985:                EasyMock.expect(this .cluster.getTransactionalExecutor())
0986:                        .andReturn(this .executor);
0987:
0988:                EasyMock.expect(
0989:                        this .transactionContext.start(EasyMock
0990:                                .isA(InvocationStrategy.class), EasyMock
0991:                                .same(this .connection))).andAnswer(this .anwser);
0992:
0993:                EasyMock.expect(
0994:                        this .cluster.isCurrentTimestampEvaluationEnabled())
0995:                        .andReturn(false);
0996:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
0997:                        .andReturn(false);
0998:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
0999:                        .andReturn(false);
1000:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1001:                        .andReturn(false);
1002:
1003:                this .sequenceLock.lock();
1004:
1005:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1006:                        this .balancer);
1007:                EasyMock.expect(this .balancer.all())
1008:                        .andReturn(this .databaseSet);
1009:
1010:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1011:
1012:                this .root.retain(this .databaseSet);
1013:
1014:                EasyMock.expect(this .statement1.execute(sql, columnNames))
1015:                        .andReturn(true);
1016:                EasyMock.expect(this .statement2.execute(sql, columnNames))
1017:                        .andReturn(true);
1018:
1019:                this .sequenceLock.unlock();
1020:
1021:                this .replay();
1022:
1023:                result = this .statement.execute(sql, columnNames);
1024:
1025:                this .verify();
1026:
1027:                assert result;
1028:
1029:                this .reset();
1030:
1031:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1032:
1033:                this .expectIdentifiers(sql, null, "table");
1034:
1035:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1036:                        .andReturn(this .executor);
1037:
1038:                EasyMock.expect(
1039:                        this .transactionContext.start(EasyMock
1040:                                .isA(InvocationStrategy.class), EasyMock
1041:                                .same(this .connection))).andAnswer(this .anwser);
1042:
1043:                EasyMock.expect(
1044:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1045:                        .andReturn(false);
1046:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1047:                        .andReturn(false);
1048:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1049:                        .andReturn(false);
1050:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1051:                        .andReturn(false);
1052:
1053:                this .tableLock.lock();
1054:
1055:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1056:                        this .balancer);
1057:                EasyMock.expect(this .balancer.all())
1058:                        .andReturn(this .databaseSet);
1059:
1060:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1061:
1062:                this .root.retain(this .databaseSet);
1063:
1064:                EasyMock.expect(this .statement1.execute(sql, columnNames))
1065:                        .andReturn(true);
1066:                EasyMock.expect(this .statement2.execute(sql, columnNames))
1067:                        .andReturn(true);
1068:
1069:                this .tableLock.unlock();
1070:
1071:                this .replay();
1072:
1073:                result = this .statement.execute(sql, columnNames);
1074:
1075:                this .verify();
1076:
1077:                assert result;
1078:
1079:                this .reset();
1080:
1081:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1082:
1083:                this .expectIdentifiers(sql, "sequence", "table");
1084:
1085:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1086:                        .andReturn(this .executor);
1087:
1088:                EasyMock.expect(
1089:                        this .transactionContext.start(EasyMock
1090:                                .isA(InvocationStrategy.class), EasyMock
1091:                                .same(this .connection))).andAnswer(this .anwser);
1092:
1093:                EasyMock.expect(
1094:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1095:                        .andReturn(false);
1096:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1097:                        .andReturn(false);
1098:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1099:                        .andReturn(false);
1100:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1101:                        .andReturn(false);
1102:
1103:                this .sequenceLock.lock();
1104:                this .tableLock.lock();
1105:
1106:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1107:                        this .balancer);
1108:                EasyMock.expect(this .balancer.all())
1109:                        .andReturn(this .databaseSet);
1110:
1111:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1112:
1113:                this .root.retain(this .databaseSet);
1114:
1115:                EasyMock.expect(this .statement1.execute(sql, columnNames))
1116:                        .andReturn(true);
1117:                EasyMock.expect(this .statement2.execute(sql, columnNames))
1118:                        .andReturn(true);
1119:
1120:                this .sequenceLock.unlock();
1121:                this .tableLock.unlock();
1122:
1123:                this .replay();
1124:
1125:                result = this .statement.execute(sql, columnNames);
1126:
1127:                this .verify();
1128:
1129:                assert result;
1130:
1131:                return result;
1132:            }
1133:
1134:            /**
1135:             * @see java.sql.Statement#executeBatch()
1136:             */
1137:            @Test
1138:            public int[] executeBatch() throws SQLException {
1139:                int[] array = new int[0];
1140:
1141:                this .addBatch("sql");
1142:
1143:                this .reset();
1144:
1145:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1146:
1147:                this .expectIdentifiers("sql", null, null);
1148:
1149:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1150:                        .andReturn(this .executor);
1151:
1152:                EasyMock.expect(
1153:                        this .transactionContext.start(EasyMock
1154:                                .isA(InvocationStrategy.class), EasyMock
1155:                                .same(this .connection))).andAnswer(this .anwser);
1156:
1157:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1158:                        this .balancer);
1159:                EasyMock.expect(this .balancer.all())
1160:                        .andReturn(this .databaseSet);
1161:
1162:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1163:
1164:                this .root.retain(this .databaseSet);
1165:
1166:                EasyMock.expect(this .statement1.executeBatch())
1167:                        .andReturn(array);
1168:                EasyMock.expect(this .statement2.executeBatch())
1169:                        .andReturn(array);
1170:
1171:                this .replay();
1172:
1173:                int[] result = this .statement.executeBatch();
1174:
1175:                this .verify();
1176:
1177:                assert result == array;
1178:
1179:                this .reset();
1180:
1181:                this .addBatch("sql");
1182:
1183:                this .reset();
1184:
1185:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1186:
1187:                this .expectIdentifiers("sql", "sequence", null);
1188:
1189:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1190:                        .andReturn(this .executor);
1191:
1192:                EasyMock.expect(
1193:                        this .transactionContext.start(EasyMock
1194:                                .isA(InvocationStrategy.class), EasyMock
1195:                                .same(this .connection))).andAnswer(this .anwser);
1196:
1197:                this .sequenceLock.lock();
1198:
1199:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1200:                        this .balancer);
1201:                EasyMock.expect(this .balancer.all())
1202:                        .andReturn(this .databaseSet);
1203:
1204:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1205:
1206:                this .root.retain(this .databaseSet);
1207:
1208:                EasyMock.expect(this .statement1.executeBatch())
1209:                        .andReturn(array);
1210:                EasyMock.expect(this .statement2.executeBatch())
1211:                        .andReturn(array);
1212:
1213:                this .sequenceLock.unlock();
1214:
1215:                this .replay();
1216:
1217:                result = this .statement.executeBatch();
1218:
1219:                this .verify();
1220:
1221:                assert result == array;
1222:
1223:                this .reset();
1224:
1225:                this .addBatch("sql");
1226:
1227:                this .reset();
1228:
1229:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1230:
1231:                this .expectIdentifiers("sql", null, "table");
1232:
1233:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1234:                        .andReturn(this .executor);
1235:
1236:                EasyMock.expect(
1237:                        this .transactionContext.start(EasyMock
1238:                                .isA(InvocationStrategy.class), EasyMock
1239:                                .same(this .connection))).andAnswer(this .anwser);
1240:
1241:                this .tableLock.lock();
1242:
1243:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1244:                        this .balancer);
1245:                EasyMock.expect(this .balancer.all())
1246:                        .andReturn(this .databaseSet);
1247:
1248:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1249:
1250:                this .root.retain(this .databaseSet);
1251:
1252:                EasyMock.expect(this .statement1.executeBatch())
1253:                        .andReturn(array);
1254:                EasyMock.expect(this .statement2.executeBatch())
1255:                        .andReturn(array);
1256:
1257:                this .tableLock.unlock();
1258:
1259:                this .replay();
1260:
1261:                result = this .statement.executeBatch();
1262:
1263:                this .verify();
1264:
1265:                assert result == array;
1266:
1267:                this .reset();
1268:
1269:                this .addBatch("sql");
1270:
1271:                this .reset();
1272:
1273:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1274:
1275:                this .expectIdentifiers("sql", "sequence", "table");
1276:
1277:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1278:                        .andReturn(this .executor);
1279:
1280:                EasyMock.expect(
1281:                        this .transactionContext.start(EasyMock
1282:                                .isA(InvocationStrategy.class), EasyMock
1283:                                .same(this .connection))).andAnswer(this .anwser);
1284:
1285:                this .sequenceLock.lock();
1286:                this .tableLock.lock();
1287:
1288:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1289:                        this .balancer);
1290:                EasyMock.expect(this .balancer.all())
1291:                        .andReturn(this .databaseSet);
1292:
1293:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1294:
1295:                this .root.retain(this .databaseSet);
1296:
1297:                EasyMock.expect(this .statement1.executeBatch())
1298:                        .andReturn(array);
1299:                EasyMock.expect(this .statement2.executeBatch())
1300:                        .andReturn(array);
1301:
1302:                this .sequenceLock.unlock();
1303:                this .tableLock.unlock();
1304:
1305:                this .replay();
1306:
1307:                result = this .statement.executeBatch();
1308:
1309:                this .verify();
1310:
1311:                assert result == array;
1312:
1313:                this .reset();
1314:
1315:                return result;
1316:            }
1317:
1318:            /**
1319:             * @see java.sql.Statement#executeQuery(java.lang.String)
1320:             */
1321:            @Test(dataProvider="string")
1322:            public ResultSet executeQuery(String sql) throws SQLException {
1323:                ResultSet resultSet1 = EasyMock.createMock(ResultSet.class);
1324:                ResultSet resultSet2 = EasyMock.createMock(ResultSet.class);
1325:
1326:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1327:
1328:                this .expectIdentifiers(sql, null, null);
1329:
1330:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1331:
1332:                // Read-only result set
1333:                EasyMock.expect(this .statement1.getResultSetConcurrency())
1334:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
1335:
1336:                this .expectSelectForUpdateCheck(sql, false);
1337:
1338:                EasyMock.expect(
1339:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1340:                        .andReturn(false);
1341:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1342:                        .andReturn(false);
1343:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1344:                        .andReturn(false);
1345:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1346:                        .andReturn(false);
1347:
1348:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1349:                        this .balancer);
1350:                EasyMock.expect(this .balancer.next()).andReturn(this .database2);
1351:
1352:                this .balancer.beforeInvocation(this .database2);
1353:
1354:                EasyMock.expect(this .statement2.executeQuery(sql)).andReturn(
1355:                        resultSet2);
1356:
1357:                this .balancer.afterInvocation(this .database2);
1358:
1359:                this .replay();
1360:
1361:                ResultSet results = this .statement.executeQuery(sql);
1362:
1363:                this .verify();
1364:
1365:                assert Proxy.isProxyClass(results.getClass());
1366:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1367:                        .getObject(this .database2) == resultSet2;
1368:
1369:                this .reset();
1370:
1371:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1372:
1373:                this .expectIdentifiers(sql, null, null);
1374:
1375:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1376:
1377:                // Updatable result set
1378:                EasyMock.expect(this .statement1.getResultSetConcurrency())
1379:                        .andReturn(ResultSet.CONCUR_UPDATABLE);
1380:
1381:                this .expectSelectForUpdateCheck(sql, false);
1382:
1383:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1384:                        .andReturn(this .executor);
1385:
1386:                EasyMock.expect(
1387:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1388:                        .andReturn(false);
1389:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1390:                        .andReturn(false);
1391:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1392:                        .andReturn(false);
1393:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1394:                        .andReturn(false);
1395:
1396:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1397:                        this .balancer);
1398:                EasyMock.expect(this .balancer.all())
1399:                        .andReturn(this .databaseSet);
1400:
1401:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1402:
1403:                this .root.retain(this .databaseSet);
1404:
1405:                EasyMock.expect(this .statement1.executeQuery(sql)).andReturn(
1406:                        resultSet1);
1407:                EasyMock.expect(this .statement2.executeQuery(sql)).andReturn(
1408:                        resultSet2);
1409:
1410:                this .replay();
1411:
1412:                results = this .statement.executeQuery(sql);
1413:
1414:                this .verify();
1415:
1416:                assert Proxy.isProxyClass(results.getClass());
1417:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1418:                        .getObject(this .database1) == resultSet1;
1419:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1420:                        .getObject(this .database2) == resultSet2;
1421:
1422:                this .reset();
1423:
1424:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1425:
1426:                this .expectIdentifiers(sql, null, null);
1427:
1428:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1429:
1430:                EasyMock.expect(this .statement1.getResultSetConcurrency())
1431:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
1432:
1433:                // Select-for-update
1434:                this .expectSelectForUpdateCheck(sql, true);
1435:
1436:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1437:                        .andReturn(this .executor);
1438:
1439:                EasyMock.expect(
1440:                        this .transactionContext.start(EasyMock
1441:                                .isA(InvocationStrategy.class), EasyMock
1442:                                .same(this .connection))).andAnswer(this .anwser);
1443:
1444:                EasyMock.expect(
1445:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1446:                        .andReturn(false);
1447:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1448:                        .andReturn(false);
1449:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1450:                        .andReturn(false);
1451:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1452:                        .andReturn(false);
1453:
1454:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1455:                        this .balancer);
1456:                EasyMock.expect(this .balancer.all())
1457:                        .andReturn(this .databaseSet);
1458:
1459:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1460:
1461:                this .root.retain(this .databaseSet);
1462:
1463:                EasyMock.expect(this .statement1.executeQuery(sql)).andReturn(
1464:                        resultSet1);
1465:                EasyMock.expect(this .statement2.executeQuery(sql)).andReturn(
1466:                        resultSet2);
1467:
1468:                this .replay();
1469:
1470:                results = this .statement.executeQuery(sql);
1471:
1472:                this .verify();
1473:
1474:                assert Proxy.isProxyClass(results.getClass());
1475:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1476:                        .getObject(this .database1) == resultSet1;
1477:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1478:                        .getObject(this .database2) == resultSet2;
1479:
1480:                this .reset();
1481:
1482:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1483:
1484:                this .expectIdentifiers(sql, "sequence", null);
1485:
1486:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1487:
1488:                EasyMock.expect(this .statement1.getResultSetConcurrency())
1489:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
1490:
1491:                this .expectSelectForUpdateCheck(sql, false);
1492:
1493:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1494:                        .andReturn(this .executor);
1495:
1496:                EasyMock.expect(
1497:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1498:                        .andReturn(false);
1499:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1500:                        .andReturn(false);
1501:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1502:                        .andReturn(false);
1503:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1504:                        .andReturn(false);
1505:
1506:                this .sequenceLock.lock();
1507:
1508:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1509:                        this .balancer);
1510:                EasyMock.expect(this .balancer.all())
1511:                        .andReturn(this .databaseSet);
1512:
1513:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1514:
1515:                this .root.retain(this .databaseSet);
1516:
1517:                EasyMock.expect(this .statement1.executeQuery(sql)).andReturn(
1518:                        resultSet1);
1519:                EasyMock.expect(this .statement2.executeQuery(sql)).andReturn(
1520:                        resultSet2);
1521:
1522:                this .sequenceLock.unlock();
1523:
1524:                this .replay();
1525:
1526:                results = this .statement.executeQuery(sql);
1527:
1528:                this .verify();
1529:
1530:                assert Proxy.isProxyClass(results.getClass());
1531:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1532:                        .getObject(this .database1) == resultSet1;
1533:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1534:                        .getObject(this .database2) == resultSet2;
1535:
1536:                this .reset();
1537:
1538:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1539:
1540:                this .expectIdentifiers(sql, null, "table");
1541:
1542:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1543:
1544:                EasyMock.expect(this .statement1.getResultSetConcurrency())
1545:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
1546:
1547:                this .expectSelectForUpdateCheck(sql, false);
1548:
1549:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1550:                        .andReturn(this .executor);
1551:
1552:                EasyMock.expect(
1553:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1554:                        .andReturn(false);
1555:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1556:                        .andReturn(false);
1557:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1558:                        .andReturn(false);
1559:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1560:                        .andReturn(false);
1561:
1562:                this .tableLock.lock();
1563:
1564:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1565:                        this .balancer);
1566:                EasyMock.expect(this .balancer.all())
1567:                        .andReturn(this .databaseSet);
1568:
1569:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1570:
1571:                this .root.retain(this .databaseSet);
1572:
1573:                EasyMock.expect(this .statement1.executeQuery(sql)).andReturn(
1574:                        resultSet1);
1575:                EasyMock.expect(this .statement2.executeQuery(sql)).andReturn(
1576:                        resultSet2);
1577:
1578:                this .tableLock.unlock();
1579:
1580:                this .replay();
1581:
1582:                results = this .statement.executeQuery(sql);
1583:
1584:                this .verify();
1585:
1586:                assert Proxy.isProxyClass(results.getClass());
1587:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1588:                        .getObject(this .database1) == resultSet1;
1589:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1590:                        .getObject(this .database2) == resultSet2;
1591:
1592:                this .reset();
1593:
1594:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1595:
1596:                this .expectIdentifiers(sql, "sequence", "table");
1597:
1598:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1599:
1600:                EasyMock.expect(this .statement1.getResultSetConcurrency())
1601:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
1602:
1603:                this .expectSelectForUpdateCheck(sql, false);
1604:
1605:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1606:                        .andReturn(this .executor);
1607:
1608:                EasyMock.expect(
1609:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1610:                        .andReturn(false);
1611:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1612:                        .andReturn(false);
1613:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1614:                        .andReturn(false);
1615:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1616:                        .andReturn(false);
1617:
1618:                this .sequenceLock.lock();
1619:                this .tableLock.lock();
1620:
1621:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1622:                        this .balancer);
1623:                EasyMock.expect(this .balancer.all())
1624:                        .andReturn(this .databaseSet);
1625:
1626:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1627:
1628:                this .root.retain(this .databaseSet);
1629:
1630:                EasyMock.expect(this .statement1.executeQuery(sql)).andReturn(
1631:                        resultSet1);
1632:                EasyMock.expect(this .statement2.executeQuery(sql)).andReturn(
1633:                        resultSet2);
1634:
1635:                this .sequenceLock.unlock();
1636:                this .tableLock.unlock();
1637:
1638:                this .replay();
1639:
1640:                results = this .statement.executeQuery(sql);
1641:
1642:                this .verify();
1643:
1644:                assert Proxy.isProxyClass(results.getClass());
1645:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1646:                        .getObject(this .database1) == resultSet1;
1647:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
1648:                        .getObject(this .database2) == resultSet2;
1649:
1650:                return results;
1651:            }
1652:
1653:            /**
1654:             * @see java.sql.Statement#executeUpdate(java.lang.String)
1655:             */
1656:            @Test(dataProvider="string")
1657:            public int executeUpdate(String sql) throws SQLException {
1658:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1659:
1660:                this .expectIdentifiers(sql, null, null);
1661:
1662:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1663:                        .andReturn(this .executor);
1664:
1665:                EasyMock.expect(
1666:                        this .transactionContext.start(EasyMock
1667:                                .isA(InvocationStrategy.class), EasyMock
1668:                                .same(this .connection))).andAnswer(this .anwser);
1669:
1670:                EasyMock.expect(
1671:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1672:                        .andReturn(false);
1673:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1674:                        .andReturn(false);
1675:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1676:                        .andReturn(false);
1677:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1678:                        .andReturn(false);
1679:
1680:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1681:                        this .balancer);
1682:                EasyMock.expect(this .balancer.all())
1683:                        .andReturn(this .databaseSet);
1684:
1685:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1686:
1687:                this .root.retain(this .databaseSet);
1688:
1689:                EasyMock.expect(this .statement1.executeUpdate(sql))
1690:                        .andReturn(1);
1691:                EasyMock.expect(this .statement2.executeUpdate(sql))
1692:                        .andReturn(1);
1693:
1694:                this .replay();
1695:
1696:                int result = this .statement.executeUpdate(sql);
1697:
1698:                this .verify();
1699:
1700:                assert result == 1 : result;
1701:
1702:                this .reset();
1703:
1704:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1705:
1706:                this .expectIdentifiers(sql, "sequence", null);
1707:
1708:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1709:                        .andReturn(this .executor);
1710:
1711:                EasyMock.expect(
1712:                        this .transactionContext.start(EasyMock
1713:                                .isA(InvocationStrategy.class), EasyMock
1714:                                .same(this .connection))).andAnswer(this .anwser);
1715:
1716:                EasyMock.expect(
1717:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1718:                        .andReturn(false);
1719:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1720:                        .andReturn(false);
1721:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1722:                        .andReturn(false);
1723:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1724:                        .andReturn(false);
1725:
1726:                this .sequenceLock.lock();
1727:
1728:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1729:                        this .balancer);
1730:                EasyMock.expect(this .balancer.all())
1731:                        .andReturn(this .databaseSet);
1732:
1733:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1734:
1735:                this .root.retain(this .databaseSet);
1736:
1737:                EasyMock.expect(this .statement1.executeUpdate(sql))
1738:                        .andReturn(1);
1739:                EasyMock.expect(this .statement2.executeUpdate(sql))
1740:                        .andReturn(1);
1741:
1742:                this .sequenceLock.unlock();
1743:
1744:                this .replay();
1745:
1746:                result = this .statement.executeUpdate(sql);
1747:
1748:                this .verify();
1749:
1750:                assert result == 1 : result;
1751:
1752:                this .reset();
1753:
1754:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1755:
1756:                this .expectIdentifiers(sql, null, "table");
1757:
1758:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1759:                        .andReturn(this .executor);
1760:
1761:                EasyMock.expect(
1762:                        this .transactionContext.start(EasyMock
1763:                                .isA(InvocationStrategy.class), EasyMock
1764:                                .same(this .connection))).andAnswer(this .anwser);
1765:
1766:                EasyMock.expect(
1767:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1768:                        .andReturn(false);
1769:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1770:                        .andReturn(false);
1771:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1772:                        .andReturn(false);
1773:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1774:                        .andReturn(false);
1775:
1776:                this .tableLock.lock();
1777:
1778:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1779:                        this .balancer);
1780:                EasyMock.expect(this .balancer.all())
1781:                        .andReturn(this .databaseSet);
1782:
1783:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1784:
1785:                this .root.retain(this .databaseSet);
1786:
1787:                EasyMock.expect(this .statement1.executeUpdate(sql))
1788:                        .andReturn(1);
1789:                EasyMock.expect(this .statement2.executeUpdate(sql))
1790:                        .andReturn(1);
1791:
1792:                this .tableLock.unlock();
1793:
1794:                this .replay();
1795:
1796:                result = this .statement.executeUpdate(sql);
1797:
1798:                this .verify();
1799:
1800:                assert result == 1 : result;
1801:
1802:                this .reset();
1803:
1804:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1805:
1806:                this .expectIdentifiers(sql, "sequence", "table");
1807:
1808:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1809:                        .andReturn(this .executor);
1810:
1811:                EasyMock.expect(
1812:                        this .transactionContext.start(EasyMock
1813:                                .isA(InvocationStrategy.class), EasyMock
1814:                                .same(this .connection))).andAnswer(this .anwser);
1815:
1816:                EasyMock.expect(
1817:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1818:                        .andReturn(false);
1819:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1820:                        .andReturn(false);
1821:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1822:                        .andReturn(false);
1823:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1824:                        .andReturn(false);
1825:
1826:                this .sequenceLock.lock();
1827:                this .tableLock.lock();
1828:
1829:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1830:                        this .balancer);
1831:                EasyMock.expect(this .balancer.all())
1832:                        .andReturn(this .databaseSet);
1833:
1834:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1835:
1836:                this .root.retain(this .databaseSet);
1837:
1838:                EasyMock.expect(this .statement1.executeUpdate(sql))
1839:                        .andReturn(1);
1840:                EasyMock.expect(this .statement2.executeUpdate(sql))
1841:                        .andReturn(1);
1842:
1843:                this .sequenceLock.unlock();
1844:                this .tableLock.unlock();
1845:
1846:                this .replay();
1847:
1848:                result = this .statement.executeUpdate(sql);
1849:
1850:                this .verify();
1851:
1852:                assert result == 1 : result;
1853:
1854:                return result;
1855:            }
1856:
1857:            /**
1858:             * @see java.sql.Statement#executeUpdate(java.lang.String, int)
1859:             */
1860:            @Test(dataProvider="string-int")
1861:            public int executeUpdate(String sql, int autoGeneratedKeys)
1862:                    throws SQLException {
1863:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1864:
1865:                this .expectIdentifiers(sql, null, null);
1866:
1867:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1868:                        .andReturn(this .executor);
1869:
1870:                EasyMock.expect(
1871:                        this .transactionContext.start(EasyMock
1872:                                .isA(InvocationStrategy.class), EasyMock
1873:                                .same(this .connection))).andAnswer(this .anwser);
1874:
1875:                EasyMock.expect(
1876:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1877:                        .andReturn(false);
1878:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1879:                        .andReturn(false);
1880:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1881:                        .andReturn(false);
1882:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1883:                        .andReturn(false);
1884:
1885:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1886:                        this .balancer);
1887:                EasyMock.expect(this .balancer.all())
1888:                        .andReturn(this .databaseSet);
1889:
1890:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1891:
1892:                this .root.retain(this .databaseSet);
1893:
1894:                EasyMock.expect(
1895:                        this .statement1.executeUpdate(sql, autoGeneratedKeys))
1896:                        .andReturn(1);
1897:                EasyMock.expect(
1898:                        this .statement2.executeUpdate(sql, autoGeneratedKeys))
1899:                        .andReturn(1);
1900:
1901:                this .replay();
1902:
1903:                int result = this .statement.executeUpdate(sql,
1904:                        autoGeneratedKeys);
1905:
1906:                this .verify();
1907:
1908:                assert result == 1 : result;
1909:
1910:                this .reset();
1911:
1912:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1913:
1914:                this .expectIdentifiers(sql, "sequence", null);
1915:
1916:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1917:                        .andReturn(this .executor);
1918:
1919:                EasyMock.expect(
1920:                        this .transactionContext.start(EasyMock
1921:                                .isA(InvocationStrategy.class), EasyMock
1922:                                .same(this .connection))).andAnswer(this .anwser);
1923:
1924:                EasyMock.expect(
1925:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1926:                        .andReturn(false);
1927:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1928:                        .andReturn(false);
1929:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1930:                        .andReturn(false);
1931:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1932:                        .andReturn(false);
1933:
1934:                this .sequenceLock.lock();
1935:
1936:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1937:                        this .balancer);
1938:                EasyMock.expect(this .balancer.all())
1939:                        .andReturn(this .databaseSet);
1940:
1941:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1942:
1943:                this .root.retain(this .databaseSet);
1944:
1945:                EasyMock.expect(
1946:                        this .statement1.executeUpdate(sql, autoGeneratedKeys))
1947:                        .andReturn(1);
1948:                EasyMock.expect(
1949:                        this .statement2.executeUpdate(sql, autoGeneratedKeys))
1950:                        .andReturn(1);
1951:
1952:                this .sequenceLock.unlock();
1953:
1954:                this .replay();
1955:
1956:                result = this .statement.executeUpdate(sql, autoGeneratedKeys);
1957:
1958:                this .verify();
1959:
1960:                assert result == 1 : result;
1961:
1962:                this .reset();
1963:
1964:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
1965:
1966:                this .expectIdentifiers(sql, null, "table");
1967:
1968:                EasyMock.expect(this .cluster.getTransactionalExecutor())
1969:                        .andReturn(this .executor);
1970:
1971:                EasyMock.expect(
1972:                        this .transactionContext.start(EasyMock
1973:                                .isA(InvocationStrategy.class), EasyMock
1974:                                .same(this .connection))).andAnswer(this .anwser);
1975:
1976:                EasyMock.expect(
1977:                        this .cluster.isCurrentTimestampEvaluationEnabled())
1978:                        .andReturn(false);
1979:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
1980:                        .andReturn(false);
1981:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
1982:                        .andReturn(false);
1983:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
1984:                        .andReturn(false);
1985:
1986:                this .tableLock.lock();
1987:
1988:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
1989:                        this .balancer);
1990:                EasyMock.expect(this .balancer.all())
1991:                        .andReturn(this .databaseSet);
1992:
1993:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
1994:
1995:                this .root.retain(this .databaseSet);
1996:
1997:                EasyMock.expect(
1998:                        this .statement1.executeUpdate(sql, autoGeneratedKeys))
1999:                        .andReturn(1);
2000:                EasyMock.expect(
2001:                        this .statement2.executeUpdate(sql, autoGeneratedKeys))
2002:                        .andReturn(1);
2003:
2004:                this .tableLock.unlock();
2005:
2006:                this .replay();
2007:
2008:                result = this .statement.executeUpdate(sql, autoGeneratedKeys);
2009:
2010:                this .verify();
2011:
2012:                assert result == 1 : result;
2013:
2014:                this .reset();
2015:
2016:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2017:
2018:                this .expectIdentifiers(sql, "sequence", "table");
2019:
2020:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2021:                        .andReturn(this .executor);
2022:
2023:                EasyMock.expect(
2024:                        this .transactionContext.start(EasyMock
2025:                                .isA(InvocationStrategy.class), EasyMock
2026:                                .same(this .connection))).andAnswer(this .anwser);
2027:
2028:                EasyMock.expect(
2029:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2030:                        .andReturn(false);
2031:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2032:                        .andReturn(false);
2033:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2034:                        .andReturn(false);
2035:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2036:                        .andReturn(false);
2037:
2038:                this .sequenceLock.lock();
2039:                this .tableLock.lock();
2040:
2041:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2042:                        this .balancer);
2043:                EasyMock.expect(this .balancer.all())
2044:                        .andReturn(this .databaseSet);
2045:
2046:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2047:
2048:                this .root.retain(this .databaseSet);
2049:
2050:                EasyMock.expect(
2051:                        this .statement1.executeUpdate(sql, autoGeneratedKeys))
2052:                        .andReturn(1);
2053:                EasyMock.expect(
2054:                        this .statement2.executeUpdate(sql, autoGeneratedKeys))
2055:                        .andReturn(1);
2056:
2057:                this .sequenceLock.unlock();
2058:                this .tableLock.unlock();
2059:
2060:                this .replay();
2061:
2062:                result = this .statement.executeUpdate(sql, autoGeneratedKeys);
2063:
2064:                this .verify();
2065:
2066:                assert result == 1 : result;
2067:
2068:                return result;
2069:            }
2070:
2071:            /**
2072:             * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
2073:             */
2074:            @Test(dataProvider="string-ints")
2075:            public int executeUpdate(String sql, int[] columnIndexes)
2076:                    throws SQLException {
2077:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2078:
2079:                this .expectIdentifiers(sql, null, null);
2080:
2081:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2082:                        .andReturn(this .executor);
2083:
2084:                EasyMock.expect(
2085:                        this .transactionContext.start(EasyMock
2086:                                .isA(InvocationStrategy.class), EasyMock
2087:                                .same(this .connection))).andAnswer(this .anwser);
2088:
2089:                EasyMock.expect(
2090:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2091:                        .andReturn(false);
2092:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2093:                        .andReturn(false);
2094:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2095:                        .andReturn(false);
2096:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2097:                        .andReturn(false);
2098:
2099:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2100:                        this .balancer);
2101:                EasyMock.expect(this .balancer.all())
2102:                        .andReturn(this .databaseSet);
2103:
2104:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2105:
2106:                this .root.retain(this .databaseSet);
2107:
2108:                EasyMock.expect(
2109:                        this .statement1.executeUpdate(sql, columnIndexes))
2110:                        .andReturn(1);
2111:                EasyMock.expect(
2112:                        this .statement2.executeUpdate(sql, columnIndexes))
2113:                        .andReturn(1);
2114:
2115:                this .replay();
2116:
2117:                int result = this .statement.executeUpdate(sql, columnIndexes);
2118:
2119:                this .verify();
2120:
2121:                assert result == 1 : result;
2122:
2123:                this .reset();
2124:
2125:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2126:
2127:                this .expectIdentifiers(sql, "sequence", null);
2128:
2129:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2130:                        .andReturn(this .executor);
2131:
2132:                EasyMock.expect(
2133:                        this .transactionContext.start(EasyMock
2134:                                .isA(InvocationStrategy.class), EasyMock
2135:                                .same(this .connection))).andAnswer(this .anwser);
2136:
2137:                EasyMock.expect(
2138:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2139:                        .andReturn(false);
2140:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2141:                        .andReturn(false);
2142:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2143:                        .andReturn(false);
2144:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2145:                        .andReturn(false);
2146:
2147:                this .sequenceLock.lock();
2148:
2149:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2150:                        this .balancer);
2151:                EasyMock.expect(this .balancer.all())
2152:                        .andReturn(this .databaseSet);
2153:
2154:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2155:
2156:                this .root.retain(this .databaseSet);
2157:
2158:                EasyMock.expect(
2159:                        this .statement1.executeUpdate(sql, columnIndexes))
2160:                        .andReturn(1);
2161:                EasyMock.expect(
2162:                        this .statement2.executeUpdate(sql, columnIndexes))
2163:                        .andReturn(1);
2164:
2165:                this .sequenceLock.unlock();
2166:
2167:                this .replay();
2168:
2169:                result = this .statement.executeUpdate(sql, columnIndexes);
2170:
2171:                this .verify();
2172:
2173:                assert result == 1 : result;
2174:
2175:                this .reset();
2176:
2177:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2178:
2179:                this .expectIdentifiers(sql, null, "table");
2180:
2181:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2182:                        .andReturn(this .executor);
2183:
2184:                EasyMock.expect(
2185:                        this .transactionContext.start(EasyMock
2186:                                .isA(InvocationStrategy.class), EasyMock
2187:                                .same(this .connection))).andAnswer(this .anwser);
2188:
2189:                EasyMock.expect(
2190:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2191:                        .andReturn(false);
2192:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2193:                        .andReturn(false);
2194:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2195:                        .andReturn(false);
2196:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2197:                        .andReturn(false);
2198:
2199:                this .tableLock.lock();
2200:
2201:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2202:                        this .balancer);
2203:                EasyMock.expect(this .balancer.all())
2204:                        .andReturn(this .databaseSet);
2205:
2206:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2207:
2208:                this .root.retain(this .databaseSet);
2209:
2210:                EasyMock.expect(
2211:                        this .statement1.executeUpdate(sql, columnIndexes))
2212:                        .andReturn(1);
2213:                EasyMock.expect(
2214:                        this .statement2.executeUpdate(sql, columnIndexes))
2215:                        .andReturn(1);
2216:
2217:                this .tableLock.unlock();
2218:
2219:                this .replay();
2220:
2221:                result = this .statement.executeUpdate(sql, columnIndexes);
2222:
2223:                this .verify();
2224:
2225:                assert result == 1 : result;
2226:
2227:                this .reset();
2228:
2229:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2230:
2231:                this .expectIdentifiers(sql, "sequence", "table");
2232:
2233:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2234:                        .andReturn(this .executor);
2235:
2236:                EasyMock.expect(
2237:                        this .transactionContext.start(EasyMock
2238:                                .isA(InvocationStrategy.class), EasyMock
2239:                                .same(this .connection))).andAnswer(this .anwser);
2240:
2241:                EasyMock.expect(
2242:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2243:                        .andReturn(false);
2244:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2245:                        .andReturn(false);
2246:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2247:                        .andReturn(false);
2248:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2249:                        .andReturn(false);
2250:
2251:                this .sequenceLock.lock();
2252:                this .tableLock.lock();
2253:
2254:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2255:                        this .balancer);
2256:                EasyMock.expect(this .balancer.all())
2257:                        .andReturn(this .databaseSet);
2258:
2259:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2260:
2261:                this .root.retain(this .databaseSet);
2262:
2263:                EasyMock.expect(
2264:                        this .statement1.executeUpdate(sql, columnIndexes))
2265:                        .andReturn(1);
2266:                EasyMock.expect(
2267:                        this .statement2.executeUpdate(sql, columnIndexes))
2268:                        .andReturn(1);
2269:
2270:                this .sequenceLock.unlock();
2271:                this .tableLock.unlock();
2272:
2273:                this .replay();
2274:
2275:                result = this .statement.executeUpdate(sql, columnIndexes);
2276:
2277:                this .verify();
2278:
2279:                assert result == 1 : result;
2280:
2281:                return result;
2282:            }
2283:
2284:            /**
2285:             * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])
2286:             */
2287:            @Test(dataProvider="string-strings")
2288:            public int executeUpdate(String sql, String[] columnNames)
2289:                    throws SQLException {
2290:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2291:
2292:                this .expectIdentifiers(sql, null, null);
2293:
2294:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2295:                        .andReturn(this .executor);
2296:
2297:                EasyMock.expect(
2298:                        this .transactionContext.start(EasyMock
2299:                                .isA(InvocationStrategy.class), EasyMock
2300:                                .same(this .connection))).andAnswer(this .anwser);
2301:
2302:                EasyMock.expect(
2303:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2304:                        .andReturn(false);
2305:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2306:                        .andReturn(false);
2307:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2308:                        .andReturn(false);
2309:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2310:                        .andReturn(false);
2311:
2312:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2313:                        this .balancer);
2314:                EasyMock.expect(this .balancer.all())
2315:                        .andReturn(this .databaseSet);
2316:
2317:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2318:
2319:                this .root.retain(this .databaseSet);
2320:
2321:                EasyMock
2322:                        .expect(this .statement1.executeUpdate(sql, columnNames))
2323:                        .andReturn(1);
2324:                EasyMock
2325:                        .expect(this .statement2.executeUpdate(sql, columnNames))
2326:                        .andReturn(1);
2327:
2328:                this .replay();
2329:
2330:                int result = this .statement.executeUpdate(sql, columnNames);
2331:
2332:                this .verify();
2333:
2334:                assert result == 1 : result;
2335:
2336:                this .reset();
2337:
2338:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2339:
2340:                this .expectIdentifiers(sql, "sequence", null);
2341:
2342:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2343:                        .andReturn(this .executor);
2344:
2345:                EasyMock.expect(
2346:                        this .transactionContext.start(EasyMock
2347:                                .isA(InvocationStrategy.class), EasyMock
2348:                                .same(this .connection))).andAnswer(this .anwser);
2349:
2350:                EasyMock.expect(
2351:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2352:                        .andReturn(false);
2353:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2354:                        .andReturn(false);
2355:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2356:                        .andReturn(false);
2357:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2358:                        .andReturn(false);
2359:
2360:                this .sequenceLock.lock();
2361:
2362:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2363:                        this .balancer);
2364:                EasyMock.expect(this .balancer.all())
2365:                        .andReturn(this .databaseSet);
2366:
2367:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2368:
2369:                this .root.retain(this .databaseSet);
2370:
2371:                EasyMock
2372:                        .expect(this .statement1.executeUpdate(sql, columnNames))
2373:                        .andReturn(1);
2374:                EasyMock
2375:                        .expect(this .statement2.executeUpdate(sql, columnNames))
2376:                        .andReturn(1);
2377:
2378:                this .sequenceLock.unlock();
2379:
2380:                this .replay();
2381:
2382:                result = this .statement.executeUpdate(sql, columnNames);
2383:
2384:                this .verify();
2385:
2386:                assert result == 1 : result;
2387:
2388:                this .reset();
2389:
2390:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2391:
2392:                this .expectIdentifiers(sql, null, "table");
2393:
2394:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2395:                        .andReturn(this .executor);
2396:
2397:                EasyMock.expect(
2398:                        this .transactionContext.start(EasyMock
2399:                                .isA(InvocationStrategy.class), EasyMock
2400:                                .same(this .connection))).andAnswer(this .anwser);
2401:
2402:                EasyMock.expect(
2403:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2404:                        .andReturn(false);
2405:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2406:                        .andReturn(false);
2407:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2408:                        .andReturn(false);
2409:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2410:                        .andReturn(false);
2411:
2412:                this .tableLock.lock();
2413:
2414:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2415:                        this .balancer);
2416:                EasyMock.expect(this .balancer.all())
2417:                        .andReturn(this .databaseSet);
2418:
2419:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2420:
2421:                this .root.retain(this .databaseSet);
2422:
2423:                EasyMock
2424:                        .expect(this .statement1.executeUpdate(sql, columnNames))
2425:                        .andReturn(1);
2426:                EasyMock
2427:                        .expect(this .statement2.executeUpdate(sql, columnNames))
2428:                        .andReturn(1);
2429:
2430:                this .tableLock.unlock();
2431:
2432:                this .replay();
2433:
2434:                result = this .statement.executeUpdate(sql, columnNames);
2435:
2436:                this .verify();
2437:
2438:                assert result == 1 : result;
2439:
2440:                this .reset();
2441:
2442:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2443:
2444:                this .expectIdentifiers(sql, "sequence", "table");
2445:
2446:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2447:                        .andReturn(this .executor);
2448:
2449:                EasyMock.expect(
2450:                        this .transactionContext.start(EasyMock
2451:                                .isA(InvocationStrategy.class), EasyMock
2452:                                .same(this .connection))).andAnswer(this .anwser);
2453:
2454:                EasyMock.expect(
2455:                        this .cluster.isCurrentTimestampEvaluationEnabled())
2456:                        .andReturn(false);
2457:                EasyMock.expect(this .cluster.isCurrentDateEvaluationEnabled())
2458:                        .andReturn(false);
2459:                EasyMock.expect(this .cluster.isCurrentTimeEvaluationEnabled())
2460:                        .andReturn(false);
2461:                EasyMock.expect(this .cluster.isRandEvaluationEnabled())
2462:                        .andReturn(false);
2463:
2464:                this .sequenceLock.lock();
2465:                this .tableLock.lock();
2466:
2467:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2468:                        this .balancer);
2469:                EasyMock.expect(this .balancer.all())
2470:                        .andReturn(this .databaseSet);
2471:
2472:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2473:
2474:                this .root.retain(this .databaseSet);
2475:
2476:                EasyMock
2477:                        .expect(this .statement1.executeUpdate(sql, columnNames))
2478:                        .andReturn(1);
2479:                EasyMock
2480:                        .expect(this .statement2.executeUpdate(sql, columnNames))
2481:                        .andReturn(1);
2482:
2483:                this .sequenceLock.unlock();
2484:                this .tableLock.unlock();
2485:
2486:                this .replay();
2487:
2488:                result = this .statement.executeUpdate(sql, columnNames);
2489:
2490:                this .verify();
2491:
2492:                assert result == 1 : result;
2493:
2494:                return result;
2495:            }
2496:
2497:            /**
2498:             * @see java.sql.Statement#getConnection()
2499:             */
2500:            @Test
2501:            public java.sql.Connection getConnection() throws SQLException {
2502:                /*		EasyMock.expect(this.cluster.isActive()).andReturn(true);
2503:                
2504:                 this.replay();
2505:                
2506:                 java.sql.Connection connection = this.statement.getConnection();
2507:
2508:                 this.verify();
2509:                
2510:                 assert connection == this.connection;
2511:                
2512:                 return connection;
2513:                 */return null;
2514:            }
2515:
2516:            /**
2517:             * @see java.sql.Statement#getFetchDirection()
2518:             */
2519:            @Test
2520:            public int getFetchDirection() throws SQLException {
2521:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2522:
2523:                EasyMock.expect(this .statement1.getFetchDirection()).andReturn(
2524:                        ResultSet.FETCH_FORWARD);
2525:
2526:                this .replay();
2527:
2528:                int result = this .statement.getFetchDirection();
2529:
2530:                this .verify();
2531:
2532:                assert result == ResultSet.FETCH_FORWARD : result;
2533:
2534:                return result;
2535:            }
2536:
2537:            /**
2538:             * @see java.sql.Statement#getFetchSize()
2539:             */
2540:            @Test
2541:            public int getFetchSize() throws SQLException {
2542:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2543:
2544:                EasyMock.expect(this .statement1.getFetchDirection()).andReturn(
2545:                        1);
2546:
2547:                this .replay();
2548:
2549:                int result = this .statement.getFetchDirection();
2550:
2551:                this .verify();
2552:
2553:                assert result == 1 : result;
2554:
2555:                return result;
2556:            }
2557:
2558:            /**
2559:             * @see java.sql.Statement#getGeneratedKeys()
2560:             */
2561:            @Test
2562:            public ResultSet getGeneratedKeys() throws SQLException {
2563:                ResultSet resultSet = EasyMock.createMock(ResultSet.class);
2564:
2565:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2566:
2567:                EasyMock.expect(this .statement1.getGeneratedKeys()).andReturn(
2568:                        resultSet);
2569:
2570:                this .replay();
2571:
2572:                ResultSet results = this .statement.getGeneratedKeys();
2573:
2574:                this .verify();
2575:
2576:                assert results == resultSet : results;
2577:
2578:                return results;
2579:            }
2580:
2581:            /**
2582:             * @see java.sql.Statement#getMaxFieldSize()
2583:             */
2584:            @Test
2585:            public int getMaxFieldSize() throws SQLException {
2586:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2587:
2588:                EasyMock.expect(this .statement1.getMaxFieldSize()).andReturn(1);
2589:
2590:                this .replay();
2591:
2592:                int result = this .statement.getMaxFieldSize();
2593:
2594:                this .verify();
2595:
2596:                assert result == 1 : result;
2597:
2598:                return result;
2599:            }
2600:
2601:            /**
2602:             * @see java.sql.Statement#getMaxRows()
2603:             */
2604:            @Test
2605:            public int getMaxRows() throws SQLException {
2606:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2607:
2608:                EasyMock.expect(this .statement1.getMaxRows()).andReturn(1);
2609:
2610:                this .replay();
2611:
2612:                int result = this .statement.getMaxRows();
2613:
2614:                this .verify();
2615:
2616:                assert result == 1 : result;
2617:
2618:                return result;
2619:            }
2620:
2621:            /**
2622:             * @see java.sql.Statement#getMoreResults()
2623:             */
2624:            @Test
2625:            public boolean getMoreResults() throws SQLException {
2626:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2627:
2628:                EasyMock.expect(this .cluster.getNonTransactionalExecutor())
2629:                        .andReturn(this .executor);
2630:
2631:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2632:                        this .balancer);
2633:                EasyMock.expect(this .balancer.all())
2634:                        .andReturn(this .databaseSet);
2635:
2636:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2637:
2638:                this .root.retain(this .databaseSet);
2639:
2640:                EasyMock.expect(this .statement1.getMoreResults()).andReturn(
2641:                        true);
2642:                EasyMock.expect(this .statement2.getMoreResults()).andReturn(
2643:                        true);
2644:
2645:                this .replay();
2646:
2647:                boolean more = this .statement.getMoreResults();
2648:
2649:                this .verify();
2650:
2651:                assert more;
2652:
2653:                return more;
2654:            }
2655:
2656:            @DataProvider(name="current")
2657:            Object[][] currentProvider() {
2658:                return new Object[][] {
2659:                        new Object[] { Statement.KEEP_CURRENT_RESULT },
2660:                        new Object[] { Statement.CLOSE_ALL_RESULTS } };
2661:            }
2662:
2663:            /**
2664:             * @see java.sql.Statement#getMoreResults(int)
2665:             */
2666:            @Test(dataProvider="current")
2667:            public boolean getMoreResults(int current) throws SQLException {
2668:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2669:
2670:                if (current == Statement.KEEP_CURRENT_RESULT) {
2671:                    EasyMock.expect(this .statement1.getMoreResults(current))
2672:                            .andReturn(true);
2673:                    EasyMock.expect(this .statement2.getMoreResults(current))
2674:                            .andReturn(true);
2675:                } else {
2676:                    EasyMock.expect(this .cluster.getNonTransactionalExecutor())
2677:                            .andReturn(this .executor);
2678:
2679:                    EasyMock.expect(this .cluster.getBalancer()).andReturn(
2680:                            this .balancer);
2681:                    EasyMock.expect(this .balancer.all()).andReturn(
2682:                            this .databaseSet);
2683:
2684:                    EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2685:
2686:                    this .root.retain(this .databaseSet);
2687:
2688:                    EasyMock.expect(this .statement1.getMoreResults(current))
2689:                            .andReturn(true);
2690:                    EasyMock.expect(this .statement2.getMoreResults(current))
2691:                            .andReturn(true);
2692:                }
2693:
2694:                this .replay();
2695:
2696:                boolean more = this .statement.getMoreResults(current);
2697:
2698:                this .verify();
2699:
2700:                assert more;
2701:
2702:                return more;
2703:            }
2704:
2705:            /**
2706:             * @see java.sql.Statement#getQueryTimeout()
2707:             */
2708:            @Test
2709:            public int getQueryTimeout() throws SQLException {
2710:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2711:
2712:                EasyMock.expect(this .statement1.getQueryTimeout()).andReturn(1);
2713:
2714:                this .replay();
2715:
2716:                int result = this .statement.getQueryTimeout();
2717:
2718:                this .verify();
2719:
2720:                assert result == 1 : result;
2721:
2722:                return result;
2723:            }
2724:
2725:            /**
2726:             * @see java.sql.Statement#getResultSet()
2727:             */
2728:            @Test
2729:            public ResultSet getResultSet() throws SQLException {
2730:                ResultSet resultSet1 = EasyMock.createMock(ResultSet.class);
2731:                ResultSet resultSet2 = EasyMock.createMock(ResultSet.class);
2732:
2733:                EasyMock.expect(this .cluster.isActive()).andReturn(true).times(
2734:                        2);
2735:
2736:                // Read-only
2737:                EasyMock.expect(this .statement1.getResultSetConcurrency())
2738:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
2739:
2740:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2741:                        this .balancer);
2742:                EasyMock.expect(this .balancer.next()).andReturn(this .database2);
2743:
2744:                this .balancer.beforeInvocation(this .database2);
2745:
2746:                EasyMock.expect(this .statement2.getResultSet()).andReturn(
2747:                        resultSet2);
2748:
2749:                this .balancer.afterInvocation(this .database2);
2750:
2751:                this .replay();
2752:
2753:                ResultSet results = this .statement.getResultSet();
2754:
2755:                this .verify();
2756:
2757:                assert Proxy.isProxyClass(results.getClass());
2758:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
2759:                        .getObject(this .database2) == resultSet2;
2760:
2761:                this .reset();
2762:
2763:                EasyMock.expect(this .cluster.isActive()).andReturn(true).times(
2764:                        2);
2765:
2766:                // Updatable
2767:                EasyMock.expect(this .statement1.getResultSetConcurrency())
2768:                        .andReturn(ResultSet.CONCUR_UPDATABLE);
2769:
2770:                EasyMock.expect(this .cluster.getTransactionalExecutor())
2771:                        .andReturn(this .executor);
2772:
2773:                EasyMock.expect(this .cluster.getBalancer()).andReturn(
2774:                        this .balancer);
2775:                EasyMock.expect(this .balancer.all())
2776:                        .andReturn(this .databaseSet);
2777:
2778:                EasyMock.expect(this .parent.getRoot()).andReturn(this .root);
2779:
2780:                this .root.retain(this .databaseSet);
2781:
2782:                EasyMock.expect(this .statement1.getResultSet()).andReturn(
2783:                        resultSet1);
2784:                EasyMock.expect(this .statement2.getResultSet()).andReturn(
2785:                        resultSet2);
2786:
2787:                this .replay();
2788:
2789:                results = this .statement.getResultSet();
2790:
2791:                this .verify();
2792:
2793:                assert Proxy.isProxyClass(results.getClass());
2794:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
2795:                        .getObject(this .database1) == resultSet1;
2796:                assert SQLProxy.class.cast(Proxy.getInvocationHandler(results))
2797:                        .getObject(this .database2) == resultSet2;
2798:
2799:                return results;
2800:            }
2801:
2802:            /**
2803:             * @see java.sql.Statement#getResultSetConcurrency()
2804:             */
2805:            @Test
2806:            public int getResultSetConcurrency() throws SQLException {
2807:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2808:
2809:                EasyMock.expect(this .statement1.getResultSetConcurrency())
2810:                        .andReturn(ResultSet.CONCUR_READ_ONLY);
2811:
2812:                this .replay();
2813:
2814:                int result = this .statement.getResultSetConcurrency();
2815:
2816:                this .verify();
2817:
2818:                assert result == ResultSet.CONCUR_READ_ONLY : result;
2819:
2820:                return result;
2821:            }
2822:
2823:            /**
2824:             * @see java.sql.Statement#getResultSetHoldability()
2825:             */
2826:            @Test
2827:            public int getResultSetHoldability() throws SQLException {
2828:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2829:
2830:                EasyMock.expect(this .statement1.getResultSetHoldability())
2831:                        .andReturn(ResultSet.CLOSE_CURSORS_AT_COMMIT);
2832:
2833:                this .replay();
2834:
2835:                int result = this .statement.getResultSetHoldability();
2836:
2837:                this .verify();
2838:
2839:                assert result == ResultSet.CLOSE_CURSORS_AT_COMMIT : result;
2840:
2841:                return result;
2842:            }
2843:
2844:            /**
2845:             * @see java.sql.Statement#getResultSetType()
2846:             */
2847:            @Test
2848:            public int getResultSetType() throws SQLException {
2849:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2850:
2851:                EasyMock.expect(this .statement1.getResultSetType()).andReturn(
2852:                        ResultSet.TYPE_FORWARD_ONLY);
2853:
2854:                this .replay();
2855:
2856:                int result = this .statement.getResultSetType();
2857:
2858:                this .verify();
2859:
2860:                assert result == ResultSet.TYPE_FORWARD_ONLY : result;
2861:
2862:                return result;
2863:            }
2864:
2865:            /**
2866:             * @see java.sql.Statement#getUpdateCount()
2867:             */
2868:            @Test
2869:            public int getUpdateCount() throws SQLException {
2870:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2871:
2872:                EasyMock.expect(this .statement1.getUpdateCount()).andReturn(1);
2873:
2874:                this .replay();
2875:
2876:                int result = this .statement.getUpdateCount();
2877:
2878:                this .verify();
2879:
2880:                assert result == 1 : result;
2881:
2882:                return result;
2883:            }
2884:
2885:            /**
2886:             * @see java.sql.Statement#getWarnings()
2887:             */
2888:            @Test
2889:            public SQLWarning getWarnings() throws SQLException {
2890:                SQLWarning warning = new SQLWarning();
2891:
2892:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2893:
2894:                EasyMock.expect(this .statement1.getWarnings()).andReturn(
2895:                        warning);
2896:
2897:                this .replay();
2898:
2899:                SQLWarning result = this .statement.getWarnings();
2900:
2901:                this .verify();
2902:
2903:                assert result == warning : result;
2904:
2905:                return result;
2906:            }
2907:
2908:            /**
2909:             * @see java.sql.Statement#setCursorName(java.lang.String)
2910:             */
2911:            @Test(dataProvider="string")
2912:            public void setCursorName(String name) throws SQLException {
2913:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2914:
2915:                this .statement1.setCursorName(name);
2916:                this .statement2.setCursorName(name);
2917:
2918:                this .replay();
2919:
2920:                this .statement.setCursorName(name);
2921:
2922:                this .verify();
2923:            }
2924:
2925:            @DataProvider(name="boolean")
2926:            Object[][] booleanProvider() {
2927:                return new Object[][] { new Object[] { true } };
2928:            }
2929:
2930:            /**
2931:             * @see java.sql.Statement#setEscapeProcessing(boolean)
2932:             */
2933:            @Test(dataProvider="boolean")
2934:            public void setEscapeProcessing(boolean enable) throws SQLException {
2935:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2936:
2937:                this .statement1.setEscapeProcessing(enable);
2938:                this .statement2.setEscapeProcessing(enable);
2939:
2940:                this .replay();
2941:
2942:                this .statement.setEscapeProcessing(enable);
2943:
2944:                this .verify();
2945:            }
2946:
2947:            @DataProvider(name="direction")
2948:            Object[][] directionProvider() {
2949:                return new Object[][] { new Object[] { ResultSet.FETCH_FORWARD } };
2950:            }
2951:
2952:            /**
2953:             * @see java.sql.Statement#setFetchDirection(int)
2954:             */
2955:            @Test(dataProvider="direction")
2956:            public void setFetchDirection(int direction) throws SQLException {
2957:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2958:
2959:                this .statement1.setFetchDirection(direction);
2960:                this .statement2.setFetchDirection(direction);
2961:
2962:                this .replay();
2963:
2964:                this .statement.setFetchDirection(direction);
2965:
2966:                this .verify();
2967:            }
2968:
2969:            @DataProvider(name="int")
2970:            Object[][] intProvider() {
2971:                return new Object[][] { new Object[] { 1 } };
2972:            }
2973:
2974:            /**
2975:             * @see java.sql.Statement#setFetchSize(int)
2976:             */
2977:            @Test(dataProvider="int")
2978:            public void setFetchSize(int rows) throws SQLException {
2979:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2980:
2981:                this .statement1.setFetchSize(rows);
2982:                this .statement2.setFetchSize(rows);
2983:
2984:                this .replay();
2985:
2986:                this .statement.setFetchSize(rows);
2987:
2988:                this .verify();
2989:            }
2990:
2991:            /**
2992:             * @see java.sql.Statement#setMaxFieldSize(int)
2993:             */
2994:            @Test(dataProvider="int")
2995:            public void setMaxFieldSize(int max) throws SQLException {
2996:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
2997:
2998:                this .statement1.setMaxFieldSize(max);
2999:                this .statement2.setMaxFieldSize(max);
3000:
3001:                this .replay();
3002:
3003:                this .statement.setMaxFieldSize(max);
3004:
3005:                this .verify();
3006:            }
3007:
3008:            /**
3009:             * @see java.sql.Statement#setMaxRows(int)
3010:             */
3011:            @Test(dataProvider="int")
3012:            public void setMaxRows(int max) throws SQLException {
3013:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3014:
3015:                this .statement1.setMaxRows(max);
3016:                this .statement2.setMaxRows(max);
3017:
3018:                this .replay();
3019:
3020:                this .statement.setMaxRows(max);
3021:
3022:                this .verify();
3023:            }
3024:
3025:            /**
3026:             * @see java.sql.Statement#setQueryTimeout(int)
3027:             */
3028:            @Test(dataProvider="int")
3029:            public void setQueryTimeout(int seconds) throws SQLException {
3030:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3031:
3032:                this .statement1.setQueryTimeout(seconds);
3033:                this .statement2.setQueryTimeout(seconds);
3034:
3035:                this .replay();
3036:
3037:                this .statement.setQueryTimeout(seconds);
3038:
3039:                this .verify();
3040:            }
3041:
3042:            /**
3043:             * @see java.sql.Statement#isClosed()
3044:             */
3045:            @Test
3046:            public boolean isClosed() throws SQLException {
3047:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3048:
3049:                EasyMock.expect(this .statement1.isClosed()).andReturn(true);
3050:
3051:                this .replay();
3052:
3053:                boolean result = this .statement.isClosed();
3054:
3055:                return result;
3056:            }
3057:
3058:            /**
3059:             * @see java.sql.Statement#isPoolable()
3060:             */
3061:            @Test
3062:            public boolean isPoolable() throws SQLException {
3063:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3064:
3065:                EasyMock.expect(this .statement1.isPoolable()).andReturn(true);
3066:
3067:                this .replay();
3068:
3069:                boolean result = this .statement.isPoolable();
3070:
3071:                return result;
3072:            }
3073:
3074:            /**
3075:             * @see java.sql.Statement#setPoolable(boolean)
3076:             */
3077:            @Test(dataProvider="boolean")
3078:            public void setPoolable(boolean poolable) throws SQLException {
3079:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3080:
3081:                this .statement1.setPoolable(poolable);
3082:                this .statement2.setPoolable(poolable);
3083:
3084:                this .replay();
3085:
3086:                this .statement.setPoolable(poolable);
3087:            }
3088:
3089:            @DataProvider(name="class")
3090:            Object[][] classProvider() {
3091:                return new Object[][] { new Object[] { Object.class } };
3092:            }
3093:
3094:            /**
3095:             * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
3096:             */
3097:            @Test(dataProvider="class")
3098:            public boolean isWrapperFor(Class<?> targetClass)
3099:                    throws SQLException {
3100:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3101:
3102:                EasyMock.expect(this .statement1.isWrapperFor(targetClass))
3103:                        .andReturn(true);
3104:
3105:                this .replay();
3106:
3107:                boolean result = this .statement.isWrapperFor(targetClass);
3108:
3109:                return result;
3110:            }
3111:
3112:            /**
3113:             * @see java.sql.Wrapper#unwrap(java.lang.Class)
3114:             */
3115:            @Test(dataProvider="class")
3116:            public <T> T unwrap(Class<T> targetClass) throws SQLException {
3117:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
3118:
3119:                try {
3120:                    EasyMock.expect(this .statement1.unwrap(targetClass))
3121:                            .andReturn(targetClass.newInstance());
3122:
3123:                    this .replay();
3124:
3125:                    T result = this .statement.unwrap(targetClass);
3126:
3127:                    return result;
3128:                } catch (InstantiationException e) {
3129:                    assert false : e;
3130:                    return null;
3131:                } catch (IllegalAccessException e) {
3132:                    assert false : e;
3133:                    return null;
3134:                }
3135:            }
3136:
3137:            protected void expectIdentifiers(String sql, String sequence,
3138:                    String table) throws SQLException {
3139:                EasyMock.expect(this .cluster.isSequenceDetectionEnabled())
3140:                        .andReturn(true);
3141:                EasyMock.expect(this .cluster.getDialect()).andReturn(
3142:                        this .dialect);
3143:                EasyMock.expect(this .dialect.parseSequence(sql)).andReturn(
3144:                        sequence);
3145:
3146:                EasyMock
3147:                        .expect(this .cluster.isIdentityColumnDetectionEnabled())
3148:                        .andReturn(true);
3149:                EasyMock.expect(this .cluster.getDialect()).andReturn(
3150:                        this .dialect);
3151:                EasyMock.expect(this .dialect.parseInsertTable(sql)).andReturn(
3152:                        table);
3153:
3154:                if (table != null) {
3155:                    EasyMock.expect(this .cluster.getDatabaseMetaDataCache())
3156:                            .andReturn(this .metaData);
3157:                    EasyMock.expect(
3158:                            this .metaData.getDatabaseProperties(EasyMock
3159:                                    .same(this .connection))).andReturn(
3160:                            this .databaseProperties);
3161:                    EasyMock.expect(this .databaseProperties.findTable(table))
3162:                            .andReturn(this .tableProperties);
3163:                    EasyMock.expect(this .tableProperties.getIdentityColumns())
3164:                            .andReturn(Collections.singleton("column"));
3165:                    EasyMock.expect(this .tableProperties.getName()).andReturn(
3166:                            table);
3167:                }
3168:
3169:                if ((sequence != null) || (table != null)) {
3170:                    EasyMock.expect(this .cluster.getLockManager()).andReturn(
3171:                            this .lockManager);
3172:
3173:                    if (sequence != null) {
3174:                        EasyMock.expect(this .lockManager.writeLock(sequence))
3175:                                .andReturn(this .sequenceLock);
3176:                    }
3177:
3178:                    if (table != null) {
3179:                        EasyMock.expect(this .lockManager.writeLock(table))
3180:                                .andReturn(this .tableLock);
3181:                    }
3182:                }
3183:            }
3184:
3185:            protected void expectSelectForUpdateCheck(String sql,
3186:                    boolean isSelectForUpdate) throws SQLException {
3187:                EasyMock.expect(this .cluster.getDatabaseMetaDataCache())
3188:                        .andReturn(this .metaData);
3189:                EasyMock.expect(
3190:                        this .metaData.getDatabaseProperties(this .connection))
3191:                        .andReturn(this .databaseProperties);
3192:                EasyMock.expect(
3193:                        this .databaseProperties.supportsSelectForUpdate())
3194:                        .andReturn(true);
3195:
3196:                EasyMock.expect(this.cluster.getDialect()).andReturn(
3197:                        this.dialect);
3198:                EasyMock.expect(this.dialect.isSelectForUpdate(sql)).andReturn(
3199:                        isSelectForUpdate);
3200:            }
3201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.