Source Code Cross Referenced for SpringUnitTransactionalTest.java in  » Testing » springunit-0.6 » org » springunit » framework » 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 » springunit 0.6 » org.springunit.framework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springunit.framework;
018:
019:        import org.springframework.test.AbstractTransactionalSpringContextTests;
020:
021:        /**
022:         * Extends Spring's test framework to support transactional data-driven tests.
023:         * Data-driven tests separate data values from test logic,
024:         * keeping data values in external files and test logic in Java code.
025:         * Every descendent of SpringUnitTransactionalTest is required by convention
026:         * to have a bean called <code><i>Classname</i></code> of type
027:         * SpringUnitContext, where <code><i>Classname</i></code> is
028:         * the simple name of the subclass of SpringUnitTransactionalTest.
029:         * Note that the simple names of subclasses must be unique,
030:         * that is, they must not be distinguished solely by different
031:         * package qualifiers.
032:         * 
033:         * @author <a href="mailto:ted@velkoff.com">Ted Velkoff</a>
034:         *
035:         */
036:        public abstract class SpringUnitTransactionalTest extends
037:                AbstractTransactionalSpringContextTests {
038:
039:            /**
040:             * Default constructor.
041:             */
042:            protected SpringUnitTransactionalTest() {
043:                this (null);
044:            }
045:
046:            /**
047:             * Constructor with JUnit name.
048:             * Sets AutowireMode to "by name" (overriding the default, which is "by type").
049:             * Creates a hierarchy of contexts.
050:             * @param fName Name of JUnit test
051:             */
052:            protected SpringUnitTransactionalTest(String name) {
053:                super (name);
054:                setAutowireMode(AUTOWIRE_BY_NAME);
055:                this .contexts = new HierarchicalSpringUnitContext<SpringUnitTransactionalTest>(
056:                        getClass());
057:            }
058:
059:            /**
060:             * Return list of file names that the
061:             * Spring test framework uses in order to create beans for testing.
062:             * @return Array of string filenames
063:             */
064:            protected final String[] getConfigLocations() {
065:                return this .contexts.getConfigLocations();
066:            }
067:
068:            /**
069:             * Search for object identified by <code>key</code>
070:             * in the hierarchy of contexts.
071:             * @param key Identifier of data value to find
072:             * @return Object if found or null
073:             * @throws Exception if errors occur when using reflection
074:             * to access the SpringUnitContext for any
075:             * class in the list
076:             */
077:            protected final <T> T getObject(String key) throws Exception {
078:                return (T) this .contexts.getObject(key, getName(), this );
079:            }
080:
081:            /**
082:             * Subclasses should override this method to perform any setup operations,
083:             * such as populating a database table, <i>within</i> the transaction
084:             * created by this class.
085:             * <p><b>NB:</b> Not called if there is no transaction management, due to no
086:             * transaction manager being provided in the context.<br/>
087:             * <b>Note:</b> This overriding of <code>onSetUpInTransaction</code>
088:             * is deprecated in SpringUnit and will be removed in a future release.
089:             * Subclasses that previously overrode <code>onSetUpInTransactionAtBeginning</code>
090:             * should instead override this method.
091:             * @throws Exception simply let any exception propagate
092:             */
093:            protected void onSetUpInTransaction() throws Exception {
094:                onSetUpInTransactionAtBeginning();
095:            }
096:
097:            /**
098:             * @deprecated Subclasses should instead override <code>onSetUpInTransaction</code>
099:             * directly.
100:             * This method is maintained for backward compatibility but will be removed
101:             * in a future release. 
102:             * @throws Exception
103:             */
104:            protected void onSetUpInTransactionAtBeginning() throws Exception {
105:            }
106:
107:            /**
108:             * Calls onTearDownAfterTransactionEnds so that subclasses can
109:             * insert behavior at conclusion of transaction.
110:             * The transaction is <i>not open anymore</i> at this point.
111:             * Follows by calling setDirty so that all beans created
112:             * from configuration files are refreshed.
113:             * @throws Exception simply let any exception propagate
114:             */
115:            protected final void onTearDownAfterTransaction() throws Exception {
116:                try {
117:                    onTearDownAfterTransactionEnds();
118:                } finally {
119:                    setDirty();
120:                }
121:            }
122:
123:            /**
124:             * Subclasses can override this method to perform cleanup here.
125:             * The transaction is <i>not open anymore</i> at this point.
126:             * @throws Exception simply let any exception propagate
127:             */
128:            protected void onTearDownAfterTransactionEnds() throws Exception {
129:            }
130:
131:            /**
132:             * Container of the hierarchy of contexts for the test.<br/>
133:             */
134:            private HierarchicalSpringUnitContext<SpringUnitTransactionalTest> contexts;
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.