Source Code Cross Referenced for DbUnitFixture.java in  » Testing » DDSteps » org » ddsteps » fixture » dbunit » 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 » Testing » DDSteps » org.ddsteps.fixture.dbunit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* DbUnitFixture.java
002:         * 
003:         * DDSteps - Data Driven JUnit Test Steps
004:         * Copyright (C) 2005 Jayway AB
005:         * 
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License version 2.1 as published by the Free Software Foundation.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, visit 
017:         * http://www.opensource.org/licenses/lgpl-license.php
018:         */
019:        package org.ddsteps.fixture.dbunit;
020:
021:        import java.sql.SQLException;
022:
023:        import org.apache.commons.lang.Validate;
024:        import org.dbunit.DatabaseUnitException;
025:        import org.dbunit.database.IDatabaseConnection;
026:        import org.dbunit.dataset.IDataSet;
027:        import org.dbunit.operation.DatabaseOperation;
028:        import org.ddsteps.dbunit.DatabaseConnectionFactory;
029:        import org.ddsteps.fixture.Fixture;
030:
031:        /**
032:         * @author adam
033:         * @version $Id: DbUnitFixture.java,v 1.1 2005/12/03 12:51:41 adamskogman Exp $
034:         */
035:        public class DbUnitFixture implements  Fixture {
036:
037:            /**
038:             * Serializable
039:             */
040:            private static final long serialVersionUID = -3983223493590352621L;
041:
042:            /**
043:             * Dependency: Database Connection Factory
044:             */
045:            protected final DatabaseConnectionFactory connectionFactory;
046:
047:            /**
048:             * Property: The data set containing the fixture.
049:             */
050:            protected final IDataSet dataSet;
051:
052:            /**
053:             * Property: The setup operation. Default is clean insert.
054:             */
055:            protected DatabaseOperation setUpOperation = DatabaseOperation.CLEAN_INSERT;
056:
057:            /**
058:             * Property: The tearDown operation. Default is none.
059:             */
060:            protected DatabaseOperation tearDownOperation = DatabaseOperation.NONE;
061:
062:            /**
063:             * Dependency Injection constructor.
064:             * 
065:             * @param connectionFactory The connection factory
066:             * @param dataSet The dataset
067:             */
068:            public DbUnitFixture(DatabaseConnectionFactory connectionFactory,
069:                    IDataSet dataSet) {
070:                super ();
071:                Validate.notNull(connectionFactory,
072:                        "Argument connectionFactory must not be null");
073:                Validate.notNull(dataSet, "Argument dataSet must not be null");
074:                this .connectionFactory = connectionFactory;
075:                this .dataSet = dataSet;
076:            }
077:
078:            /**
079:             * Executes the setup opertation on the provided dataset.
080:             * 
081:             * @throws SQLException
082:             * @throws DatabaseUnitException
083:             * @see org.ddsteps.fixture.Fixture#setUp()
084:             */
085:            public void setUp() throws DatabaseUnitException, SQLException {
086:                executeOperation(setUpOperation);
087:            }
088:
089:            /**
090:             * Executes the teardown opertation on the provided dataset.
091:             * 
092:             * @throws SQLException
093:             * @throws DatabaseUnitException
094:             * @see org.ddsteps.fixture.Fixture#tearDown()
095:             */
096:            public void tearDown() throws DatabaseUnitException, SQLException {
097:                executeOperation(tearDownOperation);
098:            }
099:
100:            /**
101:             * Courtesy of DbUnit... :-)
102:             * 
103:             * @param operation The operation.
104:             * @throws SQLException
105:             * @throws DatabaseUnitException
106:             */
107:            protected void executeOperation(DatabaseOperation operation)
108:                    throws DatabaseUnitException, SQLException {
109:                if (operation != DatabaseOperation.NONE) {
110:                    IDatabaseConnection connection = connectionFactory
111:                            .getConnection();
112:                    try {
113:                        operation.execute(connection, dataSet);
114:                    } finally {
115:                        connection.close();
116:                    }
117:                }
118:            }
119:
120:            /**
121:             * @return Returns the setUpOperation.
122:             */
123:            public DatabaseOperation getSetUpOperation() {
124:                return setUpOperation;
125:            }
126:
127:            /**
128:             * @param setUpOperation The setUpOperation to set.
129:             */
130:            public void setSetUpOperation(DatabaseOperation setUpOperation) {
131:                this .setUpOperation = setUpOperation;
132:            }
133:
134:            /**
135:             * @return Returns the tearDownOperation.
136:             */
137:            public DatabaseOperation getTearDownOperation() {
138:                return tearDownOperation;
139:            }
140:
141:            /**
142:             * @param tearDownOperation The tearDownOperation to set.
143:             */
144:            public void setTearDownOperation(DatabaseOperation tearDownOperation) {
145:                this .tearDownOperation = tearDownOperation;
146:            }
147:
148:            /**
149:             * Gets the backing dataset. Used for unit test mainly.
150:             * 
151:             * @return Returns the dataSet.
152:             */
153:            public IDataSet getDataSet() {
154:                return dataSet;
155:            }
156:
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.