xml.wsdl.refactoring/test/unit/src/org/netbeans/modules/xml/wsdl/refactoring/WSDLRefactoringEngineTest.java
Disable some tests which block the test execution on the ci server by showing dialogs.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7 * Other names may be trademarks of their respective owners.
9 * The contents of this file are subject to the terms of either the GNU
10 * General Public License Version 2 only ("GPL") or the Common
11 * Development and Distribution License("CDDL") (collectively, the
12 * "License"). You may not use this file except in compliance with the
13 * License. You can obtain a copy of the License at
14 * http://www.netbeans.org/cddl-gplv2.html
15 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16 * specific language governing permissions and limitations under the
17 * License. When distributing the software, include this License Header
18 * Notice in each file and include the License file at
19 * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
20 * particular file as subject to the "Classpath" exception as provided
21 * by Oracle in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the
23 * License Header, with the fields enclosed by brackets [] replaced by
24 * your own identifying information:
25 * "Portions Copyrighted [year] [name of copyright owner]"
29 * The Original Software is NetBeans. The Initial Developer of the Original
30 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
31 * Microsystems, Inc. All Rights Reserved.
33 * If you wish your version of this file to be governed by only the CDDL
34 * or only the GPL Version 2, indicate your decision by adding
35 * "[Contributor] elects to include this software in this distribution
36 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37 * single choice of license, a recipient has the option to distribute
38 * your version of this file under either the CDDL, the GPL Version 2 or
39 * to extend the choice of license to its licensees as provided above.
40 * However, if you add GPL Version 2 code and therefore, elected the GPL
41 * Version 2 license, then the option applies only if the new code is
42 * made subject to such option by the copyright holder.
45 package org.netbeans.modules.xml.wsdl.refactoring;
47 import java.io.IOException;
48 import java.util.List;
49 import junit.framework.*;
50 import org.netbeans.modules.refactoring.api.RefactoringSession;
51 import org.netbeans.modules.refactoring.api.RenameRefactoring;
52 import org.netbeans.modules.xml.refactoring.XMLRefactoringTransaction;
53 import org.netbeans.modules.xml.refactoring.spi.ChangeExecutor;
54 import org.netbeans.modules.xml.wsdl.model.Binding;
55 import org.netbeans.modules.xml.wsdl.model.BindingFault;
56 import org.netbeans.modules.xml.wsdl.model.BindingInput;
57 import org.netbeans.modules.xml.wsdl.model.BindingOperation;
58 import org.netbeans.modules.xml.wsdl.model.BindingOutput;
59 import org.netbeans.modules.xml.wsdl.model.Fault;
60 import org.netbeans.modules.xml.wsdl.model.Input;
61 import org.netbeans.modules.xml.wsdl.model.Message;
62 import org.netbeans.modules.xml.wsdl.model.Operation;
63 import org.netbeans.modules.xml.wsdl.model.Output;
64 import org.netbeans.modules.xml.wsdl.model.Part;
65 import org.netbeans.modules.xml.wsdl.model.Port;
66 import org.netbeans.modules.xml.wsdl.model.PortType;
67 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
68 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
69 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody;
70 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPFault;
71 import org.netbeans.modules.xml.xam.Component;
72 import org.netbeans.modules.xml.xam.Nameable;
73 import org.netbeans.modules.xml.xam.Referenceable;
74 import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent;
75 import org.openide.util.lookup.Lookups;
81 public class WSDLRefactoringEngineTest extends TestCase {
83 // private WSDLRefactoringEngine engine;
84 // private ChangeExecutor exec;
86 public WSDLRefactoringEngineTest(String testName) {
90 protected void setUp() throws Exception {
91 // exec = new WSDLChangeExecutor();
92 // engine = new WSDLRefactoringEngine();
95 protected void tearDown() throws Exception {
98 public static Test suite() {
99 // TODO Fix Test - avoid dialogs
100 // TestSuite suite = new TestSuite(WSDLRefactoringEngineTest.class);
102 return new TestSuite();
105 private void createRenameRequestAndExecute(Nameable<WSDLComponent> target, WSDLModel model) throws IOException {
106 //RenameRequest rr = new RenameRequest(target, "renamed");
107 RenameRefactoring refactoring = new RenameRefactoring(Lookups.singleton(target));
108 XMLRefactoringTransaction transaction = new XMLRefactoringTransaction((Referenceable)target, refactoring);
109 refactoring.getContext().add(transaction);
110 refactoring.getContext().add(target.getName());
111 refactoring.getContext().add((Component)model.getDefinitions());
112 RefactoringSession session = RefactoringSession.create("Test rename");
113 refactoring.setNewName("renamed");
114 assertNull(refactoring.prepare(session));
115 session.doRefactoring(true);
119 public void testMessage() throws Exception {
120 WSDLModel model = Util.loadWSDLModel("resources/stockquote.wsdl");
121 Message target = (Message) Util.findByXpath(model, "/definitions/message[@name='GetLastTradePriceInput']");
122 createRenameRequestAndExecute(target, model);
124 Input fixed1 = (Input) Util.findByXpath(model, "/definitions/portType/operation/input");
125 assertEquals("tns:renamed", ((AbstractDocumentComponent)fixed1).getPeer().getAttribute("message"));
127 // BindingInput.getInput is just implicit and should not be changed
128 BindingInput bi = (BindingInput) Util.findByXpath(model, "/definitions/binding/operation/input");
129 assertNull(((AbstractDocumentComponent)bi).getPeer().getAttributeNode("name"));
132 public void testBinding() throws Exception {
133 WSDLModel model = Util.loadWSDLModel("resources/TravelReservationService.wsdl");
134 Binding target = (Binding) Util.findByXpath(model, "/definitions/binding[@name='TravelReservationSoapBinding']");
136 createRenameRequestAndExecute(target, model);
138 Port fixed1 = (Port) Util.findByXpath(model, "/definitions/service/port");
139 assertEquals("tns:renamed", ((AbstractDocumentComponent)fixed1).getPeer().getAttribute("binding"));
142 public void testFault() throws Exception {
143 WSDLModel model = Util.loadWSDLModel("resources/TravelReservationService.wsdl");
144 Fault target = (Fault) Util.findByXpath(model,
145 "/definitions/portType[@name='TravelReservationPortType']/operation/fault[@name='itineraryProblem']");
147 createRenameRequestAndExecute(target, model);
149 BindingFault fixed1 = (BindingFault) Util.findByXpath(model, "/definitions/binding/operation/fault");
150 assertEquals("renamed", ((AbstractDocumentComponent)fixed1).getPeer().getAttribute("name"));
151 SOAPFault fixed2 = (SOAPFault) Util.findByXpath(model, "/definitions/binding/operation/fault/soap:fault");
152 assertEquals("renamed", ((AbstractDocumentComponent)fixed2).getPeer().getAttribute("name"));
155 public void testOperation() throws Exception {
156 WSDLModel model = Util.loadWSDLModel("resources/TravelReservationService.wsdl");
157 WSDLRefactoringEngine engine = new WSDLRefactoringEngine();
158 Operation target = (Operation) Util.findByXpath(model,
159 "/definitions/portType[@name='TravelReservationPortType']/operation[@name='buildItinerary']");
160 createRenameRequestAndExecute(target,model);
162 BindingOperation fixed1 = (BindingOperation) Util.findByXpath(model, "/definitions/binding/operation");
163 assertEquals("renamed", ((AbstractDocumentComponent)fixed1).getPeer().getAttribute("name"));
166 public void testPart() throws Exception {
167 WSDLModel model = Util.loadWSDLModel("resources/uddi.wsdl");
168 WSDLRefactoringEngine engine = new WSDLRefactoringEngine();
169 Part target = (Part) Util.findByXpath(model,
170 "/definitions/message[@name='bindingDetail']/part[@name='body']");
171 createRenameRequestAndExecute(target, model);
173 SOAPBody fixed1 = (SOAPBody) Util.findByXpath(model, "/definitions/binding/operation[@name='find_binding']/output/soap:body");
174 assertEquals("renamed", ((AbstractDocumentComponent)fixed1).getPeer().getAttribute("parts"));
175 SOAPBody fixed2 = (SOAPBody) Util.findByXpath(model, "/definitions/binding/operation[@name='get_bindingDetail']/output/soap:body");
176 assertEquals("renamed", ((AbstractDocumentComponent)fixed2).getPeer().getAttribute("parts"));
180 public void testInput() throws Exception {
181 WSDLModel model = Util.loadWSDLModel("resources/uddi.wsdl");
182 Input target = (Input) Util.findByXpath(model,
183 "/definitions/portType/operation[@name='find_binding']/input");
184 createRenameRequestAndExecute(target, model);
186 BindingInput fixed1 = (BindingInput) Util.findByXpath(model, "/definitions/binding/operation[@name='find_binding']/input");
187 // Still have binding/input@name implicit.
188 assertNull(((AbstractDocumentComponent)fixed1).getPeer().getAttributeNode("name"));
191 public void testOutput() throws Exception {
192 WSDLModel model = Util.loadWSDLModel("resources/uddi.wsdl");
193 Output target = (Output) Util.findByXpath(model,
194 "/definitions/portType/operation[@name='find_binding']/output");
196 createRenameRequestAndExecute(target, model);
198 BindingOutput fixed1 = (BindingOutput) Util.findByXpath(model, "/definitions/binding/operation[@name='find_binding']/output");
199 // Still have binding/output@name implicit.
200 assertNull(((AbstractDocumentComponent)fixed1).getPeer().getAttributeNode("name"));
203 public void testPortType() throws Exception {
204 WSDLModel model = Util.loadWSDLModel("resources/TravelReservationService.wsdl");
205 PortType target = (PortType) Util.findByXpath(model,
206 "/definitions/portType[@name='TravelReservationPortType']");
208 createRenameRequestAndExecute(target, model);
210 Binding fixed1 = (Binding) Util.findByXpath(model, "/definitions/binding");
211 assertEquals("tns:renamed", ((AbstractDocumentComponent)fixed1).getPeer().getAttribute("type"));