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.dataconnectivity.ServerNavigatorOperator;
052: import org.netbeans.modules.visualweb.gravy.*;
053:
054: import javax.swing.tree.*;
055: import java.util.*;
056: import java.io.*;
057:
058: /**
059: *
060: * @author Roman Mostyka
061: */
062: public class ExportEJBTest extends RaveTestCase {
063:
064: private ServerNavigatorOperator server;
065: private JTreeOperator sntree;
066: private static String[] ejbSetNames;
067:
068: public ExportEJBTest(String testName) {
069: super (testName);
070: }
071:
072: public static Test suite() {
073: NbTestSuite suite = new NbTestSuite("EJB Export");
074: suite.addTest(new ExportEJBTest(
075: "testExportEJB_01_Default_Export_1_EJB"));
076: suite.addTest(new ExportEJBTest(
077: "testExportEJB_02_Specify_Path_1_EJB"));
078: suite.addTest(new ExportEJBTest(
079: "testExportEJB_03_Default_Export_All_EJBs"));
080: suite.addTest(new ExportEJBTest(
081: "testExportEJB_04_Default_Export_All_EJBs"));
082: suite.addTest(new ExportEJBTest(
083: "testExportEJB_05_Default_Export_Required_EJB"));
084: suite.addTest(new ExportEJBTest("testExportEJB_06_Cancel"));
085: suite.addTest(new ExportEJBTest("testExportEJB_07_Help"));
086: return suite;
087: }
088:
089: /** method called before each testcase */
090: protected void setUp() {
091: }
092:
093: public void testExportEJB_01_Default_Export_1_EJB() {
094: String ejbSetName = "Export_EJB_Set", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
095: + "Client.jar";
096: EJBTestUtils.addEJB(ejbSetName,
097: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
098: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
099: + File.separator + ejbJarName, "");
100: EJBTestUtils.endAddEJB();
101: TestUtils.wait(1000);
102:
103: String errMsg = EJBTestUtils.exportEJBSet(ejbSetName, true);
104: EJBTestUtils.removeEJB(ejbSetName);
105: Util.wait(1000);
106: new QueueTool().waitEmpty();
107: if (errMsg != null) {
108: Assert.fail(errMsg);
109: }
110: }
111:
112: public void testExportEJB_02_Specify_Path_1_EJB() {
113: String ejbSetName = "Export_EJB_Set", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
114: + "Client.jar", exportJarName = "export_EJB_Jar.jar", exportJarAbsoluteName = System
115: .getProperty("xtest.workdir")
116: + "/" + exportJarName;
117:
118: EJBTestUtils.addEJB(ejbSetName,
119: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
120: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
121: + File.separator + ejbJarName, "");
122: EJBTestUtils.endAddEJB();
123: TestUtils.wait(1000);
124:
125: String errMsg = EJBTestUtils.exportEJBSet(ejbSetName,
126: exportJarAbsoluteName, true);
127: EJBTestUtils.removeEJB(ejbSetName);
128: Util.wait(1000);
129: new QueueTool().waitEmpty();
130: if (errMsg != null) {
131: Assert.fail(errMsg);
132: }
133: }
134:
135: public void testExportEJB_03_Default_Export_All_EJBs() {
136: String ejbSetName = "ValidJAR", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
137: + "Client.jar";
138: EJBTestUtils.addEJB(ejbSetName,
139: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
140: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
141: + File.separator + ejbJarName, "");
142: EJBTestUtils.endAddEJB();
143: ejbSetName = "ValidJAR_ValidEAR";
144: ejbJarDir = "EJB_Valid_JAR_Valid_EAR";
145: ejbJarName = ejbJarDir + "Client.jar";
146: String ejbEarName = ejbJarDir + ".ear";
147: EJBTestUtils.addEJB(ejbSetName,
148: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
149: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
150: + File.separator + ejbJarName,
151: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
152: + File.separator + ejbEarName);
153: EJBTestUtils.endAddEJB();
154: ejbSetName = "ValidJAR_InvalidEAR";
155: ejbJarDir = "EJB_Valid_JAR_Valid_EAR";
156: String ejbEarDir = "EJB_Invalid_EAR";
157: ejbJarName = ejbJarDir + "Client.jar";
158: ejbEarName = ejbEarDir + ".ear";
159: EJBTestUtils.addEJB(ejbSetName,
160: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
161: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
162: + File.separator + ejbJarName,
163: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbEarDir
164: + File.separator + ejbEarName);
165: EJBTestUtils.endAddEJB();
166:
167: ejbSetNames = new String[] { "ValidJAR", "ValidJAR_ValidEAR",
168: "ValidJAR_InvalidEAR" };
169: ejbSetName = "ValidJAR_ValidEAR";
170: String ejbTreeNodePath = EJBTestUtils.ejbNode + "|"
171: + ejbSetName;
172:
173: List ejbSetNameList = EJBTestUtils.getAvailableEJBSetNameList();
174: String errMsg = EJBTestUtils.exportAllEJBSets(ejbTreeNodePath,
175: ejbSetNameList, true, true);
176: Util.wait(500);
177: new QueueTool().waitEmpty();
178: if (errMsg != null) {
179: Assert.fail(errMsg);
180: }
181: }
182:
183: public void testExportEJB_04_Default_Export_All_EJBs() {
184: String ejbTreeNodePath = EJBTestUtils.ejbNode;
185:
186: List ejbSetNameList = EJBTestUtils.getAvailableEJBSetNameList();
187: String errMsg = EJBTestUtils.exportAllEJBSets(ejbTreeNodePath,
188: ejbSetNameList, false, true);
189: Util.wait(500);
190: new QueueTool().waitEmpty();
191: if (errMsg != null) {
192: Assert.fail(errMsg);
193: }
194: }
195:
196: public void testExportEJB_05_Default_Export_Required_EJB() {
197: String ejbSetName = "ValidJAR_ValidEAR";
198: String errMsg = EJBTestUtils
199: .exportRequiredEJBSets(new String[] { ejbSetName });
200: Util.wait(500);
201: new QueueTool().waitEmpty();
202: if (errMsg != null) {
203: Assert.fail(errMsg);
204: }
205: }
206:
207: public void testExportEJB_06_Cancel() {
208: String ejbSetName = "Export_EJB_Set", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
209: + "Client.jar";
210: EJBTestUtils.addEJB(ejbSetName,
211: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
212: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
213: + File.separator + ejbJarName, "");
214: EJBTestUtils.endAddEJB();
215: TestUtils.wait(1000);
216:
217: server = ServerNavigatorOperator.showNavigatorOperator();
218: Util.wait(1000);
219: String ejbTreeNodePath = EJBTestUtils.ejbNode + "|"
220: + ejbSetName;
221: server.pushPopup(ejbTreeNodePath, EJBTestUtils.exportEJBPopup);
222: Util.wait(1000);
223:
224: JDialogOperator dlg_export = new JDialogOperator(
225: EJBTestUtils.dlg_exportEJB);
226: Util.wait(1000);
227: new QueueTool().waitEmpty();
228:
229: new JButtonOperator(dlg_export, EJBTestUtils.btn_Cancel)
230: .pushNoBlock();
231: Util.wait(1000);
232: new QueueTool().waitEmpty();
233:
234: String errMsg = null;
235: try {
236: dlg_export = new JDialogOperator(EJBTestUtils.dlg_exportEJB);
237: Util.wait(1000);
238: errMsg = "Dialog [" + dlg_export.getTitle() + "] exists";
239: } catch (Exception e) {
240: TestUtils.outMsg("+++ Dialog [" + dlg_export.getTitle()
241: + "] not found");
242: }
243: EJBTestUtils.removeEJB(ejbSetName);
244: Util.wait(1000);
245: new QueueTool().waitEmpty();
246: if (errMsg != null) {
247: Assert.fail(errMsg);
248: }
249: }
250:
251: public void testExportEJB_07_Help() {
252: server = ServerNavigatorOperator.showNavigatorOperator();
253: Util.wait(1000);
254: String ejbTreeNodePath = EJBTestUtils.ejbNode;
255: server.pushPopup(ejbTreeNodePath, EJBTestUtils.exportEJBsPopup);
256: Util.wait(1000);
257:
258: JDialogOperator dialog = new JDialogOperator(
259: EJBTestUtils.dlg_exportEJB);
260: Util.wait(1000);
261: new QueueTool().waitEmpty();
262:
263: new JButtonOperator(dialog, EJBTestUtils.btn_Help)
264: .pushNoBlock();
265: Util.wait(10000);
266: new QueueTool().waitEmpty();
267:
268: String errMsg = null;
269: try {
270: try {
271: dialog = new JDialogOperator(
272: EJBTestUtils.dlg_export_help);
273: Util.wait(1000);
274: TestUtils.outMsg("+++ Dialog [" + dialog.getTitle()
275: + "] exists");
276: dialog.close();
277: } catch (Exception e) {
278: JFrameOperator frame = new JFrameOperator(
279: EJBTestUtils.dlg_export_help);
280: Util.wait(1000);
281: TestUtils.outMsg("+++ Frame [" + frame.getTitle()
282: + "] exists");
283: frame.close();
284: }
285:
286: Util.wait(1000);
287: new QueueTool().waitEmpty();
288:
289: dialog = new JDialogOperator(EJBTestUtils.dlg_exportEJB);
290: Util.wait(1000);
291: new QueueTool().waitEmpty();
292: new JButtonOperator(dialog, EJBTestUtils.btn_Cancel)
293: .pushNoBlock();
294: Util.wait(1000);
295: new QueueTool().waitEmpty();
296: } catch (Exception e) {
297: errMsg = "Dialog [" + EJBTestUtils.dlg_export_help
298: + "] not found";
299: }
300: for (int i = 0; i < ejbSetNames.length; ++i) {
301: EJBTestUtils.removeEJB(ejbSetNames[i]);
302: }
303: Util.wait(1000);
304: new QueueTool().waitEmpty();
305: if (errMsg != null) {
306: Assert.fail(errMsg);
307: }
308: EJBTestUtils.getApplicationServer().stop();
309: }
310: }
|