websvc.kit/test/qa-functional/src/org/netbeans/modules/ws/qaf/wsdl/FromWSDLTSuite.java
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2009 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.
40 package org.netbeans.modules.ws.qaf.wsdl;
43 import java.io.IOException;
44 import junit.framework.Test;
45 import org.netbeans.api.project.Project;
46 import org.netbeans.jellytools.Bundle;
47 import org.netbeans.jellytools.EditorOperator;
48 import org.netbeans.jellytools.NewJavaFileNameLocationStepOperator;
49 import org.netbeans.jellytools.nodes.Node;
50 import org.netbeans.jellytools.nodes.SourcePackagesNode;
51 import org.netbeans.jemmy.JemmyProperties;
52 import org.netbeans.jemmy.operators.JTextFieldOperator;
53 import org.netbeans.junit.NbModuleSuite;
54 import org.netbeans.modules.ws.qaf.WsValidation;
55 import org.openide.filesystems.FileObject;
56 import org.openide.filesystems.FileUtil;
62 public class FromWSDLTSuite extends WsValidation {
64 /** Default constructor.
65 * @param testName name of particular test case
67 public FromWSDLTSuite(String name) {
72 protected String getWsClientPackage() {
73 return "o.n.m.ws.qaf.client.wsdl"; //NOI18N
77 protected String getWsClientProjectName() {
78 return "WsClientFromWSDL"; //NOI18N
82 protected String getWsName() {
83 return super.getWsName();
87 protected String getWsPackage() {
88 return "o.n.m.ws.qaf.ws.wsdl"; //NOI18N
92 protected String getWsProjectName() {
93 return "WsFromWSDL"; //NOI18N
96 public static Test suite() {
97 return NbModuleSuite.create(addServerTests(
98 NbModuleSuite.createConfiguration(FromWSDLTSuite.class),
100 "testRefreshService",
101 "testRefreshServiceAndReplaceWSDL"
102 ).enableModules(".*").clusters(".*"));
105 public void testWSFromWSDL() throws IOException {
106 File wsdl = new File(getDataDir(), "resources/AddNumbers.wsdl");
107 String wsdlPath = wsdl.getCanonicalPath();
108 createNewWSFromWSDL(getProject(), getWsName(), getWsPackage(), wsdlPath);
109 JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 60000); //NOI18N
110 Node wsRootNode = new Node(getProjectRootNode(), WEB_SERVICES_NODE_NAME);
112 Node wsNode = new Node(wsRootNode, "AddNumbers"); //NOI18N
114 JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 60000); //NOI18N
115 new Node(wsNode, "addNumbers"); //NOI18N
116 assertTrue("There's no \"oneWayInt\" node", wsNode.isChildPresent("oneWayInt")); //NOI18N
117 assertEquals("Only two operations should be there", 2, wsNode.getChildren().length);
118 SourcePackagesNode spn = new SourcePackagesNode(getProjectRootNode());
120 new Node(spn, getWsPackage() + "|" + getWsName());
121 EditorOperator eo = new EditorOperator(getWsName());
122 assertTrue(eo.contains("AddNumbersFault_Exception"));
123 assertTrue(eo.contains("org.netbeans.websvc.qatests.ws.addnumbers.AddNumbersPortType"));
124 FileObject srcRoot = getProject().getProjectDirectory().getFileObject("src/java");
125 File createdFile = new File(FileUtil.toFile(srcRoot), getWsPackage().replace('.', '/') + "/" + getWsName() + ".java");
126 assertTrue("Ws Impl class has not been created", createdFile.exists());
129 protected void createNewWSFromWSDL(Project p, String name, String pkg, String wsdl) throws IOException {
130 //Web Service from WSDL
131 String fromWSDLLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.dev.wizard.Bundle", "Templates/WebServices/WebServiceFromWSDL.java");
132 createNewWSFile(p, fromWSDLLabel);
133 NewJavaFileNameLocationStepOperator op = new NewJavaFileNameLocationStepOperator();
134 op.txtObjectName().clearText();
135 op.txtObjectName().typeText(name);
136 op.cboPackage().clearText();
137 op.cboPackage().typeText(pkg);
138 JTextFieldOperator jtfo = new JTextFieldOperator(op, 0);
141 //Need to wait until WSPort txt field is populated
142 jtfo = new JTextFieldOperator(op, 1);
143 //the format of port selection is: "<serviceName>#<portName>"
144 jtfo.waitText("#"); //NOI18N
146 boolean isAnt = getProjectType().isAntBasedProject();
147 waitForWsImport("(wsimport-service-" + name, isAnt); //NOI18N
151 public void testRefreshService() {
152 refreshWSDL("service","AddNumbersService[AddNumbersPort]",false);
156 public void testRefreshServiceAndReplaceWSDL() {
157 refreshWSDL("service","AddNumbersService[AddNumbersPort]",true);