Source Code Cross Referenced for EJBAcceptanceTest.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » test » ejb » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.test.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:
004:        Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:
006:
007:        The contents of this file are subject to the terms of either the GNU
008:        General Public License Version 2 only ("GPL") or the Common
009:        Development and Distribution License("CDDL") (collectively, the
010:        "License"). You may not use this file except in compliance with the
011:        License. You can obtain a copy of the License at
012:        http://www.netbeans.org/cddl-gplv2.html
013:        or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
014:        specific language governing permissions and limitations under the
015:        License.  When distributing the software, include this License Header
016:        Notice in each file and include the License file at
017:        nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
018:        particular file as subject to the "Classpath" exception as provided
019:        by Sun in the GPL Version 2 section of the License file that
020:        accompanied this code. If applicable, add the following below the
021:        License Header, with the fields enclosed by brackets [] replaced by
022:        your own identifying information:
023:        "Portions Copyrighted [year] [name of copyright owner]"
024:
025:        Contributor(s):
026:
027:        The Original Software is NetBeans. The Initial Developer of the Original
028:        Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
029:        Microsystems, Inc. All Rights Reserved.
030:
031:        If you wish your version of this file to be governed by only the CDDL
032:        or only the GPL Version 2, indicate your decision by adding
033:        "[Contributor] elects to include this software in this distribution
034:        under the [CDDL or GPL Version 2] license." If you do not indicate a
035:        single choice of license, a recipient has the option to distribute
036:        your version of this file under either the CDDL, the GPL Version 2 or
037:        to extend the choice of license to its licensees as provided above.
038:        However, if you add GPL Version 2 code and therefore, elected the GPL
039:        Version 2 license, then the option applies only if the new code is
040:        made subject to such option by the copyright holder.
041:         */
042:
043:        package org.netbeans.test.ejb;
044:
045:        import org.netbeans.jemmy.operators.*;
046:        import org.netbeans.junit.NbTestSuite;
047:        import junit.framework.Test;
048:
049:        import org.netbeans.modules.visualweb.gravy.designer.DesignerPaneOperator;
050:        import org.netbeans.modules.visualweb.gravy.plugins.PluginsOperator;
051:        import org.netbeans.modules.visualweb.gravy.dataconnectivity.*;
052:        import org.netbeans.modules.visualweb.gravy.*;
053:        import org.netbeans.modules.visualweb.gravy.model.project.components.VisualComponent;
054:        import org.netbeans.modules.visualweb.gravy.model.deployment.*;
055:        import org.netbeans.modules.visualweb.gravy.model.components.*;
056:        import org.netbeans.modules.visualweb.gravy.model.project.*;
057:        import org.netbeans.modules.visualweb.gravy.model.*;
058:
059:        import com.meterware.httpunit.*;
060:        import java.awt.event.KeyEvent;
061:        import java.awt.Point;
062:        import java.io.*;
063:
064:        /**
065:         *
066:         * @author Roman Mostyka
067:         */
068:        public class EJBAcceptanceTest extends RaveTestCase {
069:
070:            private static String sep = File.separator;
071:            private static String reformatPopup = "Format";
072:            private static String _ejbProjectName = "AcceptanceEJBProject";
073:            private static String _projectPath = System
074:                    .getProperty("xtest.workdir")
075:                    + sep + "projects" + sep;
076:            private static String pluginName = "Visual Web JSF Backwards Compatibility Kit";
077:            private static String javaCode = "try{staticText1.setText(greeterClient1.getGreeting());}catch(Exception e){}";
078:            private static String ejbResponse = "Hello World";
079:            private static String ejbSetName = "ValidJAR";
080:            private static String ejbName = "GreeterEJB_HelloWorld";
081:            private static String ejbJarDir = "EJB_Valid_JAR_Valid_EAR";
082:            private static String ejbJarName = ejbJarDir + "Client.jar";
083:            private static String ejbEarName = ejbJarDir + ".ear";
084:            private static String serverType = "GlassFish V2";
085:
086:            private static Project prj, J2EE14prj, JavaEE5prj;
087:            private static DeploymentTargetDescriptor dtd;
088:            private static DeploymentTarget dt;
089:            private static ApplicationServer as;
090:
091:            private ServerNavigatorOperator server;
092:            private JTreeOperator sntree;
093:
094:            public EJBAcceptanceTest(String testName) {
095:                super (testName);
096:            }
097:
098:            public static Test suite() {
099:                NbTestSuite suite = new NbTestSuite(
100:                        "EJB Consumption Acceptance Tests");
101:                suite.addTest(new EJBAcceptanceTest("testPreparation"));
102:                suite.addTest(new EJBAcceptanceTest("testAddEJB"));
103:                suite
104:                        .addTest(new EJBAcceptanceTest(
105:                                "testAddEJBToJ2EE14Project"));
106:                suite.addTest(new EJBAcceptanceTest("testDeployJ2EE14Project"));
107:                suite.addTest(new EJBAcceptanceTest(
108:                        "testAddEJBToJavaEE5Project"));
109:                suite
110:                        .addTest(new EJBAcceptanceTest(
111:                                "testDeployJavaEE5Project"));
112:                suite.addTest(new EJBAcceptanceTest("testRemoveEJB"));
113:                return suite;
114:            }
115:
116:            /** method called before each testcase
117:             */
118:            protected void setUp() {
119:            }
120:
121:            public void testPreparation() {
122:                PluginsOperator.getInstance().installAvailablePlugins(
123:                        pluginName);
124:                dtd = new DeploymentTargetDescriptor();
125:                dtd.load();
126:                if (serverType != null)
127:                    dtd.setProperty(dtd.SERVER_TYPE_KEY, serverType);
128:                dt = IDE.getIDE().addDeploymentTarget(dtd);
129:                as = (ApplicationServer) dt;
130:                as.start();
131:                TestUtils.wait(1000);
132:            }
133:
134:            public void testAddEJB() {
135:                EJBTestUtils.addEJB(ejbSetName,
136:                        EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
137:                        EJBTestUtils.EJB_JARS_PATH + sep + ejbJarDir + sep
138:                                + ejbJarName, EJBTestUtils.EJB_JARS_PATH + sep
139:                                + ejbJarDir + sep + ejbEarName);
140:                EJBTestUtils.endAddEJB();
141:                TestUtils.wait(2000);
142:            }
143:
144:            public void testAddEJBToJ2EE14Project() {
145:                J2EE14prj = createProject(ProjectDescriptor.J2EE14);
146:                addComponentToProject(J2EE14prj);
147:                addEJBToProject();
148:                editPrerenderMethod(javaCode);
149:            }
150:
151:            public void testDeployJ2EE14Project() {
152:                DeployAndCheckProject(J2EE14prj);
153:                verifyHTTP(J2EE14prj, ejbResponse);
154:                projectUndeployAndClose(J2EE14prj);
155:            }
156:
157:            public void testAddEJBToJavaEE5Project() {
158:                JavaEE5prj = createProject(ProjectDescriptor.JavaEE5);
159:                addComponentToProject(JavaEE5prj);
160:                addEJBToProject();
161:                editPrerenderMethod(javaCode);
162:            }
163:
164:            public void testDeployJavaEE5Project() {
165:                DeployAndCheckProject(JavaEE5prj);
166:                verifyHTTP(JavaEE5prj, ejbResponse);
167:                projectUndeployAndClose(JavaEE5prj);
168:                as.stop();
169:            }
170:
171:            public void testRemoveEJB() {
172:                EJBTestUtils.removeEJB(ejbSetName);
173:            }
174:
175:            private Project createProject(String J2EEVersion) {
176:                String J2EEVersion_PREF = J2EEVersion.replace(' ', '_')
177:                        .replace('.', '_');
178:                ProjectDescriptor pd = new ProjectDescriptor(_ejbProjectName
179:                        + "_" + J2EEVersion_PREF, _projectPath, J2EEVersion, as
180:                        .getName());
181:                Project prj = IDE.getIDE().createProject(pd);
182:                TestUtils.disableBrowser(prj.getName(), true);
183:                TestUtils.wait(1000);
184:                return prj;
185:            }
186:
187:            private void addComponentToProject(Project prj) {
188:                WebPageFolder wpf = prj.getRoot().getWebPageRootFolder();
189:                WebPage wp = wpf.getWebPage("Page1");
190:                VisualComponent vcmp = (VisualComponent) wp.add(
191:                        (WebComponent) IDE.getIDE().getDefaultComponentSet()
192:                                .getComponent(
193:                                        StaticTextComponent.STATIC_TEXT_ID),
194:                        new Point(48, 48));
195:                EJBTestUtils.addBindingAttribute(wp.getName(),
196:                        "page1|html1|body1|form1|" + vcmp.getName());
197:            }
198:
199:            private void addEJBToProject() {
200:                EJBTestUtils.addEJBToPage(ejbSetName, ejbName);
201:                TestUtils.wait(30000);
202:            }
203:
204:            private void editPrerenderMethod(String code) {
205:                DesignerPaneOperator designer = new DesignerPaneOperator(
206:                        RaveWindowOperator.getDefaultRave());
207:                designer.switchToJavaSource();
208:                TestUtils.wait(1000);
209:                EditorOperator editor = new EditorOperator(RaveWindowOperator
210:                        .getDefaultRave(), "Page1.java");
211:                TestUtils.wait(2000);
212:                if (System.getProperty("os.name").equals("Mac OS X"))
213:                    editor.pressKey(KeyEvent.VK_F, KeyEvent.META_DOWN_MASK);
214:                else
215:                    editor.pressKey(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK);
216:                TestUtils.wait(2000);
217:                JComboBoxOperator jcbo = new JComboBoxOperator(editor);
218:                TestUtils.wait(500);
219:                jcbo.clearText();
220:                TestUtils.wait(500);
221:                jcbo.enterText("prerender() {");
222:                TestUtils.wait(500);
223:                jcbo.pressKey(KeyEvent.VK_ESCAPE);
224:                TestUtils.wait(500);
225:                jcbo.pressKey(KeyEvent.VK_RIGHT);
226:                TestUtils.wait(500);
227:                editor.setCaretPositionToEndOfLine(editor.getLineNumber());
228:                TestUtils.wait(500);
229:                editor.pressKey(KeyEvent.VK_ENTER);
230:                TestUtils.wait(2000);
231:                editor.txtEditorPane().typeText(code);
232:                editor.txtEditorPane().clickForPopup();
233:                JPopupMenuOperator epm = new JPopupMenuOperator();
234:                TestUtils.wait(1000);
235:                new JMenuItemOperator(epm, reformatPopup).push();
236:                TestUtils.wait(2000);
237:            }
238:
239:            private void DeployAndCheckProject(Project prj) {
240:                Util.getMainWindow().deploy();
241:                TestUtils.wait(20000);
242:                server = ServerNavigatorOperator.showNavigatorOperator();
243:                TestUtils.wait(4000);
244:                sntree = server.getTree();
245:                server.pushPopup(ServerExplorerOperator.STR_SERVERS_PATH
246:                        + as.web_applications_path, as.REFRESH);
247:                TestUtils.wait(1000);
248:                try {
249:                    sntree.selectPath(sntree
250:                            .findPath(ServerExplorerOperator.STR_SERVERS_PATH
251:                                    + as.web_applications_path + "|"
252:                                    + as.app_pref + prj.getName()));
253:                } catch (Exception e) {
254:                    fail("There is no " + prj.getName()
255:                            + " application in Deployed Components node!");
256:                }
257:                TestUtils.wait(1000);
258:            }
259:
260:            private void verifyHTTP(Project prj, String verificationString) {
261:                try {
262:                    WebConversation conversation = new WebConversation();
263:                    WebResponse response = null;
264:                    System.out.println("requestPrefix=" + as.requestPrefix);
265:                    response = conversation.getResponse(as.requestPrefix
266:                            + prj.getName());
267:                    if (response.getText().indexOf(ejbResponse) == -1)
268:                        fail("There is no needed string (\"" + ejbResponse
269:                                + "\") in response!");
270:                } catch (Exception e) {
271:                    System.out.println("Exception occured: ");
272:                    e.printStackTrace();
273:                    fail("Excetion in HTTP check : " + e);
274:                }
275:            }
276:
277:            private void projectUndeployAndClose(Project prj) {
278:                TestUtils.wait(1000);
279:                Util.saveAllAPICall();
280:                server.pushPopup(ServerExplorerOperator.STR_SERVERS_PATH
281:                        + as.web_applications_path, as.REFRESH);
282:                TestUtils.wait(1000);
283:                server.pushPopup(ServerExplorerOperator.STR_SERVERS_PATH
284:                        + as.web_applications_path + "|" + as.app_pref
285:                        + prj.getName(), as.APPLICATION_UNDEPLOY);
286:                TestUtils.wait(1000);
287:                prj.close();
288:                TestUtils.wait(1000);
289:            }
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.