Source Code Cross Referenced for TestRequiredException.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » tests » transaction » containermanaged » base » 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 » J2EE » ow2 easybeans » org.ow2.easybeans.tests.transaction.containermanaged.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * EasyBeans
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: easybeans@ow2.org
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 as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: TestRequiredException.java 1970 2007-10-16 11:49:25Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.ow2.easybeans.tests.transaction.containermanaged.base;
025:
026:        import static org.testng.Assert.fail;
027:
028:        import java.sql.SQLException;
029:
030:        import org.ow2.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction;
031:        import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.transaction.ItfTransactionMisc00;
032:        import org.ow2.util.log.Log;
033:        import org.ow2.util.log.LogFactory;
034:
035:        /**
036:         * Verifies if the container-managed transaction in the session bean is
037:         * following the JSR 220. The container must handle the different types of
038:         * exception in the transaction context. The items covered in this test are:
039:         * 13.3
040:         * @reference JSR 220-PROPOSED FINAL
041:         * @requirement Application Server must be running; the bean .
042:         *              SFSBContainerTransactionRequiredApp,
043:         *              SFSBContainerTransactionRequiredRollback and
044:         *              SFSBContainerTransactionRequiredRuntime must be deployed for
045:         *              testing stateful session bean. And, the bean
046:         *              SLSBContainerTransactionRequiredApp,
047:         *              SLSBContainerTransactionRequiredRollback and
048:         *              SLSBContainerTransactionRequiredRuntime must be deployed for
049:         *              testing stateless session bean.
050:         * @setup gets the reference of the bean and binds the databases specified in
051:         *        the EmbeddedTest.
052:         * @author Gisele Pinheiro Souza
053:         * @author Eduardo Studzinski Estima de Castro
054:         */
055:        public abstract class TestRequiredException extends
056:                TestContainerTransactionException {
057:
058:            /**
059:             * Logger.
060:             */
061:            private static Log logger = LogFactory
062:                    .getLog(TestRequiredException.class);
063:
064:            /**
065:             * Verifies if the container does not use the same transaction when the
066:             * other bean has the transaction attribute NOT_SUPPORTED.The bean method
067:             * throws a runtime exception.
068:             * @input -
069:             * @output the method execution without error
070:             * @throws Exception if an error during the tests occurs.
071:             */
072:            @Override
073:            public void testCallOtherBeanNotSup() throws Exception {
074:                super .testCallOtherBeanNotSup();
075:                verifyOtherBeanNotSupport();
076:            }
077:
078:            /**
079:             * Verifies if the container uses the same transaction when the other bean
080:             * has the transaction attribute REQUIRED. The bean method
081:             * throws a runtime exception.
082:             * @input -
083:             * @output the method execution without error
084:             * @throws Exception if an error during the tests occurs.
085:             */
086:            @Override
087:            public void testCallOtherBeanReq() throws Exception {
088:                super .testCallOtherBeanReq();
089:                verifyOtherBeanReq();
090:            }
091:
092:            /**
093:             * Verifies if the container made a rollback only in the method required.The
094:             * method with transaction attribute not_supported must no be in the
095:             * transaction context.
096:             * @throws Exception if an error occurs.
097:             */
098:            private void verifyOtherBeanNotSupport() throws Exception {
099:                // verifies if the transaction in the bean was rolled back.
100:                try {
101:                    ExceptionHandleUtil.verifyTable(DATABASE_1,
102:                            ItfContainerTransaction.TABLE);
103:                    fail("The container did not make a rollback in the transaction.");
104:                } catch (SQLException e) {
105:                    logger.debug("The test threw an expected exception {0}", e);
106:                }
107:                // verifies if the table in the second bean was destroyed. This table
108:                // must not to be destroyed because the other bean has the transaction
109:                // atttribute NOT_SUPPORTED.
110:                try {
111:                    ExceptionHandleUtil.verifyTable(DATABASE_2,
112:                            ItfTransactionMisc00.TABLE);
113:                } catch (SQLException e) {
114:                    fail("The container made a rollback in the transaction.");
115:                }
116:            }
117:
118:            /**
119:             * Verifies if the bean makes a rollback in the both bean method. The
120:             * methods have the transaction attribute required, so they must stay in the
121:             * same transaction context.
122:             * @throws Exception if a problem occurs.
123:             */
124:            private void verifyOtherBeanReq() throws Exception {
125:                // verifies if the transaction in the bean was rolled back.
126:                try {
127:                    ExceptionHandleUtil.verifyTable(DATABASE_1,
128:                            ItfContainerTransaction.TABLE);
129:                    fail("The container did not make a rollback in the transaction.");
130:                } catch (SQLException e) {
131:                    logger.debug("The test threw an expected exception {0}", e);
132:                }
133:                // verifies if the table in the second bean was destroyed. This table
134:                // must to be destroyed because the two beans are using the same
135:                // transaction.
136:                try {
137:                    ExceptionHandleUtil.verifyTable(DATABASE_2,
138:                            ItfTransactionMisc00.TABLE);
139:                    fail("The container did not make a rollback in the transaction.");
140:                } catch (SQLException e) {
141:                    logger.debug("The test threw an expected exception {0}", e);
142:                }
143:            }
144:
145:        }
w_ww_._j__a__v___a__2___s___.c_o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.