Source Code Cross Referenced for TestMandatory.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: TestMandatory.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.assertFalse;
027:        import static org.testng.Assert.fail;
028:
029:        import javax.transaction.UserTransaction;
030:
031:        import org.ow2.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction;
032:        import org.ow2.easybeans.tests.common.exception.TransactionException;
033:        import org.ow2.util.log.Log;
034:        import org.ow2.util.log.LogFactory;
035:
036:        /**
037:         * Verifies if the container-managed transaction in the session bean is
038:         * following the JSR 220.The items covered in this test are: 12.6.2.5.
039:         * @reference JSR 220-PROPOSED FINAL
040:         * @requirement Application Server must be running; the bean .
041:         *              objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.SFSBContainerTransactionMandatory
042:         *              must be deployed for testing stateful session bean. And, the
043:         *              bean
044:         *              objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBContainerTransactionMandatory
045:         *              must be deployed for testing stateless session bean.
046:         * @setup gets the reference of the bean and binds the databases specified in
047:         *        the EmbeddedTest.
048:         * @author Gisele Pinheiro Souza
049:         * @author Eduardo Studzinski Estima de Castro
050:         */
051:        public class TestMandatory extends TestContainerTransactionBase {
052:
053:            /**
054:             * Logger.
055:             */
056:            private static Log logger = LogFactory.getLog(TestMandatory.class);
057:
058:            /**
059:             * Verifies if the container uses the same transaction that the client. The
060:             * client rollback must to force a bean rollback, because the both use the
061:             * same transaction.
062:             * @input -
063:             * @output a SQLException because the table must not be created.
064:             * @throws Exception if an error during the tests occurs.
065:             */
066:            @Override
067:            public void testUsingClientTrans() throws Exception {
068:                super .testUsingClientTrans();
069:            }
070:
071:            /**
072:             * Calls a setRollbackOnly and after inserts two tables. The container must
073:             * do a roll back before the method invocation completes. So, the tables
074:             * must not be created and a SQLException must be thrown when the test tries
075:             * to verify if the table exists.
076:             * @input -
077:             * @output an exception when the method verifies if the table exists.
078:             * @throws Exception if an error occurs during the tests.
079:             */
080:            public void testSetRollbackOnlyWithUserTransaction()
081:                    throws Exception {
082:                UserTransaction utx = getUserTransaction();
083:                utx.begin();
084:                try {
085:                    ItfContainerTransaction sfsbContainerTransaction = getBean();
086:                    // calls the setRollbackOnly
087:                    try {
088:                        sfsbContainerTransaction.setRollbackOnly(DATABASE_1,
089:                                DATABASE_2);
090:                    } catch (TransactionException e) {
091:                        throw e.getParentException();
092:                    }
093:                    // tries to commit the transaction
094:                    try {
095:                        utx.commit();
096:                        fail("The transaction is marked as rollback. The client cannot make the commit.");
097:                    } catch (Exception e) {
098:                        logger.debug("Expected exception {0}", e);
099:                    }
100:                } finally {
101:                    assertFalse(
102:                            transactionIsActive(),
103:                            "There was an exception in the server side. The container is using the same transaction "
104:                                    + "that the client, so the cointainer should rollback the transaction.");
105:                }
106:            }
107:
108:            /**
109:             * Calls the getRollbackOnly that must throw an exception for this type of
110:             * transaction attribute.The EJBTransactionRequiredException is thrown,
111:             * because the setRollbackOnly will be called without an transaction
112:             * context.
113:             * @input -
114:             * @output an exception when the method call a method without a transaction
115:             *         context.
116:             * @throws Exception if an error occurs during the tests.
117:             */
118:            public void testSetRollbackOnlyWithoutUserTransaction()
119:                    throws Exception {
120:                try {
121:                    testSetRollbackOnly();
122:                } finally {
123:                    assertFalse(
124:                            transactionIsActive(),
125:                            "There was an exception in the server side. The container is using the same transaction "
126:                                    + "that the client, so the cointainer should rollback the transaction.");
127:                }
128:            }
129:
130:            /**
131:             * Calls the getRollbackOnly that must not throw any exception for this type
132:             * of transaction attribute.
133:             * @input -
134:             * @output the method execution without error.
135:             * @throws Exception if an error occurs during the tests.
136:             */
137:            public void testGetRollbackOnlyWithUserTransaction()
138:                    throws Exception {
139:                UserTransaction utx = getUserTransaction();
140:
141:                utx.begin();
142:                testGetRollbackOnly();
143:                utx.commit();
144:            }
145:
146:            /**
147:             * Calls the getRollbackOnly that must throw an exception for this type of
148:             * transaction attribute.The EJBTransactionRequiredException is thrown,
149:             * because the setRollbackOnly will be called without an transaction
150:             * context.
151:             * @input -
152:             * @output an exception when the method call a method without a transaction
153:             *         context.
154:             * @throws Exception if an error occurs during the tests.
155:             */
156:            public void testGetRollbackOnlyWithoutUserTransaction()
157:                    throws Exception {
158:                testGetRollbackOnly();
159:
160:            }
161:
162:            /**
163:             * @see org.ow2.easybeans.tests.common.interfaces.ItfTestContainerManaged#testGetUserTransactionWithEJBContext()
164:             * @throws Exception if an error occurs during the tests.
165:             */
166:            @Override
167:            public void testGetUserTransactionWithEJBContext() throws Exception {
168:                UserTransaction utx = getUserTransaction();
169:                utx.begin();
170:                try {
171:                    super .testGetUserTransactionWithEJBContext();
172:                } finally {
173:                    utx.rollback();
174:                }
175:            }
176:
177:            /**
178:             * @see org.ow2.easybeans.tests.common.interfaces.ItfTestContainerManaged#testGetUserTransactionWithLookup()
179:             * @throws Exception if an error occurs during the tests.
180:             */
181:            @Override
182:            public void testGetUserTransactionWithLookup() throws Exception {
183:                UserTransaction utx = getUserTransaction();
184:                utx.begin();
185:                try {
186:                    super.testGetUserTransactionWithLookup();
187:                } finally {
188:                    utx.rollback();
189:                }
190:            }
191:
192:        }
w___w__w_.j_av___a___2s_._c__o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.