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.jemmy.*;
047: import org.netbeans.junit.NbTestSuite;
048: import junit.framework.Test;
049: import junit.framework.*;
050:
051: import org.netbeans.modules.visualweb.gravy.model.deployment.ApplicationServer;
052: import org.netbeans.modules.visualweb.gravy.plugins.PluginsOperator;
053: import org.netbeans.modules.visualweb.gravy.dataconnectivity.*;
054: import org.netbeans.modules.visualweb.gravy.*;
055:
056: import java.io.*;
057:
058: /**
059: *
060: * @author Roman Mostyka
061: */
062: public class AddEJBTest extends RaveTestCase {
063:
064: private static String pluginName = "Visual Web JSF Backwards Compatibility Kit";
065: private static int lbIndex = EJBTestUtils.getLabelIndex();
066:
067: public ServerNavigatorOperator server;
068: public JTreeOperator sntree;
069:
070: public AddEJBTest(String testName) {
071: super (testName);
072: }
073:
074: public static Test suite() {
075: NbTestSuite suite = new NbTestSuite("Add Set of Session EJBs");
076: suite.addTest(new AddEJBTest("testPreparation"));
077: suite.addTest(new AddEJBTest("testEJB_Dia_01_NoJAR"));
078: suite.addTest(new AddEJBTest("testEJB_Dia_02_CancelDialog"));
079: suite.addTest(new AddEJBTest("testEJB_Dia_03_InvalidJAR"));
080: suite.addTest(new AddEJBTest("testEJB_Dia_04_ValidJAR"));
081: suite
082: .addTest(new AddEJBTest(
083: "testEJB_Dia_05_ValidJAR_ValidEAR"));
084: suite.addTest(new AddEJBTest(
085: "testEJB_Dia_06_ValidJAR_InvalidEAR"));
086: suite.addTest(new AddEJBTest("testEJB_Dia_07_NoJAR_ValidEAR"));
087: suite.addTest(new AddEJBTest(
088: "testEJB_Dia_08_InvalidJAR_InvalidEAR"));
089: suite.addTest(new AddEJBTest(
090: "testEJB_Dia_09_ValidJAR_NoPackage"));
091: suite.addTest(new AddEJBTest("testEJB_Dia_10_ValidJARs_2EJBs"));
092: return suite;
093: }
094:
095: /** method called before each testcase
096: */
097: protected void setUp() {
098: }
099:
100: public void testPreparation() {
101: PluginsOperator.getInstance().installAvailablePlugins(
102: pluginName);
103: ApplicationServer as = EJBTestUtils.getApplicationServer();
104: as.start();
105: TestUtils.wait(1000);
106: }
107:
108: public void testEJB_Dia_01_NoJAR() {
109: EJBTestUtils.addEJB();
110: TestUtils.wait(1000);
111: JDialogOperator dlg_error = new JDialogOperator();
112: String errMsg = null;
113: if (!(new JLabelOperator(dlg_error, lbIndex).getText().trim()
114: .equals(EJBTestUtils.msg_emptyJAR))) {
115: errMsg = "Wrong message!";
116: }
117: TestUtils.wait(1000);
118: new JButtonOperator(new JDialogOperator(),
119: EJBTestUtils.btn_Cancel).pushNoBlock();
120:
121: Util.wait(1000);
122: new QueueTool().waitEmpty();
123: if (errMsg != null) {
124: fail(errMsg);
125: }
126: }
127:
128: public void testEJB_Dia_02_CancelDialog() {
129: server = ServerNavigatorOperator.showNavigatorOperator();
130: TestUtils.wait(1000);
131: sntree = server.getTree();
132: server.pushPopup(EJBTestUtils.ejbNode,
133: EJBTestUtils.sessionEJBPopup);
134: TestUtils.wait(1000);
135: JDialogOperator addDialog = new JDialogOperator();
136: new JButtonOperator(addDialog, EJBTestUtils.btn_Cancel)
137: .pushNoBlock();
138: Util.wait(1000);
139: new QueueTool().waitEmpty();
140: }
141:
142: public void testEJB_Dia_03_InvalidJAR() {
143: String ejbSetName = "InvalidJAR", ejbJarDir = "EJB_Invalid_JAR", ejbJarName = "EJB_Invalid_Client_JAR.jar";
144: EJBTestUtils.addEJB(ejbSetName,
145: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
146: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
147: + File.separator + ejbJarName, "");
148:
149: JDialogOperator dlg_error = new JDialogOperator();
150: Util.wait(1000);
151:
152: String dialogErrMessage = new JLabelOperator(dlg_error, lbIndex)
153: .getText().trim();
154: if (dialogErrMessage.indexOf(EJBTestUtils.msg_noDescriptor) == -1) {
155: Util.wait(1000);
156: new JButtonOperator(new JDialogOperator(),
157: EJBTestUtils.btn_Cancel).pushNoBlock();
158: Util.wait(1000);
159: new QueueTool().waitEmpty();
160: fail("Invalid Client JAR: Wrong message in the error-dialog!");
161: }
162: Util.wait(1000);
163: new QueueTool().waitEmpty();
164:
165: new JButtonOperator(new JDialogOperator(),
166: EJBTestUtils.btn_Cancel).pushNoBlock();
167: Util.wait(1000);
168: new QueueTool().waitEmpty();
169: try {
170: server.showNavigatorOperator().getTree().findPath(
171: EJBTestUtils.ejbNode + "|" + ejbSetName);
172: fail("EJB Set subnode [" + ejbSetName
173: + "] has been found under the Server's tree node ["
174: + EJBTestUtils.ejbNode + "]");
175: } catch (Exception e) {
176: TestUtils.outMsg("+++ EJB Set subnode [" + ejbSetName
177: + "] not found under the Server's tree node ["
178: + EJBTestUtils.ejbNode + "]");
179: }
180: Util.wait(1000);
181: new QueueTool().waitEmpty();
182: }
183:
184: public void testEJB_Dia_04_ValidJAR() {
185: String ejbSetName = "ValidJAR", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
186: + "Client.jar";
187: EJBTestUtils.addEJB(ejbSetName,
188: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
189: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
190: + File.separator + ejbJarName, "");
191: EJBTestUtils.endAddEJB();
192: server.showNavigatorOperator().getTree().findPath(
193: EJBTestUtils.ejbNode + "|" + ejbSetName);
194: TestUtils.wait(1000);
195:
196: // create and verify application
197: String errMsg = EJBTestUtils.createProjectWithEJB(ejbSetName,
198: "getGreeting", new String[] { ejbJarName,
199: ejbSetName + "ClientWrapper.jar",
200: ejbSetName + "DesignTime.jar", },
201: "Hello World", true, true);
202:
203: EJBTestUtils.removeEJB(ejbSetName);
204:
205: Util.wait(1000);
206: new QueueTool().waitEmpty();
207: if (errMsg != null) {
208: Assert.fail(errMsg);
209: }
210: }
211:
212: public void testEJB_Dia_05_ValidJAR_ValidEAR() {
213: String ejbSetName = "ValidJAR_ValidEAR", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
214: + "Client.jar", ejbEarName = ejbJarDir + ".ear";
215: EJBTestUtils.addEJB(ejbSetName,
216: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
217: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
218: + File.separator + ejbJarName,
219: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
220: + File.separator + ejbEarName);
221: EJBTestUtils.endAddEJB();
222:
223: server.showNavigatorOperator().getTree().findPath(
224: EJBTestUtils.ejbNode + "|" + ejbSetName);
225: TestUtils.wait(1000);
226:
227: // create and verify application
228: String errMsg = EJBTestUtils.createProjectWithEJB(ejbSetName,
229: "getGreeting", new String[] { ejbJarName,
230: ejbSetName + "ClientWrapper.jar",
231: ejbSetName + "DesignTime.jar", },
232: "Hello World", true, true);
233:
234: EJBTestUtils.removeEJB(ejbSetName);
235:
236: Util.wait(1000);
237: new QueueTool().waitEmpty();
238: if (errMsg != null) {
239: Assert.fail(errMsg);
240: }
241: }
242:
243: public void testEJB_Dia_06_ValidJAR_InvalidEAR() {
244: String ejbSetName = "ValidJAR_InvalidEAR", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbEarDir = "EJB_Invalid_EAR", ejbJarName = ejbJarDir
245: + "Client.jar", ejbEarName = ejbEarDir + ".ear";
246: EJBTestUtils.addEJB(ejbSetName,
247: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
248: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
249: + File.separator + ejbJarName,
250: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbEarDir
251: + File.separator + ejbEarName);
252: EJBTestUtils.endAddEJB();
253:
254: server.showNavigatorOperator().getTree().findPath(
255: EJBTestUtils.ejbNode + "|" + ejbSetName);
256: TestUtils.wait(1000);
257:
258: // create and verify application
259: String errMsg = EJBTestUtils.createProjectWithEJB(ejbSetName,
260: "getGreeting", new String[] { ejbJarName,
261: ejbSetName + "ClientWrapper.jar",
262: ejbSetName + "DesignTime.jar", },
263: "Hello World", true, true);
264:
265: EJBTestUtils.removeEJB(ejbSetName);
266:
267: Util.wait(1000);
268: new QueueTool().waitEmpty();
269: if (errMsg != null) {
270: Assert.fail(errMsg);
271: }
272: }
273:
274: public void testEJB_Dia_07_NoJAR_ValidEAR() {
275: String ejbSetName = "NoJAR_ValidEAR", ejbEarDir = "EJB_Valid_JAR_Valid_EAR", ejbEarName = ejbEarDir
276: + ".ear";
277: EJBTestUtils.addEJB(ejbSetName,
278: EJBTestUtils.RMI_IIOP_PORT_APPSERVER, "",
279: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbEarDir
280: + File.separator + ejbEarName);
281:
282: JDialogOperator dlg_error = new JDialogOperator();
283: Util.wait(1000);
284:
285: String dialogErrMessage = new JLabelOperator(dlg_error, lbIndex)
286: .getText().trim();
287: if (dialogErrMessage.indexOf(EJBTestUtils.msg_emptyJAR) == -1) {
288: Util.wait(1000);
289: new JButtonOperator(new JDialogOperator(),
290: EJBTestUtils.btn_Cancel).pushNoBlock();
291: Util.wait(1000);
292: new QueueTool().waitEmpty();
293: fail("No client JAR and valid EAR: Wrong message in the error-dialog!");
294: }
295: Util.wait(1000);
296: new JButtonOperator(new JDialogOperator(),
297: EJBTestUtils.btn_Cancel).pushNoBlock();
298: Util.wait(1000);
299: new QueueTool().waitEmpty();
300: try {
301: server.showNavigatorOperator().getTree().findPath(
302: EJBTestUtils.ejbNode + "|" + ejbSetName);
303: fail("EJB Set subnode [" + ejbSetName
304: + "] has been found under the Server's tree node ["
305: + EJBTestUtils.ejbNode + "]");
306: } catch (Exception e) {
307: TestUtils.outMsg("+++ EJB Set subnode [" + ejbSetName
308: + "] not found under the Server's tree node ["
309: + EJBTestUtils.ejbNode + "]");
310: }
311: Util.wait(1000);
312: new QueueTool().waitEmpty();
313: }
314:
315: public void testEJB_Dia_08_InvalidJAR_InvalidEAR() {
316: String ejbSetName = "InvalidJAR_InvalidEAR", ejbJarDir = "EJB_Invalid_JAR", ejbEarDir = "EJB_Invalid_EAR", ejbJarName = "EJB_Invalid_Client_JAR.jar", ejbEarName = ejbEarDir
317: + ".ear";
318: EJBTestUtils.addEJB(ejbSetName,
319: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
320: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
321: + File.separator + ejbJarName,
322: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbEarDir
323: + File.separator + ejbEarName);
324:
325: JDialogOperator dlg_error = new JDialogOperator();
326: Util.wait(1000);
327:
328: String dialogErrMessage = new JLabelOperator(dlg_error, lbIndex)
329: .getText().trim();
330: if (dialogErrMessage.indexOf(EJBTestUtils.msg_noDescriptor) == -1) {
331: Util.wait(1000);
332: new JButtonOperator(new JDialogOperator(),
333: EJBTestUtils.btn_Cancel).pushNoBlock();
334: Util.wait(1000);
335: new QueueTool().waitEmpty();
336: fail("Invalid JAR and Invalid EAR: Wrong message in the error-dialog!");
337: }
338: Util.wait(1000);
339: new JButtonOperator(new JDialogOperator(),
340: EJBTestUtils.btn_Cancel).pushNoBlock();
341: Util.wait(1000);
342: new QueueTool().waitEmpty();
343: try {
344: server.showNavigatorOperator().getTree().findPath(
345: EJBTestUtils.ejbNode + "|" + ejbSetName);
346: fail("EJB Set subnode [" + ejbSetName
347: + "] has been found under the Server's tree node ["
348: + EJBTestUtils.ejbNode + "]");
349: } catch (Exception e) {
350: TestUtils.outMsg("+++ EJB Set subnode [" + ejbSetName
351: + "] not found under the Server's tree node ["
352: + EJBTestUtils.ejbNode + "]");
353: }
354: Util.wait(1000);
355: new QueueTool().waitEmpty();
356: }
357:
358: public void testEJB_Dia_09_ValidJAR_NoPackage() {
359: String ejbSetName = "ValidJAR_NoPackage", ejbJarDir = "EJB_Valid_JAR_No_Package", ejbEarDir = "EJB_Valid_JAR_No_Package", ejbJarName = ejbJarDir
360: + "Client.jar", ejbEarName = ejbEarDir + ".ear";
361:
362: EJBTestUtils.addEJB(ejbSetName,
363: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
364: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
365: + File.separator + ejbJarName,
366: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbEarDir
367: + File.separator + ejbEarName);
368:
369: JDialogOperator dlg_error = new JDialogOperator();
370: Util.wait(1000);
371:
372: String dialogErrMessage = new JLabelOperator(dlg_error, lbIndex)
373: .getText().trim(), checkMessage = EJBTestUtils.msg_noEJBsFound
374: + " " + EJBTestUtils.msg_skipped;
375: if (dialogErrMessage.indexOf(checkMessage) == -1) {
376: Util.wait(1000);
377: new JButtonOperator(new JDialogOperator(),
378: EJBTestUtils.btn_Cancel).pushNoBlock();
379: Util.wait(1000);
380: new QueueTool().waitEmpty();
381: fail("Valid JAR without Package: Wrong message in the error-dialog!");
382: }
383: Util.wait(1000);
384: new JButtonOperator(new JDialogOperator(),
385: EJBTestUtils.btn_Cancel).pushNoBlock();
386: Util.wait(1000);
387: new QueueTool().waitEmpty();
388: try {
389: server.showNavigatorOperator().getTree().findPath(
390: EJBTestUtils.ejbNode + "|" + ejbSetName);
391: fail("EJB Set subnode [" + ejbSetName
392: + "] has been found under the Server's tree node ["
393: + EJBTestUtils.ejbNode + "]");
394: } catch (Exception e) {
395: TestUtils.outMsg("+++ EJB Set subnode [" + ejbSetName
396: + "] not found under the Server's tree node ["
397: + EJBTestUtils.ejbNode + "]");
398: }
399:
400: Util.wait(1000);
401: new QueueTool().waitEmpty();
402: }
403:
404: public void testEJB_Dia_10_ValidJARs_2EJBs() {
405: String ejbSetName = "Valid_JARs_2EJBs", ejbJarDir = "EJB_Valid_JARs_2EJBs", ejbEarDir = "EJB_Valid_JARs_2EJBs", ejbJarName = ejbJarDir
406: + "Client.jar", ejbEarName = ejbEarDir + ".ear";
407:
408: EJBTestUtils.addEJB(ejbSetName,
409: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
410: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
411: + File.separator + ejbJarName,
412: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
413: + File.separator + ejbEarName);
414: EJBTestUtils.endAddEJB();
415:
416: server.showNavigatorOperator().getTree().findPath(
417: EJBTestUtils.ejbNode + "|" + ejbSetName);
418: TestUtils.wait(1000);
419:
420: // create and verify application
421: String errMsg = EJBTestUtils.createProjectWithEJB(ejbSetName,
422: "getFarewell", new String[] { ejbJarName,
423: ejbSetName + "ClientWrapper.jar",
424: ejbSetName + "DesignTime.jar", }, "Good bye",
425: true, true);
426:
427: EJBTestUtils.removeEJB(ejbSetName);
428:
429: Util.wait(1000);
430: new QueueTool().waitEmpty();
431: if (errMsg != null) {
432: Assert.fail(errMsg);
433: }
434: }
435: }
|