Source Code Cross Referenced for QLConversionTestCase.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.Collection;
028:        import javax.ejb.CreateException;
029:        import javax.ejb.Handle;
030:        import javax.management.ObjectName;
031:        import javax.naming.InitialContext;
032:        import javax.naming.NamingException;
033:        import javax.rmi.PortableRemoteObject;
034:
035:        import junit.extensions.TestSetup;
036:        import junit.framework.Test;
037:        import junit.framework.TestCase;
038:        import junit.framework.TestSuite;
039:
040:        import org.jboss.test.JBossTestCase;
041:        import org.jboss.test.JBossTestSetup;
042:
043:        import org.jboss.test.foedeployer.ejb.ql.CarCatalog;
044:        import org.jboss.test.foedeployer.ejb.ql.CarCatalogHome;
045:
046:        /**
047:         * Test of a simple WebLogic QL conversion
048:         *
049:         * @author <a href="mailto:loubyansky@hotmail.com">Alex Loubyansky</a>
050:         * @version $Revision: 57211 $
051:         */
052:        public class QLConversionTestCase extends JBossTestCase {
053:            // Constants -----------------------------------------------------
054:            public static final String FOE_DEPLOYER = "foe-deployer-3.2.sar";
055:            public static final String FOE_DEPLOYER_NAME = "jboss:service=FoeDeployer";
056:            public static final String CONVERTOR_DEPLOYER_QUERY_NAME = "jboss:service=Convertor,*";
057:            public static final String QL_APPLICATION = "foe-deployer-ql-test";
058:            public static final String CAR_CATALOG_JNDI_NAME = "CarCatalogEJB.CarCatalogHome";
059:
060:            // Static --------------------------------------------------------
061:            /**
062:             * Setup the test suite.
063:             */
064:            public static Test suite() throws Exception {
065:                TestSuite lSuite = new TestSuite();
066:                lSuite.addTest(new TestSuite(QLConversionTestCase.class));
067:
068:                // Create an initializer for the test suite
069:                TestSetup lWrapper = new JBossTestSetup(lSuite) {
070:                    protected void setUp() throws Exception {
071:                        super .setUp();
072:                    }
073:
074:                    protected void tearDown() throws Exception {
075:                        super .tearDown();
076:                    }
077:                };
078:                return lWrapper;
079:            }
080:
081:            // Constructors --------------------------------------------------
082:            public QLConversionTestCase(String pName) {
083:                super (pName);
084:            }
085:
086:            // Public --------------------------------------------------------
087:            /**
088:             * Test a simple conversion
089:             **/
090:            public void testQLConversion() throws Exception {
091:                try {
092:                    log.debug("+++ testQLConversion");
093:
094:                    // First check if foe-deployer is deployed
095:                    boolean lIsInitiallyDeployed = getServer().isRegistered(
096:                            new ObjectName(FOE_DEPLOYER_NAME));
097:                    if (!lIsInitiallyDeployed)
098:                        deploy(FOE_DEPLOYER);
099:
100:                    boolean lIsDeployed = getServer().isRegistered(
101:                            new ObjectName(FOE_DEPLOYER_NAME));
102:                    assertTrue("Foe-Deployer is not deployed", lIsDeployed);
103:
104:                    // Count number of convertors (must be a list one)
105:                    int lCount = getServer()
106:                            .queryNames(
107:                                    new ObjectName(
108:                                            CONVERTOR_DEPLOYER_QUERY_NAME),
109:                                    null).size();
110:                    assertTrue("No Convertor found on web server", lCount > 0);
111:
112:                    // Deploy the simple application
113:                    deploy(QL_APPLICATION + ".wlar");
114:
115:                    // Because the Foe-Deployer copies the converted JAR back to the original place
116:                    // it has to be deployed from here again
117:                    deploy(QL_APPLICATION + ".jar");
118:
119:                    // Create some data and test queries
120:                    int i;
121:                    String[] carNumbers = { "apache", "noch", "zzuk", "silvia" };
122:                    String[] carColors = { "red", "black", "red", "yellow" };
123:                    int[] carYears = { 1990, 1989, 2000, 1995 };
124:
125:                    CarCatalog carCatalog = getCarCatalogEJB();
126:
127:                    //getLog().debug( "clean the database" );
128:                    //i = -1;
129:                    //while( ++i < carNumbers.length )
130:                    //   carCatalog.removeCarIfExists( carNumbers[ i ] );
131:
132:                    getLog().debug("manufacture cars");
133:                    i = -1;
134:                    while (++i < carNumbers.length) {
135:                        carCatalog.createCar(carNumbers[i], carColors[i],
136:                                carYears[i]);
137:                        getLog().debug("registered car: " + carNumbers[i]);
138:                    }
139:
140:                    getLog().debug("find all cars");
141:                    Collection numbersCol = carCatalog.getAllCarNumbers();
142:                    i = -1;
143:                    while (++i < carNumbers.length) {
144:                        assertTrue(
145:                                "Not all cars returned by converted findAll query",
146:                                numbersCol.contains(carNumbers[i]));
147:                    }
148:
149:                    getLog().debug("find cars with red color");
150:                    Collection cars = carCatalog.getCarsWithColor("red");
151:                    i = -1;
152:                    while (++i < carNumbers.length) {
153:                        if ("red".equals(carColors[i])) {
154:                            assertTrue("Not all red cars found", cars
155:                                    .contains(carNumbers[i]));
156:                        }
157:                    }
158:
159:                    log.debug("find cars after 1993 year");
160:                    cars = carCatalog.getCarsAfterYear(1993);
161:                    i = -1;
162:                    while (++i < carNumbers.length) {
163:                        if (1993 < carYears[i]) {
164:                            assertTrue("Not all cars after year 1993 found",
165:                                    cars.contains(carNumbers[i]));
166:                        }
167:                    }
168:
169:                    // Undeploy converted application to clean up
170:                    undeploy(QL_APPLICATION + ".jar");
171:
172:                    // also now should work without undeploying
173:                    undeploy(QL_APPLICATION + ".wlar");
174:
175:                    // Only undeploy if deployed here
176:                    if (!lIsInitiallyDeployed) {
177:                        undeploy(FOE_DEPLOYER);
178:                    }
179:                } catch (Exception e) {
180:                    e.printStackTrace();
181:                    throw e;
182:                }
183:            }
184:
185:            // Private -------------------------------------------------------
186:            private CarCatalog getCarCatalogEJB() throws Exception {
187:                getLog().debug("looking for CarCatalogHome");
188:                Object ref = getInitialContext().lookup(CAR_CATALOG_JNDI_NAME);
189:                CarCatalogHome home = (CarCatalogHome) PortableRemoteObject
190:                        .narrow(ref, CarCatalogHome.class);
191:                getLog().debug("creating an instance of CarCatalog");
192:                return home.create();
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.