Source Code Cross Referenced for EJBValidation.java in  » IDE-Netbeans » j2ee » org » netbeans » test » j2ee » 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 » j2ee » org.netbeans.test.j2ee 
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:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.test.j2ee;
043:
044:        import java.io.File;
045:        import java.io.FilenameFilter;
046:        import java.io.IOException;
047:        import java.util.Arrays;
048:        import junit.textui.TestRunner;
049:        import org.netbeans.jellytools.*;
050:        import org.netbeans.jellytools.actions.DeleteAction;
051:        import org.netbeans.jellytools.actions.OpenAction;
052:        import org.netbeans.jellytools.nodes.Node;
053:        import org.netbeans.jemmy.TimeoutExpiredException;
054:        import org.netbeans.jemmy.operators.*;
055:        import org.netbeans.junit.NbTestSuite;
056:        import org.netbeans.junit.ide.ProjectSupport;
057:        import org.netbeans.test.j2ee.addmethod.*;
058:        import org.netbeans.test.j2ee.lib.Utils;
059:
060:        /**
061:         * EJBValidation suite for J2EE.
062:         * 
063:         * 
064:         * @author libor.martinek@sun.com
065:         */
066:        public class EJBValidation extends JellyTestCase {
067:
068:            public static final String EAR_PROJECT_NAME = "TestingEntApp";
069:            public static final String WEB_PROJECT_NAME = EAR_PROJECT_NAME
070:                    + "-WebModule";
071:            public static final String EJB_PROJECT_NAME = EAR_PROJECT_NAME
072:                    + "-EJBModule";
073:
074:            public static File EAR_PROJECT_FILE;
075:            public static File EJB_PROJECT_FILE;
076:            public static File WEB_PROJECT_FILE;
077:
078:            /** Need to be defined because of JUnit */
079:            public EJBValidation(String name) {
080:                super (name);
081:            }
082:
083:            public static NbTestSuite suite() {
084:                NbTestSuite suite = new NbTestSuite();
085:
086:                suite.addTest(new EJBValidation("openProjects"));
087:                suite.addTest(new AddMethodTest("testAddBusinessMethod1InSB"));
088:                suite.addTest(new AddMethodTest("testAddBusinessMethod2InSB"));
089:                suite.addTest(new AddMethodTest("testAddBusinessMethod1InEB"));
090:                suite.addTest(new AddMethodTest("testAddBusinessMethod2InEB"));
091:                suite.addTest(new AddMethodTest("testAddCreateMethod1InEB"));
092:                suite.addTest(new AddMethodTest("testAddCreateMethod2InEB"));
093:                suite.addTest(new AddMethodTest("testAddHomeMethod1InEB"));
094:                suite.addTest(new AddMethodTest("testAddHomeMethod2InEB"));
095:                //suite.addTest(new GenerateDTOTest("testGenerateDTO"));
096:                //suite.addTest(new GenerateDTOTest("testDeleteDTO"));
097:                suite.addTest(new AddFinderMethodTest(
098:                        "testAddFinderMethod1InEB"));
099:                suite.addTest(new AddFinderMethodTest(
100:                        "testAddFinderMethod2InEB"));
101:                suite.addTest(new AddSelectMethodTest(
102:                        "testAddSelectMethod1InEB"));
103:                suite.addTest(new AddSelectMethodTest(
104:                        "testAddSelectMethod2InEB"));
105:                suite.addTest(new AddCMPFieldTest("testAddCMPField1InEB"));
106:                suite.addTest(new AddCMPFieldTest("testAddCMPField2InEB"));
107:                suite.addTest(new CallEJBTest("testCallEJBInServlet"));
108:                suite.addTest(new CallEJBTest("testCallEJB1InSB"));
109:                suite.addTest(new CallEJBTest("testCallEJB2InSB"));
110:                //suite.addTest(new EJBValidation("prepareDatabase"));
111:                //suite.addTest(new UseDatabaseTest("testUseDatabase1InSB"));
112:                //suite.addTest(new SendMessageTest("testSendMessage1InSB"));
113:                //suite.addTest(new EJBValidation("testStartServer"));
114:                //suite.addTest(new EJBValidation("testDeployment"));
115:                //suite.addTest(new EJBValidation("testUndeploy"));
116:                //suite.addTest(new CreateCMPBeansFromDB("testCreateCMPBeansFromDB"));
117:                //suite.addTest(new EJBValidation("testDeleteEntityBean"));
118:
119:                //suite.addTest(new EJBValidation("testStopServer"));
120:                suite.addTest(new EJBValidation("closeProjects"));
121:                return suite;
122:            }
123:
124:            /** Use for execution inside IDE */
125:            public static void main(java.lang.String[] args) {
126:                // run whole suite
127:                TestRunner.run(suite());
128:
129:                /*
130:                NbTestSuite suite = new NbTestSuite();
131:                suite.addTest(new GUIValidation("openProjects"));
132:                suite.addTest(new GUIValidation("prepareDatabase"));
133:                suite.addTest(new CreateCMPBeansFromDB("testCreateCMPBeansFromDB"));
134:                TestRunner.run(suite);
135:                 */
136:                // run only selected test case
137:                //junit.textui.TestRunner.run(new GUIValidation("testDeleteWSinWeb"));
138:            }
139:
140:            public void setUp() {
141:                System.out.println("########  " + getName() + "  #######");
142:            }
143:
144:            public void tearDown() {
145:            }
146:
147:            public void openProjects() {
148:                EAR_PROJECT_FILE = new File(getDataDir(), EAR_PROJECT_NAME);
149:                ProjectSupport.openProject(EAR_PROJECT_FILE);
150:                ProjectSupport.waitScanFinished();
151:                EJB_PROJECT_FILE = new File(EAR_PROJECT_FILE, EAR_PROJECT_NAME
152:                        + "-ejb");
153:                ProjectSupport.openProject(EJB_PROJECT_FILE);
154:                ProjectSupport.waitScanFinished();
155:                WEB_PROJECT_FILE = new File(EAR_PROJECT_FILE, EAR_PROJECT_NAME
156:                        + "-war");
157:                ProjectSupport.openProject(WEB_PROJECT_FILE);
158:                ProjectSupport.waitScanFinished();
159:
160:                //TEMPORARY HACK
161:                try {
162:                    new NbDialogOperator("Open Project").ok();
163:                } catch (TimeoutExpiredException e) {
164:                }
165:
166:                new org.netbeans.jemmy.EventTool().waitNoEvent(5000);
167:                String files[] = { "TestingSession", "TestingEntity" };
168:                for (int i = 0; i < files.length; i++) {
169:                    Node openFile = new Node(
170:                            new ProjectsTabOperator()
171:                                    .getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
172:                            Bundle
173:                                    .getStringTrimmed(
174:                                            "org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle",
175:                                            "LBL_node")
176:                                    + "|" + files[i]);
177:                    new OpenAction().performAPI(openFile);
178:                    EditorOperator editor = new EditorWindowOperator()
179:                            .getEditor(files[i] + "Bean.java");
180:                }
181:                new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
182:            }
183:
184:            public void closeProjects() {
185:                new EditorWindowOperator().getEditor().closeDiscardAll();
186:                ProjectSupport.closeProject(EAR_PROJECT_NAME);
187:                ProjectSupport.closeProject(EJB_PROJECT_NAME);
188:                ProjectSupport.closeProject(WEB_PROJECT_NAME);
189:            }
190:
191:            public void prepareDatabase() {
192:                Utils.prepareDatabase();
193:                new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
194:            }
195:
196:            public void testDeleteEntityBean() throws IOException {
197:                Node node = new Node(
198:                        new ProjectsTabOperator()
199:                                .getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
200:                        Bundle
201:                                .getStringTrimmed(
202:                                        "org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle",
203:                                        "LBL_node")
204:                                + "|TestingEntityEB");
205:                new DeleteAction().performAPI(node);
206:                NbDialogOperator dialog = new NbDialogOperator(
207:                        Bundle
208:                                .getStringTrimmed(
209:                                        "org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle",
210:                                        "MSG_ConfirmDeleteObjectTitle"));
211:                new JCheckBoxOperator(dialog).changeSelection(true);
212:                dialog.yes();
213:
214:                new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
215:                Utils utils = new Utils(this );
216:                String ddNames[] = { "ejb-jar.xml", "sun-ejb-jar.xml" };
217:                utils.assertFiles(new File(EJB_PROJECT_FILE, "src/conf"),
218:                        ddNames, getName() + "_");
219:
220:                File dir = new File(EJB_PROJECT_FILE, "src/java/test");
221:                String deletedFiles[] = dir.list(new FilenameFilter() {
222:                    public boolean accept(File dir, String name) {
223:                        return name.endsWith(".java")
224:                                && name.startsWith("TestingEntity")
225:                                && !name.equals("TestingEntityDTO.java");
226:                    }
227:                });
228:                if (deletedFiles != null && deletedFiles.length > 0) {
229:                    fail("Bean files was not deleted from directory "
230:                            + dir.getAbsolutePath() + ". I found "
231:                            + Arrays.asList(deletedFiles));
232:                }
233:            }
234:
235:            public void testStartServer() throws IOException {
236:                Utils.startStopServer(true);
237:                String url = "http://localhost:8080/";
238:                String page = Utils.loadFromURL(url);
239:                log(page);
240:                String text = "Your server is up and running";
241:                assertTrue("AppServer start page doesn't contain text '" + text
242:                        + "'. See log for page content.",
243:                        page.indexOf(text) >= 0);
244:            }
245:
246:            public void testDeployment() throws IOException {
247:                final String CONTROL_TEXT = "ControlTextABC";
248:                Utils utils = new Utils(this );
249:
250:                Node openFile = new Node(
251:                        new ProjectsTabOperator()
252:                                .getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
253:                        Bundle
254:                                .getStringTrimmed(
255:                                        "org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle",
256:                                        "LBL_node")
257:                                + "|TestingSession");
258:                new OpenAction().performAPI(openFile);
259:                utils.checkAndModify("TestingSessionBean.java", 61,
260:                        "public String testBusinessMethod1()", 63,
261:                        "return null;", 63, true, "return \"" + CONTROL_TEXT
262:                                + "\";\n");
263:                utils
264:                        .checkAndModify(
265:                                "TestingSessionBean.java",
266:                                103,
267:                                "// javax.jms.TextMessage tm = session.createTextMessage();",
268:                                0, null, 103, true,
269:                                "javax.jms.TextMessage tm = session.createTextMessage();\n");
270:                utils.checkAndModify("TestingSessionBean.java", 104,
271:                        "// tm.setText(messageData.toString());", 0, null, 104,
272:                        true, "tm.setText(messageData.toString());\n");
273:                utils.checkAndModify("TestingSessionBean.java", 105,
274:                        "// return tm;", 0, null, 105, true, "return tm;\n");
275:
276:                openFile = new Node(new ProjectsTabOperator()
277:                        .getProjectRootNode(EJBValidation.WEB_PROJECT_NAME),
278:                        Bundle.getStringTrimmed(
279:                                "org.netbeans.modules.web.project.ui.Bundle",
280:                                "LBL_Node_Sources")
281:                                + "|test|TestingServlet");
282:                new OpenAction().performAPI(openFile);
283:                utils
284:                        .checkAndModify("TestingServlet.java", 36,
285:                                "out.println(\"</body>\");", 0, null, 36,
286:                                false,
287:                                "out.println(lookupTestingSessionBean().testBusinessMethod1());\n");
288:
289:                String page = Utils
290:                        .deploy(EAR_PROJECT_NAME,
291:                                "http://localhost:8080/TestingEntApp-WebModule/TestingServlet");
292:                log(page);
293:                assertTrue("TestingServlet doesn't contain expected text '"
294:                        + CONTROL_TEXT + "'. See log for page content.", page
295:                        .indexOf(CONTROL_TEXT) >= 0);
296:            }
297:
298:            public void testUndeploy() {
299:                Utils.undeploy(EAR_PROJECT_NAME);
300:            }
301:
302:            public void testStopServer() {
303:                Utils.startStopServer(false);
304:                String url = "http://localhost:8080/";
305:                try {
306:                    String page = Utils.loadFromURL(url);
307:                    log(page);
308:                    fail("AppServer should not be running, but start page is available. See log for page content.");
309:                } catch (IOException e) {
310:                }
311:            }
312:
313:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.