Source Code Cross Referenced for WsdlTestRequestStepFactory.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » teststeps » registry » 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.teststeps.registry 
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.teststeps.registry;
014:
015:        import java.util.ArrayList;
016:        import java.util.List;
017:
018:        import com.eviware.soapui.SoapUI;
019:        import com.eviware.soapui.config.CallConfig;
020:        import com.eviware.soapui.config.CredentialsConfig;
021:        import com.eviware.soapui.config.RequestAssertionConfig;
022:        import com.eviware.soapui.config.RequestStepConfig;
023:        import com.eviware.soapui.config.TestStepConfig;
024:        import com.eviware.soapui.impl.wsdl.WsdlOperation;
025:        import com.eviware.soapui.impl.wsdl.WsdlRequest;
026:        import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
027:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep;
028:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
029:        import com.eviware.soapui.impl.wsdl.teststeps.assertions.NotSoapFaultAssertion;
030:        import com.eviware.soapui.impl.wsdl.teststeps.assertions.SchemaComplianceAssertion;
031:        import com.eviware.soapui.impl.wsdl.teststeps.assertions.SoapResponseAssertion;
032:        import com.eviware.soapui.model.iface.Interface;
033:        import com.eviware.soapui.model.iface.Operation;
034:        import com.eviware.soapui.model.project.Project;
035:        import com.eviware.soapui.settings.WsdlSettings;
036:        import com.eviware.soapui.support.UISupport;
037:        import com.eviware.soapui.support.types.StringToStringMap;
038:        import com.eviware.x.form.XForm;
039:        import com.eviware.x.form.XFormDialog;
040:        import com.eviware.x.form.XFormDialogBuilder;
041:        import com.eviware.x.form.XFormFactory;
042:
043:        /**
044:         * Factory for WsdlTestRequestSteps
045:         * 
046:         * @author Ole.Matzura
047:         */
048:
049:        public class WsdlTestRequestStepFactory extends WsdlTestStepFactory {
050:            public static final String REQUEST_TYPE = "request";
051:            private static final String CREATE_OPTIONAL_ELEMENTS_IN_REQUEST = "Create optional elements";
052:            private static final String ADD_SOAP_RESPONSE_ASSERTION = "Add SOAP Response Assertion";
053:            private static final String ADD_SOAP_FAULT_ASSERTION = "Add Not SOAP Fault Assertion";
054:            private static final String ADD_SCHEMA_ASSERTION = "Add Schema Assertion";
055:            private static final String STEP_NAME = "Name";
056:            private XFormDialog dialog;
057:            private StringToStringMap dialogValues = new StringToStringMap();
058:
059:            public WsdlTestRequestStepFactory() {
060:                super (REQUEST_TYPE, "Test Request",
061:                        "Submits a request and validates its response",
062:                        "/request.gif");
063:            }
064:
065:            public WsdlTestStep buildTestStep(WsdlTestCase testCase,
066:                    TestStepConfig config, boolean forLoadTest) {
067:                return new WsdlTestRequestStep(testCase, config, forLoadTest);
068:            }
069:
070:            public static TestStepConfig createConfig(WsdlRequest request,
071:                    String stepName) {
072:                RequestStepConfig requestStepConfig = RequestStepConfig.Factory
073:                        .newInstance();
074:
075:                requestStepConfig.setInterface(request.getOperation()
076:                        .getInterface().getName());
077:                requestStepConfig
078:                        .setOperation(request.getOperation().getName());
079:
080:                CallConfig testRequestConfig = requestStepConfig
081:                        .addNewRequest();
082:
083:                testRequestConfig.setName(stepName);
084:                testRequestConfig.setEncoding(request.getEncoding());
085:                testRequestConfig.setEndpoint(request.getEndpoint());
086:                testRequestConfig.addNewRequest().setStringValue(
087:                        request.getRequestContent());
088:
089:                if ((CredentialsConfig) request.getConfig().getCredentials() != null) {
090:                    testRequestConfig
091:                            .setCredentials((CredentialsConfig) request
092:                                    .getConfig().getCredentials().copy());
093:                }
094:
095:                testRequestConfig.setWssPasswordType(request.getConfig()
096:                        .getWssPasswordType());
097:                //testRequestConfig.setSettings( request.getConfig().getSettings() );
098:
099:                TestStepConfig testStep = TestStepConfig.Factory.newInstance();
100:                testStep.setType(REQUEST_TYPE);
101:                testStep.setConfig(requestStepConfig);
102:
103:                return testStep;
104:            }
105:
106:            public static TestStepConfig createConfig(WsdlOperation operation,
107:                    String stepName) {
108:                RequestStepConfig requestStepConfig = RequestStepConfig.Factory
109:                        .newInstance();
110:
111:                requestStepConfig.setInterface(operation.getInterface()
112:                        .getName());
113:                requestStepConfig.setOperation(operation.getName());
114:
115:                CallConfig testRequestConfig = requestStepConfig
116:                        .addNewRequest();
117:
118:                testRequestConfig.setName(stepName);
119:                testRequestConfig.setEncoding("UTF-8");
120:                String[] endpoints = operation.getInterface().getEndpoints();
121:                if (endpoints.length > 0)
122:                    testRequestConfig.setEndpoint(endpoints[0]);
123:
124:                String requestContent = operation
125:                        .createRequest(SoapUI
126:                                .getSettings()
127:                                .getBoolean(
128:                                        WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS));
129:                testRequestConfig.addNewRequest()
130:                        .setStringValue(requestContent);
131:
132:                TestStepConfig testStep = TestStepConfig.Factory.newInstance();
133:                testStep.setType(REQUEST_TYPE);
134:                testStep.setConfig(requestStepConfig);
135:
136:                return testStep;
137:            }
138:
139:            public TestStepConfig createNewTestStep(WsdlTestCase testCase,
140:                    String name) {
141:                // build list of available interfaces / operations
142:                Project project = testCase.getTestSuite().getProject();
143:                List<String> options = new ArrayList<String>();
144:                List<Operation> operations = new ArrayList<Operation>();
145:
146:                for (int c = 0; c < project.getInterfaceCount(); c++) {
147:                    Interface iface = project.getInterfaceAt(c);
148:                    for (int i = 0; i < iface.getOperationCount(); i++) {
149:                        options.add(iface.getName() + " -> "
150:                                + iface.getOperationAt(i).getName());
151:                        operations.add(iface.getOperationAt(i));
152:                    }
153:                }
154:
155:                Object op = UISupport.prompt(
156:                        "Select operation to invoke for request",
157:                        "New TestRequest", options.toArray());
158:                if (op != null) {
159:                    int ix = options.indexOf(op);
160:                    if (ix != -1) {
161:                        WsdlOperation operation = (WsdlOperation) operations
162:                                .get(ix);
163:
164:                        if (dialog == null)
165:                            buildDialog();
166:
167:                        dialogValues.put(STEP_NAME, name);
168:                        dialogValues = dialog.show(dialogValues);
169:                        if (dialog.getReturnValue() != XFormDialog.OK_OPTION)
170:                            return null;
171:
172:                        name = dialogValues.get(STEP_NAME);
173:
174:                        String requestContent = operation
175:                                .createRequest(dialogValues
176:                                        .getBoolean(CREATE_OPTIONAL_ELEMENTS_IN_REQUEST));
177:
178:                        RequestStepConfig requestStepConfig = RequestStepConfig.Factory
179:                                .newInstance();
180:
181:                        requestStepConfig.setInterface(operation.getInterface()
182:                                .getName());
183:                        requestStepConfig.setOperation(operation.getName());
184:
185:                        CallConfig testRequestConfig = requestStepConfig
186:                                .addNewRequest();
187:
188:                        testRequestConfig.setName(name);
189:                        testRequestConfig.setEncoding("UTF-8");
190:                        String[] endpoints = operation.getInterface()
191:                                .getEndpoints();
192:                        if (endpoints.length > 0)
193:                            testRequestConfig.setEndpoint(endpoints[0]);
194:                        testRequestConfig.addNewRequest().setStringValue(
195:                                requestContent);
196:
197:                        if (dialogValues
198:                                .getBoolean(ADD_SOAP_RESPONSE_ASSERTION)) {
199:                            RequestAssertionConfig assertionConfig = testRequestConfig
200:                                    .addNewAssertion();
201:                            assertionConfig.setType(SoapResponseAssertion.ID);
202:                        }
203:
204:                        if (dialogValues.getBoolean(ADD_SCHEMA_ASSERTION)) {
205:                            RequestAssertionConfig assertionConfig = testRequestConfig
206:                                    .addNewAssertion();
207:                            assertionConfig
208:                                    .setType(SchemaComplianceAssertion.ID);
209:                        }
210:
211:                        if (dialogValues.getBoolean(ADD_SOAP_FAULT_ASSERTION)) {
212:                            RequestAssertionConfig assertionConfig = testRequestConfig
213:                                    .addNewAssertion();
214:                            assertionConfig.setType(NotSoapFaultAssertion.ID);
215:                        }
216:
217:                        TestStepConfig testStep = TestStepConfig.Factory
218:                                .newInstance();
219:                        testStep.setType(REQUEST_TYPE);
220:                        testStep.setConfig(requestStepConfig);
221:                        testStep.setName(name);
222:
223:                        return testStep;
224:                    }
225:                }
226:
227:                return null;
228:            }
229:
230:            public boolean canCreate() {
231:                return true;
232:            }
233:
234:            private void buildDialog() {
235:                XFormDialogBuilder builder = XFormFactory
236:                        .createDialogBuilder("Add Request to TestCase");
237:                XForm mainForm = builder.createForm("Basic");
238:
239:                mainForm.addTextField(STEP_NAME, "Name of TestStep",
240:                        XForm.FieldType.URL).setWidth(30);
241:
242:                mainForm.addCheckBox(ADD_SOAP_RESPONSE_ASSERTION,
243:                        "(adds validation that response is a SOAP message)");
244:                mainForm
245:                        .addCheckBox(ADD_SCHEMA_ASSERTION,
246:                                "(adds validation that response complies with its schema)");
247:                mainForm.addCheckBox(ADD_SOAP_FAULT_ASSERTION,
248:                        "(adds validation that response is not a SOAP Fault)");
249:                mainForm.addCheckBox(CREATE_OPTIONAL_ELEMENTS_IN_REQUEST,
250:                        "(creates optional content i sample request)");
251:
252:                dialog = builder
253:                        .buildDialog(
254:                                builder.buildOkCancelActions(),
255:                                "Specify options for adding a new request to a TestCase",
256:                                UISupport.OPTIONS_ICON);
257:
258:                dialogValues.put(ADD_SOAP_RESPONSE_ASSERTION, Boolean.TRUE
259:                        .toString());
260:            }
261:        }
w__w___w_.j___ava___2__s_.___c__o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.