Source Code Cross Referenced for XAUnitTestCase.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » xa » 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.xa.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.xa.test;
023:
024:        import java.rmi.*;
025:
026:        import javax.naming.Context;
027:        import javax.naming.InitialContext;
028:        import javax.ejb.DuplicateKeyException;
029:        import javax.ejb.Handle;
030:        import javax.ejb.EJBMetaData;
031:        import javax.ejb.FinderException;
032:
033:        import java.util.Date;
034:        import java.util.Properties;
035:        import java.util.Collection;
036:        import java.util.Iterator;
037:        import java.util.Enumeration;
038:
039:        import junit.framework.Test;
040:        import junit.framework.TestCase;
041:        import junit.framework.TestSuite;
042:
043:        import org.jboss.test.JBossTestCase;
044:
045:        import org.jboss.test.xa.interfaces.CantSeeDataException;
046:        import org.jboss.test.xa.interfaces.XATest;
047:        import org.jboss.test.xa.interfaces.XATestHome;
048:
049:        /* This needs lots more work to be an acceptable test case.  
050:         Aside from needing an xa-capable database, we need an xa-test-service.xml
051:         file to deploy the two ConnectionFactoryLoaders.
052:         Then the printing needs to be changed to assertions.
053:
054:
055:         */
056:
057:        public class XAUnitTestCase extends JBossTestCase {
058:            org.apache.log4j.Category log = getLog();
059:
060:            public XAUnitTestCase(String name) {
061:                super (name);
062:            }
063:
064:            public void testXABean() throws Exception {
065:                int test = 0;
066:
067:                Context ctx = new InitialContext();
068:
069:                // sed kicks ass
070:                System.out.print(++test + "- "
071:                        + "Looking up the XATest home...");
072:
073:                XATestHome home;
074:
075:                try {
076:                    home = (XATestHome) ctx.lookup("XATest");
077:
078:                    if (home == null)
079:                        throw new Exception("No Home!");
080:                    log.debug("OK");
081:                } catch (Exception e) {
082:                    // sed kicks ass
083:                    log
084:                            .debug("Could not lookup the context:  the beans are probably not deployed");
085:                    log.debug("Check the server trace for details");
086:
087:                    throw e;
088:                }
089:
090:                // sed kicks ass
091:                System.out.print(++test + "- "
092:                        + "Creating an the XATest bean...");
093:                XATest bean;
094:                try {
095:                    bean = home.create();
096:                    if (bean == null)
097:                        throw new Exception("No Bean!");
098:                    log.debug("OK");
099:                } catch (Exception e) {
100:                    // sed kicks ass
101:                    log.debug("Could not create the bean!");
102:                    log.debug("Check the server trace for details");
103:                    log.debug("failed", e);
104:
105:                    throw e;
106:                }
107:
108:                // sed kicks ass
109:                System.out.print(++test + "- " + "Creating required tables...");
110:                try {
111:                    bean.createTables();
112:                    log.debug("OK");
113:                } catch (Exception e) {
114:                    log.debug("\nFailed to create tables");
115:                    throw e;
116:                }
117:
118:                // sed kicks ass
119:                System.out.print(++test + "- " + "Clearing any old data...");
120:                try {
121:                    bean.clearData();
122:                    log.debug("OK");
123:                } catch (Exception e) {
124:                    // sed kicks ass
125:                    log
126:                            .debug("Could not clear the data: did you create the table in both data sources?");
127:                    log
128:                            .debug("CREATE TABLE XA_TEST(ID INTEGER NOT NULL PRIMARY KEY, DATA INTEGER NOT NULL)");
129:
130:                    throw e;
131:                }
132:
133:                // sed kicks ass
134:                System.out.print(++test + "- " + "Testing DB connections...");
135:                try {
136:                    bean.doWork();
137:                    log.debug("OK");
138:                } catch (CantSeeDataException e) {
139:                    log.debug("sort of worked.");
140:                    log.debug(e.getMessage());
141:                } catch (Exception e) {
142:                    // sed kicks ass
143:                    log.debug("Error during DB test!");
144:                    log.debug("Check the server trace for details");
145:
146:                    throw e;
147:                }
148:            }
149:
150:            public static Test suite() throws Exception {
151:                return getDeploySetup(XAUnitTestCase.class, "xatest.jar");
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.