Source Code Cross Referenced for TestSavepoint.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) 


001:        /*
002:         * HA-JDBC: High-Availability JDBC
003:         * Copyright (c) 2004-2007 Paul Ferraro
004:         * 
005:         * This library is free software; you can redistribute it and/or modify it 
006:         * under the terms of the GNU Lesser General Public License as published by the 
007:         * Free Software Foundation; either version 2.1 of the License, or (at your 
008:         * option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful, but WITHOUT
011:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
012:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
013:         * for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public License
016:         * along with this library; if not, write to the Free Software Foundation, 
017:         * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         * 
019:         * Contact: ferraro@users.sourceforge.net
020:         */
021:        package net.sf.hajdbc.sql;
022:
023:        import java.sql.SQLException;
024:        import java.sql.Savepoint;
025:        import java.util.Map;
026:        import java.util.TreeMap;
027:
028:        import net.sf.hajdbc.Database;
029:        import net.sf.hajdbc.DatabaseCluster;
030:        import net.sf.hajdbc.MockDatabase;
031:        import net.sf.hajdbc.util.reflect.ProxyFactory;
032:
033:        import org.easymock.EasyMock;
034:        import org.testng.annotations.AfterMethod;
035:        import org.testng.annotations.BeforeClass;
036:        import org.testng.annotations.Test;
037:
038:        /**
039:         * @author Paul Ferraro
040:         *
041:         */
042:        @SuppressWarnings({"unchecked","nls"})
043:        public class TestSavepoint implements  Savepoint {
044:            private DatabaseCluster cluster = EasyMock
045:                    .createStrictMock(DatabaseCluster.class);
046:            private Savepoint savepoint1 = EasyMock
047:                    .createStrictMock(java.sql.Savepoint.class);
048:            private Savepoint savepoint2 = EasyMock
049:                    .createStrictMock(java.sql.Savepoint.class);
050:            private SQLProxy parent = EasyMock.createStrictMock(SQLProxy.class);
051:
052:            private Database database1 = new MockDatabase("1");
053:            private Database database2 = new MockDatabase("2");
054:            private Savepoint savepoint;
055:
056:            @BeforeClass
057:            void init() throws Exception {
058:                Map<Database, Savepoint> map = new TreeMap<Database, Savepoint>();
059:                map.put(this .database1, this .savepoint1);
060:                map.put(this .database2, this .savepoint2);
061:
062:                EasyMock.expect(this .parent.getDatabaseCluster()).andReturn(
063:                        this .cluster);
064:
065:                this .parent.addChild(EasyMock
066:                        .isA(SavepointInvocationHandler.class));
067:
068:                this .replay();
069:
070:                this .savepoint = ProxyFactory.createProxy(Savepoint.class,
071:                        new SavepointInvocationHandler(null, this .parent,
072:                                EasyMock.createMock(Invoker.class), map));
073:
074:                this .verify();
075:                this .reset();
076:            }
077:
078:            private Object[] objects() {
079:                return new Object[] { this .cluster, this .savepoint1,
080:                        this .savepoint2, this .parent };
081:            }
082:
083:            void replay() {
084:                EasyMock.replay(this .objects());
085:            }
086:
087:            void verify() {
088:                EasyMock.verify(this .objects());
089:            }
090:
091:            @AfterMethod
092:            void reset() {
093:                EasyMock.reset(this .objects());
094:            }
095:
096:            /**
097:             * @see java.sql.Savepoint#getSavepointId()
098:             */
099:            @Test
100:            public int getSavepointId() throws SQLException {
101:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
102:
103:                EasyMock.expect(this .savepoint1.getSavepointId()).andReturn(1);
104:
105:                this .replay();
106:
107:                int result = this .savepoint.getSavepointId();
108:
109:                this .verify();
110:
111:                assert result == 1;
112:
113:                return result;
114:            }
115:
116:            /**
117:             * @see java.sql.Savepoint#getSavepointName()
118:             */
119:            @Test
120:            public String getSavepointName() throws SQLException {
121:                EasyMock.expect(this .cluster.isActive()).andReturn(true);
122:
123:                EasyMock.expect(this .savepoint1.getSavepointName()).andReturn(
124:                        "");
125:
126:                this .replay();
127:
128:                String result = this .savepoint.getSavepointName();
129:
130:                this .verify();
131:
132:                assert result.equals("");
133:
134:                return result;
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.