Source Code Cross Referenced for O2MBConversionTestCase.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » foedeployer » 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.foedeployer.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.foedeployer.test;
023:
024:        import java.io.IOException;
025:        import java.net.InetAddress;
026:        import java.rmi.RemoteException;
027:        import java.util.Set;
028:        import java.util.Collection;
029:        import javax.ejb.CreateException;
030:        import javax.ejb.Handle;
031:        import javax.management.ObjectName;
032:        import javax.naming.InitialContext;
033:        import javax.naming.NamingException;
034:        import javax.rmi.PortableRemoteObject;
035:
036:        import junit.extensions.TestSetup;
037:        import junit.framework.Test;
038:        import junit.framework.TestCase;
039:        import junit.framework.TestSuite;
040:
041:        import org.jboss.test.JBossTestCase;
042:        import org.jboss.test.JBossTestSetup;
043:
044:        import org.jboss.test.foedeployer.ejb.simple.SecretManager;
045:        import org.jboss.test.foedeployer.ejb.simple.SecretManagerHome;
046:        import org.jboss.test.foedeployer.ejb.o2mb.O2MBManager;
047:        import org.jboss.test.foedeployer.ejb.o2mb.O2MBManagerHome;
048:
049:        /**
050:         * Test of relationships conversion
051:         *
052:         * @author <a href="mailto:loubyansky@hotmail.com">Alex Loubyansky</a>
053:         * @version $Revision: 57211 $
054:         */
055:        public class O2MBConversionTestCase extends JBossTestCase {
056:            // Constants -----------------------------------------------------
057:            public static final String FOE_DEPLOYER = "foe-deployer-3.2.sar";
058:            public static final String FOE_DEPLOYER_NAME = "jboss:service=FoeDeployer";
059:            public static final String CONVERTOR_DEPLOYER_QUERY_NAME = "jboss:service=Convertor,*";
060:            public static final String APPLICATION = "foe-deployer-o2mb-test";
061:            public static final String MANAGER_SESSION_JNDI_NAME = "O2MBManagerEJB.O2MBManagerHome";
062:
063:            // Static --------------------------------------------------------
064:            /**
065:             * Setup the test suite.
066:             */
067:            public static Test suite() throws Exception {
068:                TestSuite suite = new TestSuite();
069:                suite.addTest(new TestSuite(O2MBConversionTestCase.class));
070:
071:                // Create an initializer for the test suite
072:                TestSetup wrapper = new JBossTestSetup(suite) {
073:                    protected void setUp() throws Exception {
074:                        super .setUp();
075:                    }
076:
077:                    protected void tearDown() throws Exception {
078:                        super .tearDown();
079:                    }
080:                };
081:                return wrapper;
082:            }
083:
084:            // Constructors --------------------------------------------------
085:            public O2MBConversionTestCase(String name) {
086:                super (name);
087:            }
088:
089:            // Public --------------------------------------------------------
090:            /**
091:             * Test a simple conversion
092:             **/
093:            public void testSimpleConversion() throws Exception {
094:                try {
095:                    log.debug("+++ testO2MBConversion");
096:
097:                    // First check if foe-deployer is deployed
098:                    boolean isInitiallyDeployed = getServer().isRegistered(
099:                            new ObjectName(FOE_DEPLOYER_NAME));
100:                    if (!isInitiallyDeployed)
101:                        deploy(FOE_DEPLOYER);
102:
103:                    boolean isDeployed = getServer().isRegistered(
104:                            new ObjectName(FOE_DEPLOYER_NAME));
105:                    assertTrue("Foe-Deployer is not deployed", isDeployed);
106:
107:                    // Count number of convertors (must be a list one)
108:                    int count = getServer()
109:                            .queryNames(
110:                                    new ObjectName(
111:                                            CONVERTOR_DEPLOYER_QUERY_NAME),
112:                                    null).size();
113:                    assertTrue("No Convertor found on web server", count > 0);
114:
115:                    // Deploy the simple application
116:                    deploy(APPLICATION + ".wlar");
117:
118:                    // Because the Foe-Deployer copies the converted JAR back to the original place
119:                    // it has to be deployed from here again
120:                    deploy(APPLICATION + ".jar");
121:
122:                    // Access the Session Bean and invoke some methods on it
123:                    int i;
124:                    String companyName = "Romashka";
125:                    String[] employees = { "Ivanov", "Petrov", "Sidorov" };
126:
127:                    O2MBManager manager = getO2MBManager();
128:
129:                    log.debug("cleaning the database");
130:                    manager.removeCompanyIfExists(companyName);
131:
132:                    log.debug("creating company: " + companyName);
133:                    manager.createCompany(companyName);
134:
135:                    // create all employees except the last one
136:                    for (i = 0; i < employees.length - 1; ++i) {
137:                        log.debug("creating employee '" + employees[i]
138:                                + "' for company '" + companyName + "'");
139:                        manager.createEmployeeForCompany(employees[i],
140:                                companyName);
141:                    }
142:
143:                    // fetch created employees
144:                    Collection emps = manager
145:                            .getEmployeesForCompany(companyName);
146:                    log.debug("employees for company '" + companyName + "': "
147:                            + emps);
148:
149:                    log
150:                            .debug("checking whether employees employed by the company");
151:                    for (i = 0; i < employees.length - 1; ++i) {
152:                        assertTrue("Employee '" + employees[i]
153:                                + "' must have been employed", emps
154:                                .contains(employees[i]));
155:                    }
156:
157:                    log.debug("creating the last employee: "
158:                            + employees[employees.length - 1]);
159:                    manager.createEmployee(employees[employees.length - 1]);
160:
161:                    log.debug("employ '" + employees[employees.length - 1]
162:                            + "'");
163:                    manager
164:                            .employ(employees[employees.length - 1],
165:                                    companyName);
166:
167:                    // verifying the last employee is employed
168:                    assertTrue(
169:                            "Employee '" + employees[employees.length - 1]
170:                                    + "' must have been employed",
171:                            companyName
172:                                    .equals(manager
173:                                            .getCompanyForEmployee(employees[employees.length - 1])));
174:
175:                    log
176:                            .debug("checking whether all employees are employed by the company");
177:                    emps = manager.getEmployeesForCompany(companyName);
178:                    for (i = 0; i < employees.length; ++i) {
179:                        assertTrue("Employee '" + employees[i]
180:                                + "' must have been employed", emps
181:                                .contains(employees[i]));
182:                    }
183:
184:                    log.debug("removing company: " + companyName);
185:                    manager.removeCompany(companyName);
186:
187:                    // Undeploy converted application to clean up
188:                    undeploy(APPLICATION + ".jar");
189:                    // undeploy wlar (though it should work without it)
190:                    undeploy(APPLICATION + ".wlar");
191:
192:                    // Only undeploy if deployed here
193:                    if (!isInitiallyDeployed)
194:                        undeploy(FOE_DEPLOYER);
195:                } catch (Exception e) {
196:                    e.printStackTrace();
197:                    throw e;
198:                }
199:            }
200:
201:            // Private -------------------------------------------------------
202:            private O2MBManager getO2MBManager() throws Exception {
203:                log.debug("looking for O2MBManager");
204:                Object ref = getInitialContext().lookup(
205:                        MANAGER_SESSION_JNDI_NAME);
206:                O2MBManagerHome home = (O2MBManagerHome) PortableRemoteObject
207:                        .narrow(ref, O2MBManagerHome.class);
208:                return home.create();
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.