Source Code Cross Referenced for F_RollbackMDB.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » clients » jms » 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 » JOnAS 4.8.6 » org.objectweb.jonas.jtests.clients.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.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: F_RollbackMDB.java 1971 2003-04-17 13:40:28Z coqp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.clients.jms;
027:
028:        import javax.naming.NamingException;
029:        import javax.rmi.PortableRemoteObject;
030:        import junit.framework.Test;
031:        import junit.framework.TestSuite;
032:        import org.objectweb.jonas.jtests.util.JTestCase;
033:        import org.objectweb.jonas.jtests.beans.message.Sender;
034:        import org.objectweb.jonas.jtests.beans.message.SenderHome;
035:        import org.objectweb.jonas.jtests.beans.message.Sender1_1;
036:        import org.objectweb.jonas.jtests.beans.message.Sender1_1Home;
037:
038:        public class F_RollbackMDB extends JTestCase {
039:
040:            private static String BEAN_HOME = "messageSenderSFHome";
041:            private static String BEAN1_1_HOME = "messageSender1_1SFHome";
042:            protected static SenderHome home = null;
043:            protected static Sender1_1Home home1 = null;
044:
045:            public F_RollbackMDB(String name) {
046:                super (name);
047:            }
048:
049:            public SenderHome getHome() {
050:                if (home == null) {
051:                    try {
052:                        home = (SenderHome) PortableRemoteObject.narrow(ictx
053:                                .lookup(BEAN_HOME), SenderHome.class);
054:                    } catch (NamingException e) {
055:                        fail("Cannot get bean home");
056:                    }
057:                }
058:                return home;
059:            }
060:
061:            public Sender1_1Home getHome1() {
062:                if (home1 == null) {
063:                    try {
064:                        home1 = (Sender1_1Home) PortableRemoteObject.narrow(
065:                                ictx.lookup(BEAN1_1_HOME), Sender1_1Home.class);
066:                    } catch (NamingException e) {
067:                        fail("Cannot get bean home1");
068:                    }
069:                }
070:                return home1;
071:            }
072:
073:            /**
074:             * init environment:
075:             * - load beans
076:             * - create/init database for entities.
077:             */
078:            protected void setUp() {
079:                super .setUp();
080:                useBeans("message", true);
081:            }
082:
083:            // --------------------------------------------------------
084:            //  Tests Rollback
085:            // --------------------------------------------------------
086:
087:            /**
088:             * send a message on a topic in a transaction rolled back
089:             */
090:            public void testRollbackSendOnTopic1() throws Exception {
091:                Sender s = getHome().create();
092:                int val = 204;
093:                utx.begin();
094:                s.sendOnTopic("JunitTopic1", val, 1);
095:                utx.rollback();
096:                assertEquals(0, s.check(val, 2, 4));
097:                s.remove();
098:            }
099:
100:            /**
101:             * send a message on a topic in a transaction rolled back
102:             * via Sender1_1SF and JMS1.1 interfaces
103:             */
104:            public void testRollbackSendOnDestTopic1() throws Exception {
105:                Sender1_1 s = getHome1().create();
106:                int val = 204;
107:                utx.begin();
108:                s.sendOnDestination("JunitTopic1", val, 1);
109:                utx.rollback();
110:                assertEquals(0, s.check(val, 2, 4));
111:                s.remove();
112:            }
113:
114:            /**
115:             * send a message on a queue in a transaction rolled back
116:             * MDB transacted.
117:             */
118:            public void testRollbackSendOnQueue1() throws Exception {
119:                Sender s = getHome().create();
120:                int val = 104;
121:                utx.begin();
122:                s.sendOnQueue("JunitQueue1", val, 1);
123:                utx.rollback();
124:                assertEquals(0, s.check(val, 1, 4));
125:                s.remove();
126:            }
127:
128:            /**
129:             * send a message on a queue in a transaction rolled back
130:             * MDB transacted.
131:             * via Sender1_1SF and JMS1.1 interfaces
132:             */
133:            public void testRollbackSendOnDestQueue1() throws Exception {
134:                Sender1_1 s = getHome1().create();
135:                int val = 104;
136:                utx.begin();
137:                s.sendOnDestination("JunitQueue1", val, 1);
138:                utx.rollback();
139:                assertEquals(0, s.check(val, 1, 4));
140:                s.remove();
141:            }
142:
143:            /**
144:             * Test that it's possible to set rollback only in a message driven
145:             * 2 MDB are listening queue3, but 1 of them rollback all messages.
146:             * So, we should receive all messages by the commiting MDB.
147:             */
148:            public void testRollbackOnlyOnQueue3() throws Exception {
149:                Sender s = getHome().create();
150:                int val = 114;
151:                int nb = 25;
152:                s.sendOnQueue("JunitQueue3", val, nb);
153:                assertEquals(nb, s.check(val, nb, 10));
154:                s.remove();
155:            }
156:
157:            /**
158:             * Test that it's possible to set rollback only in a message driven
159:             * 2 MDB are listening queue3, but 1 of them rollback all messages.
160:             * So, we should receive all messages by the commiting MDB.
161:             * via Sender1_1SF and JMS1.1 interfaces
162:             */
163:            public void testRollbackOnlyOnDestQueue3() throws Exception {
164:                Sender1_1 s = getHome1().create();
165:                int val = 114;
166:                int nb = 25;
167:                s.sendOnDestination("JunitQueue3", val, nb);
168:                assertEquals(nb, s.check(val, nb, 10));
169:                s.remove();
170:            }
171:
172:            /**
173:             * Run all the tests
174:             */
175:            public static Test suite() {
176:                return new TestSuite(F_RollbackMDB.class);
177:            }
178:
179:            public static void main(String args[]) {
180:                String testtorun = null;
181:                // Get args
182:                for (int argn = 0; argn < args.length; argn++) {
183:                    String s_arg = args[argn];
184:                    Integer i_arg;
185:                    if (s_arg.equals("-n")) {
186:                        testtorun = args[++argn];
187:                    }
188:                }
189:                if (testtorun == null) {
190:                    junit.textui.TestRunner.run(suite());
191:                } else {
192:                    junit.textui.TestRunner.run(new F_RollbackMDB(testtorun));
193:                }
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.