Source Code Cross Referenced for CreateCancelTestCase.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » txtimer » test » 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 » EJB Server JBoss 4.2.1 » testsuite » org.jboss.test.txtimer.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.test.txtimer.test;
023:
024:        import java.util.List;
025:
026:        import javax.management.MBeanServerInvocationHandler;
027:        import javax.naming.InitialContext;
028:
029:        import junit.framework.TestSuite;
030:
031:        import org.jboss.ejb.txtimer.DatabasePersistencePolicyMBean;
032:        import org.jboss.test.JBossTestCase;
033:        import org.jboss.test.txtimer.interfaces.TimerTest;
034:        import org.jboss.test.txtimer.interfaces.TimerTestHome;
035:
036:        /**
037:         * Test the Tx timer creation/cancelation for every tx setting
038:         * 
039:         * @author Dimitris.Andreadis@jboss.org
040:         * @version $Revision: 57211 $
041:         */
042:        public class CreateCancelTestCase extends JBossTestCase {
043:            DatabasePersistencePolicyMBean pp;
044:
045:            public CreateCancelTestCase(String name) {
046:                super (name);
047:            }
048:
049:            protected void setUp() throws Exception {
050:                super .setUp();
051:                pp = (DatabasePersistencePolicyMBean) MBeanServerInvocationHandler
052:                        .newProxyInstance(getServer(),
053:                                DatabasePersistencePolicyMBean.OBJECT_NAME,
054:                                DatabasePersistencePolicyMBean.class, false);
055:            }
056:
057:            protected int getTimerCount() {
058:                List timerHandles = pp.listTimerHandles();
059:                return timerHandles.size();
060:            }
061:
062:            public static TestSuite suite() throws Exception {
063:                TestSuite ts = new TestSuite();
064:                ts.addTest(getDeploySetup(CreateCancelTestCase.class,
065:                        "ejb-txtimer.jar"));
066:                return ts;
067:            }
068:
069:            public void testCreateRequiredCancelRequired() throws Exception {
070:                InitialContext iniCtx = getInitialContext();
071:                TimerTestHome home = (TimerTestHome) iniCtx
072:                        .lookup(TimerTestHome.JNDI_NAME);
073:                TimerTest session = home.create();
074:
075:                try {
076:                    int initialTimerCount;
077:                    int createdTimerCount;
078:                    int canceledTimerCount;
079:
080:                    initialTimerCount = getTimerCount();
081:                    session.startTimerInTxRequired();
082:                    createdTimerCount = getTimerCount();
083:                    assertEquals("Timer not created", initialTimerCount + 1,
084:                            createdTimerCount);
085:                    session.cancelTimerInTxRequired();
086:                    canceledTimerCount = getTimerCount();
087:                    assertEquals("Timer not canceled", createdTimerCount,
088:                            canceledTimerCount + 1);
089:                } finally {
090:                    session.remove();
091:                }
092:            }
093:
094:            public void testCreateRequiredCancelRequiresNew() throws Exception {
095:                InitialContext iniCtx = getInitialContext();
096:                TimerTestHome home = (TimerTestHome) iniCtx
097:                        .lookup(TimerTestHome.JNDI_NAME);
098:                TimerTest session = home.create();
099:
100:                try {
101:                    int initialTimerCount;
102:                    int createdTimerCount;
103:                    int canceledTimerCount;
104:
105:                    initialTimerCount = getTimerCount();
106:                    session.startTimerInTxRequired();
107:                    createdTimerCount = getTimerCount();
108:                    assertEquals("Timer not created", initialTimerCount + 1,
109:                            createdTimerCount);
110:                    session.cancelTimerInTxRequiresNew();
111:                    canceledTimerCount = getTimerCount();
112:                    assertEquals("Timer not canceled", createdTimerCount,
113:                            canceledTimerCount + 1);
114:                } finally {
115:                    session.remove();
116:                }
117:            }
118:
119:            public void testCreateRequiredCancelNotSupported() throws Exception {
120:                InitialContext iniCtx = getInitialContext();
121:                TimerTestHome home = (TimerTestHome) iniCtx
122:                        .lookup(TimerTestHome.JNDI_NAME);
123:                TimerTest session = home.create();
124:
125:                try {
126:                    int initialTimerCount;
127:                    int createdTimerCount;
128:                    int canceledTimerCount;
129:
130:                    initialTimerCount = getTimerCount();
131:                    session.startTimerInTxRequired();
132:                    createdTimerCount = getTimerCount();
133:                    assertEquals("Timer not created", initialTimerCount + 1,
134:                            createdTimerCount);
135:                    session.cancelTimerInTxNotSupported();
136:                    canceledTimerCount = getTimerCount();
137:                    assertEquals("Timer not canceled", createdTimerCount,
138:                            canceledTimerCount + 1);
139:                } finally {
140:                    session.remove();
141:                }
142:            }
143:
144:            public void testCreateRequiredCancelNever() throws Exception {
145:                InitialContext iniCtx = getInitialContext();
146:                TimerTestHome home = (TimerTestHome) iniCtx
147:                        .lookup(TimerTestHome.JNDI_NAME);
148:                TimerTest session = home.create();
149:
150:                try {
151:                    int initialTimerCount;
152:                    int createdTimerCount;
153:                    int canceledTimerCount;
154:
155:                    initialTimerCount = getTimerCount();
156:                    session.startTimerInTxRequired();
157:                    createdTimerCount = getTimerCount();
158:                    assertEquals("Timer not created", initialTimerCount + 1,
159:                            createdTimerCount);
160:                    session.cancelTimerInTxNever();
161:                    canceledTimerCount = getTimerCount();
162:                    assertEquals("Timer not canceled", createdTimerCount,
163:                            canceledTimerCount + 1);
164:                } finally {
165:                    session.remove();
166:                }
167:            }
168:
169:            public void testCreateRequiresNewCancelRequired() throws Exception {
170:                InitialContext iniCtx = getInitialContext();
171:                TimerTestHome home = (TimerTestHome) iniCtx
172:                        .lookup(TimerTestHome.JNDI_NAME);
173:                TimerTest session = home.create();
174:
175:                try {
176:                    int initialTimerCount;
177:                    int createdTimerCount;
178:                    int canceledTimerCount;
179:
180:                    initialTimerCount = getTimerCount();
181:                    session.startTimerInTxRequiresNew();
182:                    createdTimerCount = getTimerCount();
183:                    assertEquals("Timer not created", initialTimerCount + 1,
184:                            createdTimerCount);
185:                    session.cancelTimerInTxRequired();
186:                    canceledTimerCount = getTimerCount();
187:                    assertEquals("Timer not canceled", createdTimerCount,
188:                            canceledTimerCount + 1);
189:                } finally {
190:                    session.remove();
191:                }
192:            }
193:
194:            public void testCreateRequiresNewCancelRequiresNew()
195:                    throws Exception {
196:                InitialContext iniCtx = getInitialContext();
197:                TimerTestHome home = (TimerTestHome) iniCtx
198:                        .lookup(TimerTestHome.JNDI_NAME);
199:                TimerTest session = home.create();
200:
201:                try {
202:                    int initialTimerCount;
203:                    int createdTimerCount;
204:                    int canceledTimerCount;
205:
206:                    initialTimerCount = getTimerCount();
207:                    session.startTimerInTxRequiresNew();
208:                    createdTimerCount = getTimerCount();
209:                    assertEquals("Timer not created", initialTimerCount + 1,
210:                            createdTimerCount);
211:                    session.cancelTimerInTxRequiresNew();
212:                    canceledTimerCount = getTimerCount();
213:                    assertEquals("Timer not canceled", createdTimerCount,
214:                            canceledTimerCount + 1);
215:                } finally {
216:                    session.remove();
217:                }
218:            }
219:
220:            public void testCreateRequiresNewCancelNotSupported()
221:                    throws Exception {
222:                InitialContext iniCtx = getInitialContext();
223:                TimerTestHome home = (TimerTestHome) iniCtx
224:                        .lookup(TimerTestHome.JNDI_NAME);
225:                TimerTest session = home.create();
226:
227:                try {
228:                    int initialTimerCount;
229:                    int createdTimerCount;
230:                    int canceledTimerCount;
231:
232:                    initialTimerCount = getTimerCount();
233:                    session.startTimerInTxRequiresNew();
234:                    createdTimerCount = getTimerCount();
235:                    assertEquals("Timer not created", initialTimerCount + 1,
236:                            createdTimerCount);
237:                    session.cancelTimerInTxNotSupported();
238:                    canceledTimerCount = getTimerCount();
239:                    assertEquals("Timer not canceled", createdTimerCount,
240:                            canceledTimerCount + 1);
241:                } finally {
242:                    session.remove();
243:                }
244:            }
245:
246:            public void testCreateRequiresNewCancelNever() throws Exception {
247:                InitialContext iniCtx = getInitialContext();
248:                TimerTestHome home = (TimerTestHome) iniCtx
249:                        .lookup(TimerTestHome.JNDI_NAME);
250:                TimerTest session = home.create();
251:
252:                try {
253:                    int initialTimerCount;
254:                    int createdTimerCount;
255:                    int canceledTimerCount;
256:
257:                    initialTimerCount = getTimerCount();
258:                    session.startTimerInTxRequiresNew();
259:                    createdTimerCount = getTimerCount();
260:                    assertEquals("Timer not created", initialTimerCount + 1,
261:                            createdTimerCount);
262:                    session.cancelTimerInTxNever();
263:                    canceledTimerCount = getTimerCount();
264:                    assertEquals("Timer not canceled", createdTimerCount,
265:                            canceledTimerCount + 1);
266:                } finally {
267:                    session.remove();
268:                }
269:            }
270:
271:            public void testCreateNotSupportedCancelRequired() throws Exception {
272:                InitialContext iniCtx = getInitialContext();
273:                TimerTestHome home = (TimerTestHome) iniCtx
274:                        .lookup(TimerTestHome.JNDI_NAME);
275:                TimerTest session = home.create();
276:
277:                try {
278:                    int initialTimerCount;
279:                    int createdTimerCount;
280:                    int canceledTimerCount;
281:
282:                    initialTimerCount = getTimerCount();
283:                    session.startTimerInTxNotSupported();
284:                    createdTimerCount = getTimerCount();
285:                    assertEquals("Timer not created", initialTimerCount + 1,
286:                            createdTimerCount);
287:                    session.cancelTimerInTxRequired();
288:                    canceledTimerCount = getTimerCount();
289:                    assertEquals("Timer not canceled", createdTimerCount,
290:                            canceledTimerCount + 1);
291:                } finally {
292:                    session.remove();
293:                }
294:            }
295:
296:            public void testCreateNotSupportedCancelRequiresNew()
297:                    throws Exception {
298:                InitialContext iniCtx = getInitialContext();
299:                TimerTestHome home = (TimerTestHome) iniCtx
300:                        .lookup(TimerTestHome.JNDI_NAME);
301:                TimerTest session = home.create();
302:
303:                try {
304:                    int initialTimerCount;
305:                    int createdTimerCount;
306:                    int canceledTimerCount;
307:
308:                    initialTimerCount = getTimerCount();
309:                    session.startTimerInTxNotSupported();
310:                    createdTimerCount = getTimerCount();
311:                    assertEquals("Timer not created", initialTimerCount + 1,
312:                            createdTimerCount);
313:                    session.cancelTimerInTxRequiresNew();
314:                    canceledTimerCount = getTimerCount();
315:                    assertEquals("Timer not canceled", createdTimerCount,
316:                            canceledTimerCount + 1);
317:                } finally {
318:                    session.remove();
319:                }
320:            }
321:
322:            public void testCreateNotSupportedCancelNotSupported()
323:                    throws Exception {
324:                InitialContext iniCtx = getInitialContext();
325:                TimerTestHome home = (TimerTestHome) iniCtx
326:                        .lookup(TimerTestHome.JNDI_NAME);
327:                TimerTest session = home.create();
328:
329:                try {
330:                    int initialTimerCount;
331:                    int createdTimerCount;
332:                    int canceledTimerCount;
333:
334:                    initialTimerCount = getTimerCount();
335:                    session.startTimerInTxNotSupported();
336:                    createdTimerCount = getTimerCount();
337:                    assertEquals("Timer not created", initialTimerCount + 1,
338:                            createdTimerCount);
339:                    session.cancelTimerInTxNotSupported();
340:                    canceledTimerCount = getTimerCount();
341:                    assertEquals("Timer not canceled", createdTimerCount,
342:                            canceledTimerCount + 1);
343:                } finally {
344:                    session.remove();
345:                }
346:            }
347:
348:            public void testCreateNotSupportedCancelNever() throws Exception {
349:                InitialContext iniCtx = getInitialContext();
350:                TimerTestHome home = (TimerTestHome) iniCtx
351:                        .lookup(TimerTestHome.JNDI_NAME);
352:                TimerTest session = home.create();
353:
354:                try {
355:                    int initialTimerCount;
356:                    int createdTimerCount;
357:                    int canceledTimerCount;
358:
359:                    initialTimerCount = getTimerCount();
360:                    session.startTimerInTxNotSupported();
361:                    createdTimerCount = getTimerCount();
362:                    assertEquals("Timer not created", initialTimerCount + 1,
363:                            createdTimerCount);
364:                    session.cancelTimerInTxNever();
365:                    canceledTimerCount = getTimerCount();
366:                    assertEquals("Timer not canceled", createdTimerCount,
367:                            canceledTimerCount + 1);
368:                } finally {
369:                    session.remove();
370:                }
371:            }
372:
373:            public void testCreateNeverCancelRequired() throws Exception {
374:                InitialContext iniCtx = getInitialContext();
375:                TimerTestHome home = (TimerTestHome) iniCtx
376:                        .lookup(TimerTestHome.JNDI_NAME);
377:                TimerTest session = home.create();
378:
379:                try {
380:                    int initialTimerCount;
381:                    int createdTimerCount;
382:                    int canceledTimerCount;
383:
384:                    initialTimerCount = getTimerCount();
385:                    session.startTimerInTxNever();
386:                    createdTimerCount = getTimerCount();
387:                    assertEquals("Timer not created", initialTimerCount + 1,
388:                            createdTimerCount);
389:                    session.cancelTimerInTxRequired();
390:                    canceledTimerCount = getTimerCount();
391:                    assertEquals("Timer not canceled", createdTimerCount,
392:                            canceledTimerCount + 1);
393:                } finally {
394:                    session.remove();
395:                }
396:            }
397:
398:            public void testCreateNeverCancelRequiresNew() throws Exception {
399:                InitialContext iniCtx = getInitialContext();
400:                TimerTestHome home = (TimerTestHome) iniCtx
401:                        .lookup(TimerTestHome.JNDI_NAME);
402:                TimerTest session = home.create();
403:
404:                try {
405:                    int initialTimerCount;
406:                    int createdTimerCount;
407:                    int canceledTimerCount;
408:
409:                    initialTimerCount = getTimerCount();
410:                    session.startTimerInTxNever();
411:                    createdTimerCount = getTimerCount();
412:                    assertEquals("Timer not created", initialTimerCount + 1,
413:                            createdTimerCount);
414:                    session.cancelTimerInTxRequiresNew();
415:                    canceledTimerCount = getTimerCount();
416:                    assertEquals("Timer not canceled", createdTimerCount,
417:                            canceledTimerCount + 1);
418:                } finally {
419:                    session.remove();
420:                }
421:            }
422:
423:            public void testCreateNeverCancelNotSupported() throws Exception {
424:                InitialContext iniCtx = getInitialContext();
425:                TimerTestHome home = (TimerTestHome) iniCtx
426:                        .lookup(TimerTestHome.JNDI_NAME);
427:                TimerTest session = home.create();
428:
429:                try {
430:                    int initialTimerCount;
431:                    int createdTimerCount;
432:                    int canceledTimerCount;
433:
434:                    initialTimerCount = getTimerCount();
435:                    session.startTimerInTxNever();
436:                    createdTimerCount = getTimerCount();
437:                    assertEquals("Timer not created", initialTimerCount + 1,
438:                            createdTimerCount);
439:                    session.cancelTimerInTxNotSupported();
440:                    canceledTimerCount = getTimerCount();
441:                    assertEquals("Timer not canceled", createdTimerCount,
442:                            canceledTimerCount + 1);
443:                } finally {
444:                    session.remove();
445:                }
446:            }
447:
448:            public void testCreateNeverCancelNever() throws Exception {
449:                InitialContext iniCtx = getInitialContext();
450:                TimerTestHome home = (TimerTestHome) iniCtx
451:                        .lookup(TimerTestHome.JNDI_NAME);
452:                TimerTest session = home.create();
453:
454:                try {
455:                    int initialTimerCount;
456:                    int createdTimerCount;
457:                    int canceledTimerCount;
458:
459:                    initialTimerCount = getTimerCount();
460:                    session.startTimerInTxNever();
461:                    createdTimerCount = getTimerCount();
462:                    assertEquals("Timer not created", initialTimerCount + 1,
463:                            createdTimerCount);
464:                    session.cancelTimerInTxNever();
465:                    canceledTimerCount = getTimerCount();
466:                    assertEquals("Timer not canceled", createdTimerCount,
467:                            canceledTimerCount + 1);
468:                } finally {
469:                    session.remove();
470:                }
471:            }
472:
473:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.