Source Code Cross Referenced for CloneTestCaseAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » testcase » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl.actions.testcase 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl.actions.testcase;
014:
015:        import java.util.HashMap;
016:        import java.util.HashSet;
017:        import java.util.Map;
018:        import java.util.Set;
019:
020:        import javax.xml.namespace.QName;
021:
022:        import com.eviware.soapui.SoapUI;
023:        import com.eviware.soapui.impl.WorkspaceImpl;
024:        import com.eviware.soapui.impl.wsdl.WsdlInterface;
025:        import com.eviware.soapui.impl.wsdl.WsdlProject;
026:        import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
027:        import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
028:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
029:        import com.eviware.soapui.model.iface.Interface;
030:        import com.eviware.soapui.model.project.Project;
031:        import com.eviware.soapui.model.support.ModelSupport;
032:        import com.eviware.soapui.support.SoapUIException;
033:        import com.eviware.soapui.support.UISupport;
034:        import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
035:        import com.eviware.x.form.XFormDialog;
036:        import com.eviware.x.form.XFormField;
037:        import com.eviware.x.form.XFormFieldListener;
038:        import com.eviware.x.form.support.ADialogBuilder;
039:        import com.eviware.x.form.support.AField;
040:        import com.eviware.x.form.support.AForm;
041:        import com.eviware.x.form.support.AField.AFieldType;
042:
043:        /**
044:         * Clones a WsdlTestSuite
045:         * 
046:         * @author Ole.Matzura
047:         */
048:
049:        public class CloneTestCaseAction extends
050:                AbstractSoapUIAction<WsdlTestCase> {
051:            private static final String CREATE_NEW_OPTION = "<Create New>";
052:            private XFormDialog dialog;
053:
054:            public CloneTestCaseAction() {
055:                super ("Clone TestCase", "Clones this TestCase");
056:            }
057:
058:            public void perform(WsdlTestCase testCase, Object param) {
059:                if (dialog == null) {
060:                    dialog = ADialogBuilder.buildDialog(Form.class);
061:                    dialog.getFormField(Form.PROJECT).addFormFieldListener(
062:                            new XFormFieldListener() {
063:
064:                                public void valueChanged(
065:                                        XFormField sourceField,
066:                                        String newValue, String oldValue) {
067:                                    if (newValue.equals(CREATE_NEW_OPTION))
068:                                        dialog
069:                                                .setOptions(
070:                                                        Form.TESTSUITE,
071:                                                        new String[] { CREATE_NEW_OPTION });
072:                                    else {
073:                                        Project project = SoapUI.getWorkspace()
074:                                                .getProjectByName(newValue);
075:                                        dialog
076:                                                .setOptions(
077:                                                        Form.TESTSUITE,
078:                                                        ModelSupport
079:                                                                .getNames(
080:                                                                        project
081:                                                                                .getTestSuites(),
082:                                                                        new String[] { CREATE_NEW_OPTION }));
083:                                    }
084:                                }
085:                            });
086:                }
087:
088:                dialog.setValue(Form.NAME, "Copy of " + testCase.getName());
089:                WorkspaceImpl workspace = testCase.getTestSuite().getProject()
090:                        .getWorkspace();
091:                dialog.setOptions(Form.PROJECT, ModelSupport.getNames(workspace
092:                        .getProjectList(), new String[] { CREATE_NEW_OPTION }));
093:
094:                dialog.setValue(Form.PROJECT, testCase.getTestSuite()
095:                        .getProject().getName());
096:
097:                dialog.setOptions(Form.TESTSUITE, ModelSupport.getNames(
098:                        testCase.getTestSuite().getProject().getTestSuites(),
099:                        new String[] { CREATE_NEW_OPTION }));
100:
101:                dialog.setValue(Form.TESTSUITE, testCase.getTestSuite()
102:                        .getName());
103:                boolean hasLoadTests = testCase.getLoadTestCount() > 0;
104:                dialog.setBooleanValue(Form.CLONE_LOADTESTS, hasLoadTests);
105:                dialog.getFormField(Form.CLONE_LOADTESTS).setEnabled(
106:                        hasLoadTests);
107:
108:                if (dialog.show()) {
109:                    String targetProjectName = dialog.getValue(Form.PROJECT);
110:                    String targetTestSuiteName = dialog
111:                            .getValue(Form.TESTSUITE);
112:                    String name = dialog.getValue(Form.NAME);
113:
114:                    WsdlProject project = testCase.getTestSuite().getProject();
115:                    WsdlTestSuite targetTestSuite = null;
116:                    Set<WsdlInterface> requiredInterfaces = new HashSet<WsdlInterface>();
117:
118:                    // to another project project?
119:                    if (!targetProjectName.equals(project.getName())) {
120:                        // get required interfaces
121:                        for (int y = 0; y < testCase.getTestStepCount(); y++) {
122:                            WsdlTestStep testStep = testCase.getTestStepAt(y);
123:                            requiredInterfaces.addAll(testStep
124:                                    .getRequiredInterfaces());
125:                        }
126:
127:                        project = (WsdlProject) workspace
128:                                .getProjectByName(targetProjectName);
129:                        if (project == null) {
130:                            targetProjectName = UISupport.prompt(
131:                                    "Enter name for new Project",
132:                                    "Clone TestCase", "");
133:                            if (targetProjectName == null)
134:                                return;
135:
136:                            try {
137:                                project = workspace
138:                                        .createProject(targetProjectName);
139:                            } catch (SoapUIException e) {
140:                                UISupport.showErrorMessage(e);
141:                            }
142:
143:                            if (project == null)
144:                                return;
145:                        }
146:
147:                        if (requiredInterfaces.size() > 0
148:                                && project.getInterfaceCount() > 0) {
149:                            Map<QName, WsdlInterface> bindings = new HashMap<QName, WsdlInterface>();
150:                            for (WsdlInterface iface : requiredInterfaces) {
151:                                bindings.put(iface.getBindingName(), iface);
152:                            }
153:
154:                            for (Interface iface : project.getInterfaces()) {
155:                                bindings.remove(iface.getBindingName());
156:                            }
157:
158:                            requiredInterfaces.retainAll(bindings.values());
159:                        }
160:
161:                        if (requiredInterfaces.size() > 0) {
162:                            String msg = "Target project ["
163:                                    + targetProjectName
164:                                    + "] is missing required interfaces;\r\n\r\n";
165:                            for (WsdlInterface iface : requiredInterfaces) {
166:                                msg += iface.getName() + " ["
167:                                        + iface.getBindingName() + "]\r\n";
168:                            }
169:                            msg += "\r\nThese will be cloned to the targetProject as well";
170:
171:                            if (!UISupport.confirm(msg, "Clone TestCase"))
172:                                return;
173:
174:                            for (WsdlInterface iface : requiredInterfaces) {
175:                                project.importInterface(iface);
176:                            }
177:                        }
178:                    }
179:
180:                    targetTestSuite = project
181:                            .getTestSuiteByName(targetTestSuiteName);
182:                    if (targetTestSuite == null) {
183:                        targetTestSuiteName = UISupport.prompt(
184:                                "Specify name for new TestSuite",
185:                                "Clone TestCase", "Copy of "
186:                                        + testCase.getTestSuite().getName());
187:                        if (targetTestSuiteName == null)
188:                            return;
189:
190:                        targetTestSuite = project
191:                                .addNewTestSuite(targetTestSuiteName);
192:                    }
193:
194:                    WsdlTestCase newTestCase = targetTestSuite.importTestCase(
195:                            testCase, name, -1, dialog
196:                                    .getBooleanValue(Form.CLONE_LOADTESTS));
197:                    UISupport.select(newTestCase);
198:
199:                    if (dialog.getBooleanValue(Form.MOVE)) {
200:                        testCase.getTestSuite().removeTestCase(testCase);
201:                    }
202:                }
203:            }
204:
205:            @AForm(description="Specify target Project/TestSuite and name of cloned TestCase",name="Clone TestCase")
206:            protected interface Form {
207:                @AField(name="TestCase Name",description="The name of the cloned TestCase",type=AFieldType.STRING)
208:                public final static String NAME = "TestCase Name";
209:
210:                @AField(name="Target TestSuite",description="The target TestSuite for the cloned TestCase",type=AFieldType.ENUMERATION)
211:                public final static String TESTSUITE = "Target TestSuite";
212:
213:                @AField(name="Target Project",description="The target Project for the cloned TestCase",type=AFieldType.ENUMERATION)
214:                public final static String PROJECT = "Target Project";
215:
216:                @AField(name="Clone LoadTests",description="Clone contained LoadTests",type=AFieldType.BOOLEAN)
217:                public final static String CLONE_LOADTESTS = "Clone LoadTests";
218:
219:                @AField(name="Move instead",description="Moves the selected TestCase instead of copying",type=AFieldType.BOOLEAN)
220:                public final static String MOVE = "Move instead";
221:            }
222:        }
w___w__w_.j___a__v__a___2_s__._c___om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.