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-2007 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.uml.ejb;
043:
044: import org.netbeans.jellytools.ProjectsTabOperator;
045: import org.netbeans.jemmy.EventTool;
046: import org.netbeans.jemmy.JemmyProperties;
047: import org.netbeans.jemmy.operators.JDialogOperator;
048: import org.netbeans.junit.NbTestSuite;
049:
050: import org.netbeans.test.uml.ejb.utils.EJBCreator;
051: import org.netbeans.test.umllib.DiagramOperator;
052: import org.netbeans.test.umllib.exceptions.KnownBugException;
053: import org.netbeans.test.umllib.exceptions.NotFoundException;
054: import org.netbeans.test.umllib.testcases.UMLTestCase;
055:
056: public class CreatingEJBsWithoutSubstitution extends UMLTestCase {
057:
058: private EventTool eventTool = new EventTool();
059: private boolean failedByBug = false;
060: private static String workdir = System.getProperty("xtest.workdir");
061: private static String prName = "EJB_uml";
062: private static String project = prName + "|Model";
063: private static boolean codeSync = false;
064: private static String lastTestCase = "";
065:
066: public CreatingEJBsWithoutSubstitution(String name) {
067: super (name);
068: }
069:
070: public static NbTestSuite suite() {
071: NbTestSuite suite = new NbTestSuite(
072: CreatingEJBsWithoutSubstitution.class);
073: return suite;
074: }
075:
076: /******************const section*************************/
077: private String INVOKATION_POINT = "Model|pkg";
078: private String PROJECT_NAME = "EJB_uml";
079: private String EXCEPTION_DLG = "Exception";
080:
081: /********************************************************/
082:
083: EJBCreator creator = new EJBCreator(PROJECT_NAME);
084: org.netbeans.test.uml.ejb.utils.Util util = new org.netbeans.test.uml.ejb.utils.Util();
085:
086: protected void setUp() {
087: ProjectsTabOperator.invoke();
088: if (!codeSync) {
089: util.commonSetup(workdir, prName);
090: //
091: codeSync = true;
092: }
093: closeAllModal();
094: }
095:
096: public void testEJB1_BMP() throws NotFoundException {
097: lastTestCase = getCurrentTestMethodName();
098: final String ejbType = EJBCreator.EJB_1;
099: final String ejbName = EJBCreator.BMP;
100: final String namespace = null;
101: final boolean createDiagram = true;
102: final String diagramName = "EJB1_BMP";
103: final String parentPath = "Model";
104: String[] elementNames = new String[] { "BMPHome", "BMPBean",
105: "BMP" };
106: //creating EJBs:
107: DiagramOperator dia = null;
108: try {
109: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
110: namespace, createDiagram, diagramName);
111: } catch (KnownBugException ex) {
112: fail(ex.getBugId(), ex.getMessage());
113: }
114: eventTool.waitNoEvent(2000);
115: //verification:
116: if (!util.diagramHasExactElements(elementNames, dia)) {
117: fail("testEJB1_BMP verification failed ");
118: }
119:
120: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
121: fail("testEJB1_BMP verification failed ");
122: }
123:
124: if (!util.nodeExists(parentPath + "|" + diagramName,
125: PROJECT_NAME)) {
126: fail("testEJB1_BMP verification failed ");
127: }
128:
129: }
130:
131: public void testEJB1_CMP() throws NotFoundException {
132: lastTestCase = getCurrentTestMethodName();
133: final String ejbType = EJBCreator.EJB_1;
134: final String ejbName = EJBCreator.CMP;
135: final String namespace = null;
136: final boolean createDiagram = true;
137: final String diagramName = "EJB1_CMP";
138: String[] elementNames = new String[] { "CMPHome", "CMPBean",
139: "CMP" };
140: final String parentPath = "Model";
141: //creating EJBs:
142: DiagramOperator dia = null;
143: try {
144: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
145: namespace, createDiagram, diagramName);
146: } catch (KnownBugException ex) {
147: fail(ex.getBugId(), ex.getMessage());
148: }
149: if (!util.diagramHasExactElements(elementNames, dia)) {
150: fail("testEJB1_CMP verification failed ");
151: }
152:
153: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
154: fail("testEJB1_CMP verification failed ");
155: }
156:
157: if (!util.nodeExists(parentPath + "|" + diagramName,
158: PROJECT_NAME)) {
159: fail("testEJB1_CMP verification failed ");
160: }
161:
162: }
163:
164: public void testEJB1_SSTL() throws NotFoundException {
165: lastTestCase = getCurrentTestMethodName();
166: final String ejbType = EJBCreator.EJB_1;
167: final String ejbName = EJBCreator.SESSION_STATELESS;
168: final String namespace = null;
169: final boolean createDiagram = true;
170: final String diagramName = "EJB1_STTL";
171: String[] elementNames = new String[] { "StatelessSession",
172: "StatelessSessionHome", "StatelessSessionBean" };
173: final String parentPath = "Model";
174: //creating EJBs:
175: DiagramOperator dia = null;
176: try {
177: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
178: namespace, createDiagram, diagramName);
179: } catch (KnownBugException ex) {
180: fail(ex.getBugId(), ex.getMessage());
181: }
182:
183: if (!util.diagramHasExactElements(elementNames, dia)) {
184: fail("testEJB1_SSTL verification failed ");
185: }
186:
187: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
188: fail("testEJB1_SSTL verification failed ");
189: }
190:
191: if (!util.nodeExists(parentPath + "|" + diagramName,
192: PROJECT_NAME)) {
193: fail("testEJB1_SSTL verification failed ");
194: }
195:
196: }
197:
198: public void testEJB1_SSTF() throws NotFoundException {
199: lastTestCase = getCurrentTestMethodName();
200: final String ejbType = EJBCreator.EJB_1;
201: final String ejbName = EJBCreator.SESSION_STATEFUL;
202: final String namespace = null;
203: final boolean createDiagram = true;
204: final String diagramName = "EJB1_SSTF";
205: String[] elementNames = new String[] { "StatefulSession",
206: "StatefulSessionHome", "StatefulSessionBean" };
207: final String parentPath = "Model";
208: //creating EJBs:
209: DiagramOperator dia = null;
210: try {
211: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
212: namespace, createDiagram, diagramName);
213: } catch (KnownBugException ex) {
214: fail(ex.getBugId(), ex.getMessage());
215: }
216:
217: if (!util.diagramHasExactElements(elementNames, dia)) {
218: fail("testEJB1_SSTL verification failed ");
219: }
220:
221: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
222: fail("testEJB1_SSTL verification failed ");
223: }
224:
225: if (!util.nodeExists(parentPath + "|" + diagramName,
226: PROJECT_NAME)) {
227: fail("testEJB1_SSTL verification failed ");
228: }
229:
230: }
231:
232: public void testEJB2_BMP() throws NotFoundException {
233: lastTestCase = getCurrentTestMethodName();
234: final String ejbType = EJBCreator.EJB_2;
235: final String ejbName = EJBCreator.BMP;
236: final String namespace = "pkg";
237: final boolean createDiagram = true;
238: final String diagramName = "EJB2_BMP";
239: final String parentPath = "Model|pkg";
240: String[] elementNames = new String[] { "BMPHome", "BMPBean",
241: "BMP", "BMPLocal", "BMPLocalHome" };
242: //creating EJBs:
243: DiagramOperator dia = null;
244: try {
245: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
246: namespace, createDiagram, diagramName);
247: } catch (KnownBugException ex) {
248: fail(ex.getBugId(), ex.getMessage());
249: }
250:
251: if (!util.diagramHasExactElements(elementNames, dia)) {
252: fail("testEJB2_BMP verification failed ");
253: }
254:
255: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
256: fail("testEJB2_BMP verification failed ");
257: }
258:
259: if (!util.nodeExists(parentPath + "|" + diagramName,
260: PROJECT_NAME)) {
261: fail("testEJB2_BMP verification failed ");
262: }
263:
264: }
265:
266: public void testEJB2_CMP() throws NotFoundException {
267: lastTestCase = getCurrentTestMethodName();
268: final String ejbType = EJBCreator.EJB_2;
269: final String ejbName = EJBCreator.CMP;
270: final String namespace = "pkg";
271: final boolean createDiagram = true;
272: final String diagramName = "EJB2_CMP";
273: String[] elementNames = new String[] { "CMPHome",
274: "CMPLocalHome", "CMPBean", "CMP", "CMPLocal" };
275: final String parentPath = "Model|pkg";
276: //creating EJBs:
277: DiagramOperator dia = null;
278: try {
279: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
280: namespace, createDiagram, diagramName);
281: } catch (KnownBugException ex) {
282: fail(ex.getBugId(), ex.getMessage());
283: }
284:
285: if (!util.diagramHasExactElements(elementNames, dia)) {
286: fail("testEJB2_CMP verification failed ");
287: }
288:
289: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
290: fail("testEJB2_CMP verification failed ");
291: }
292:
293: if (!util.nodeExists(parentPath + "|" + diagramName,
294: PROJECT_NAME)) {
295: fail("testEJB2_CMP verification failed ");
296: }
297:
298: }
299:
300: public void testEJB2_SSTL() throws NotFoundException {
301: lastTestCase = getCurrentTestMethodName();
302: final String ejbType = EJBCreator.EJB_2;
303: final String ejbName = EJBCreator.SESSION_STATELESS;
304: final String namespace = "pkg";
305: final boolean createDiagram = true;
306: final String diagramName = "EJB2_STTL";
307: String[] elementNames = new String[] { "StatelessSession",
308: "StatelessSessionHome", "StatelessSessionBean",
309: "StatelessSessionLocal", "StatelessSessionLocalHome" };
310: final String parentPath = "Model|pkg";
311: //creating EJBs:
312: DiagramOperator dia = null;
313: try {
314: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
315: namespace, createDiagram, diagramName);
316: } catch (KnownBugException ex) {
317: fail(ex.getBugId(), ex.getMessage());
318: }
319:
320: if (!util.diagramHasExactElements(elementNames, dia)) {
321: fail("testEJB2_SSTL verification failed ");
322: }
323:
324: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
325: fail("testEJB2_SSTL verification failed ");
326: }
327:
328: if (!util.nodeExists(parentPath + "|" + diagramName,
329: PROJECT_NAME)) {
330: fail("testEJB2_SSTL verification failed ");
331: }
332:
333: }
334:
335: public void testEJB2_SSTF() throws NotFoundException {
336: lastTestCase = getCurrentTestMethodName();
337: final String ejbType = EJBCreator.EJB_2;
338: final String ejbName = EJBCreator.SESSION_STATEFUL;
339: final String namespace = "pkg";
340: final boolean createDiagram = true;
341: final String diagramName = "EJB2_SSTF";
342: String[] elementNames = new String[] { "StatefulSession",
343: "StatefulSessionHome", "StatefulSessionBean",
344: "StatefulSessionLocal", "StatefulSessionLocalHome" };
345: final String parentPath = "Model|pkg";
346: //creating EJBs:
347: DiagramOperator dia = null;
348: try {
349: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
350: namespace, createDiagram, diagramName);
351: } catch (KnownBugException ex) {
352: fail(ex.getBugId(), ex.getMessage());
353: }
354:
355: if (!util.diagramHasExactElements(elementNames, dia)) {
356: fail("testEJB2_SSTF verification failed ");
357: }
358:
359: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
360: fail("testEJB2_SSTF verification failed ");
361: }
362:
363: if (!util.nodeExists(parentPath + "|" + diagramName,
364: PROJECT_NAME)) {
365: fail("testEJB2_SSTF verification failed ");
366: }
367:
368: }
369:
370: public void testEJB2_MDB() throws NotFoundException {
371: lastTestCase = getCurrentTestMethodName();
372: final String ejbType = EJBCreator.EJB_2;
373: final String ejbName = EJBCreator.MDB;
374: final String namespace = "pkg";
375: final boolean createDiagram = true;
376: final String diagramName = "EJB2_MDB";
377: String[] elementNames = new String[] { "AsyncMessageBean" };
378: final String parentPath = "Model|pkg";
379: //creating EJBs:
380: DiagramOperator dia = null;
381: try {
382: dia = creator.create(INVOKATION_POINT, ejbType, ejbName,
383: namespace, createDiagram, diagramName);
384: } catch (KnownBugException ex) {
385: fail(ex.getBugId(), ex.getMessage());
386: }
387:
388: if (!util.diagramHasExactElements(elementNames, dia)) {
389: fail("testEJB2_MDB verification failed ");
390: }
391:
392: if (!util.allNodesExist(PROJECT_NAME, parentPath, elementNames)) {
393: fail("testEJB2_MDB verification failed ");
394: }
395:
396: if (!util.nodeExists(parentPath + "|" + diagramName,
397: PROJECT_NAME)) {
398: fail("testEJB2_MDB verification failed ");
399: }
400:
401: }
402:
403: public void tearDown() {
404: org.netbeans.test.umllib.util.Utils
405: .makeScreenShot(lastTestCase);
406: org.netbeans.test.umllib.util.Utils.saveAll();
407:
408: long timeoutValDlg = JemmyProperties
409: .getCurrentTimeout("DialogWaiter.WaitDialogTimeout");
410: try {
411: JemmyProperties.setCurrentTimeout(
412: "DialogWaiter.WaitDialogTimeout", 1000);
413: new JDialogOperator(EXCEPTION_DLG).close();
414: if (!failedByBug) {
415: fail("Unexpected Exception dialog was found");
416: }
417: } catch (Exception excp) {
418: } finally {
419: if (failedByBug) {
420: failedByBug = false;
421: }
422: JemmyProperties.setCurrentTimeout(
423: "DialogWaiter.WaitDialogTimeout", timeoutValDlg);
424: util.closeSaveDlg();
425: closeAllModal();
426: }
427: }
428:
429: }
|