websvc.restkit/test/qa-functional/src/org/netbeans/modules/ws/qaf/rest/FromDBTest.java
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
24 * If you wish your version of this file to be governed by only the CDDL
25 * or only the GPL Version 2, indicate your decision by adding
26 * "[Contributor] elects to include this software in this distribution
27 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28 * single choice of license, a recipient has the option to distribute
29 * your version of this file under either the CDDL, the GPL Version 2 or
30 * to extend the choice of license to its licensees as provided above.
31 * However, if you add GPL Version 2 code and therefore, elected the GPL
32 * Version 2 license, then the option applies only if the new code is
33 * made subject to such option by the copyright holder.
37 * Portions Copyrighted 2008 Sun Microsystems, Inc.
39 package org.netbeans.modules.ws.qaf.rest;
42 import java.io.IOException;
44 import javax.swing.JDialog;
45 import junit.framework.Test;
46 import org.netbeans.jellytools.Bundle;
47 import org.netbeans.jellytools.WizardOperator;
48 import org.netbeans.jellytools.actions.ActionNoBlock;
49 import org.netbeans.jellytools.actions.OutputWindowViewAction;
50 import org.netbeans.jemmy.EventTool;
51 import org.netbeans.jemmy.operators.JButtonOperator;
52 import org.netbeans.jemmy.operators.JComboBoxOperator;
53 import org.netbeans.jemmy.operators.JDialogOperator;
54 import org.netbeans.junit.NbModuleSuite;
55 import org.netbeans.modules.ws.qaf.utilities.RestWizardOperator;
58 * Tests for New REST web services from Database wizard
62 public class FromDBTest extends CRUDTest {
64 public FromDBTest(String name) {
69 protected String getProjectName() {
70 return "FromDB"; //NOI18N
74 protected String getRestPackage() {
75 return "o.n.m.ws.qaf.rest.fromdb"; //NOI18N
78 public void testFromDB() throws IOException {
80 new OutputWindowViewAction().performMenu();
81 new ActionNoBlock("Window|Tasks", null).performMenu();
82 new ActionNoBlock("Window|Close Window", null).performMenu();
85 //RESTful Web Services from Database
86 String restLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.rest.wizard.Bundle", "Templates/WebServices/RestServicesFromDatabase");
87 createNewWSFile(getProject(), restLabel);
88 //Entity Classes from Database
89 String fromDbLabel = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.persistence.wizard.fromdb.Bundle", "Templates/Persistence/RelatedCMP");
90 WizardOperator wo = prepareEntityClasses(new RestWizardOperator(fromDbLabel), false);
92 JComboBoxOperator jcbo = new JComboBoxOperator(wo, 1);
94 jcbo.typeText(getRestPackage() + ".service"); //NOI18N
95 jcbo = new JComboBoxOperator(wo, 2);
97 jcbo.typeText(getRestPackage() + ".converter"); //NOI18N
99 Runnable r = new Runnable() {
101 private boolean found = false;
104 String dlgLbl = "REST Resources Configuration";
105 JDialog dlg = JDialogOperator.findJDialog(dlgLbl, true, true);
108 new JButtonOperator(new JDialogOperator(dlg), "OK").push();
113 new Thread(r).start();
114 String generationTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.persistence.wizard.fromdb.Bundle", "TXT_EntityClassesGeneration");
115 waitDialogClosed(generationTitle);
116 new EventTool().waitNoEvent(1500);
118 Set<File> files = getFiles(getRestPackage() + ".service"); //NOI18N
119 files.addAll(getFiles(getRestPackage() + ".converter")); //NOI18N
120 assertEquals("Some files were not generated", 30, files.size()); //NOI18N
121 //make sure all REST services nodes are visible in project log. view
122 assertEquals("missing nodes?", 14, getRestNode().getChildren().length);
125 private void createPU() {
127 String category = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.persistence.ui.resources.Bundle", "Templates/Persistence");
129 String puLabel = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.persistence.wizard.unit.Bundle", "Templates/Persistence/PersistenceUnit");
130 createNewFile(getProject(), category, puLabel);
131 String title = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.persistence.unit.Bundle", "LBL_NewPersistenceUnit");
132 WizardOperator wo = new WizardOperator(title);
133 new JComboBoxOperator(wo, 1).selectItem("jdbc/sample"); //NOI18N
138 * Creates suite from particular test cases. You can define order of testcases here.
140 public static Test suite() {
141 return NbModuleSuite.create(addServerTests(Server.GLASSFISH_V3, NbModuleSuite.createConfiguration(FromDBTest.class),
142 "testFromDB", //NOI18N
143 "testDeploy", //NOI18N
144 "testUndeploy").enableModules(".*").clusters(".*")); //NOI18N