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:
050: import org.netbeans.modules.visualweb.gravy.dataconnectivity.*;
051: import org.netbeans.modules.visualweb.gravy.*;
052:
053: import java.awt.event.*;
054: import java.io.*;
055:
056: /**
057: * @author Roman Mostyka
058: */
059: public class EJBNodeTest extends RaveTestCase {
060: public ServerNavigatorOperator server;
061: public JTreeOperator sntree;
062:
063: public EJBNodeTest(String testName) {
064: super (testName);
065: }
066:
067: public static Test suite() {
068: NbTestSuite suite = new NbTestSuite("EJB Node");
069: suite.addTest(new EJBNodeTest("testEJB_Node_01_Popup"));
070: suite
071: .addTest(new EJBNodeTest(
072: "testEJB_Node_02_ExpandCollapse"));
073: suite.addTest(new EJBNodeTest("testEJB_Node_03_AddDialog"));
074: return suite;
075: }
076:
077: /** method called before each testcase
078: */
079: protected void setUp() {
080: }
081:
082: public void testEJB_Node_01_Popup() {
083: server = ServerNavigatorOperator.showNavigatorOperator();
084: TestUtils.wait(1000);
085: sntree = server.getTree();
086: sntree.callPopupOnPath(sntree.findPath(EJBTestUtils.ejbNode));
087: TestUtils.wait(1000);
088: JPopupMenuOperator snpm = new JPopupMenuOperator();
089: TestUtils.wait(1000);
090:
091: EJBTestUtils.checkPopupMenuItemList(snpm, new String[] {
092: EJBTestUtils.sessionEJBPopup,
093: EJBTestUtils.importEJBPopup,
094: EJBTestUtils.exportEJBsPopup });
095: TestUtils.wait(1000);
096:
097: String timeoutName = "WindowWaiter.WaitWindowTimeout";
098: long timeoutValue = JemmyProperties
099: .getCurrentTimeout(timeoutName);
100: JemmyProperties.getCurrentTimeouts().setTimeout(timeoutName,
101: 8000);
102:
103: sntree.pressKey(KeyEvent.VK_ESCAPE);
104: TestUtils.wait(1000);
105: try {
106: snpm = new JPopupMenuOperator();
107: fail("Popup menu is still displayed after pressing the key ESC.");
108: } catch (Exception e) {
109: e.printStackTrace();
110: TestUtils
111: .outMsg("+++ Popup menu has disappeared after pressing the key ESC.");
112: }
113: TestUtils.wait(1000);
114:
115: sntree.callPopupOnPath(sntree.findPath(EJBTestUtils.ejbNode));
116: TestUtils.wait(1000);
117: snpm = new JPopupMenuOperator();
118: TestUtils.wait(1000);
119: sntree.clickOnPath(sntree.findPath(EJBTestUtils.ejbNode));
120: TestUtils.wait(1000);
121: try {
122: snpm = new JPopupMenuOperator();
123: fail("Popup menu is still displayed after mouse clicking.");
124: } catch (Exception e) {
125: e.printStackTrace();
126: TestUtils
127: .outMsg("+++ Popup menu has disappeared after mouse clicking.");
128: }
129: }
130:
131: public void testEJB_Node_02_ExpandCollapse() {
132: String ejbSetName = "ValidJAR", ejbJarDir = "EJB_Valid_JAR_Valid_EAR", ejbJarName = ejbJarDir
133: + "Client.jar";
134: EJBTestUtils.addEJB(ejbSetName,
135: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
136: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
137: + File.separator + ejbJarName, "");
138: EJBTestUtils.endAddEJB();
139: ejbSetName = "ValidJAR_ValidEAR";
140: ejbJarDir = "EJB_Valid_JAR_Valid_EAR";
141: ejbJarName = ejbJarDir + "Client.jar";
142: String ejbEarName = ejbJarDir + ".ear";
143: EJBTestUtils.addEJB(ejbSetName,
144: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
145: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
146: + File.separator + ejbJarName,
147: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
148: + File.separator + ejbEarName);
149: EJBTestUtils.endAddEJB();
150: ejbSetName = "ValidJAR_InvalidEAR";
151: ejbJarDir = "EJB_Valid_JAR_Valid_EAR";
152: String ejbEarDir = "EJB_Invalid_EAR";
153: ejbJarName = ejbJarDir + "Client.jar";
154: ejbEarName = ejbEarDir + ".ear";
155: EJBTestUtils.addEJB(ejbSetName,
156: EJBTestUtils.RMI_IIOP_PORT_APPSERVER,
157: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbJarDir
158: + File.separator + ejbJarName,
159: EJBTestUtils.EJB_JARS_PATH + File.separator + ejbEarDir
160: + File.separator + ejbEarName);
161: EJBTestUtils.endAddEJB();
162:
163: String[] ejbSetNames = new String[] { "ValidJAR",
164: "ValidJAR_ValidEAR", "ValidJAR_InvalidEAR" };
165: server = ServerNavigatorOperator.showNavigatorOperator();
166: TestUtils.wait(1000);
167: sntree = server.getTree();
168: sntree.collapsePath(sntree.findPath(EJBTestUtils.ejbNode));
169: TestUtils.wait(1000);
170: sntree.expandPath(sntree.findPath(EJBTestUtils.ejbNode));
171: TestUtils.wait(1000);
172: for (int i = 0; i < ejbSetNames.length; ++i) {
173: sntree
174: .findPath(EJBTestUtils.ejbNode + "|"
175: + ejbSetNames[i]);
176: }
177: TestUtils.wait(1000);
178: new QueueTool().waitEmpty();
179: for (int i = 0; i < ejbSetNames.length; ++i) {
180: EJBTestUtils.removeEJB(ejbSetNames[i]);
181: }
182: }
183:
184: public void testEJB_Node_03_AddDialog() {
185: server = ServerNavigatorOperator.showNavigatorOperator();
186: TestUtils.wait(1000);
187: sntree = server.getTree();
188: server.pushPopup(EJBTestUtils.ejbNode,
189: EJBTestUtils.sessionEJBPopup);
190: TestUtils.wait(1000);
191: new JButtonOperator(new JDialogOperator(),
192: EJBTestUtils.btn_Cancel).pushNoBlock();
193: TestUtils.wait(1000);
194: new QueueTool().waitEmpty();
195: }
196: }
|