Source Code Cross Referenced for AddRequestToMockServiceAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » request » 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.request 
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.request;
014:
015:        import com.eviware.soapui.SoapUI;
016:        import com.eviware.soapui.impl.wsdl.WsdlProject;
017:        import com.eviware.soapui.impl.wsdl.WsdlRequest;
018:        import com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation;
019:        import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
020:        import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
021:        import com.eviware.soapui.impl.wsdl.submit.transports.http.WsdlResponse;
022:        import com.eviware.soapui.model.iface.Attachment;
023:        import com.eviware.soapui.model.support.ModelSupport;
024:        import com.eviware.soapui.support.UISupport;
025:        import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
026:
027:        /**
028:         * Adds a WsdlRequest to a WsdlMockService, will create required WsdlMockOperation if neccessary
029:         * 
030:         * @author ole.matzura
031:         */
032:
033:        public class AddRequestToMockServiceAction extends
034:                AbstractSoapUIAction<WsdlRequest> {
035:            private static final String CREATE_MOCKSUITE_OPTION = "Create new..";
036:            public static final String SOAPUI_ACTION_ID = "AddRequestToMockServiceAction";
037:
038:            public AddRequestToMockServiceAction() {
039:                super ("Add to MockService",
040:                        "Adds the current response to a MockService");
041:            }
042:
043:            public void perform(WsdlRequest request, Object param) {
044:                String title = getName();
045:
046:                if (request != null && request.getResponse() == null) {
047:                    if (!UISupport
048:                            .confirm(
049:                                    "Request is missing response, create default mock response instead?",
050:                                    title)) {
051:                        return;
052:                    }
053:                }
054:
055:                WsdlMockService mockService = null;
056:                WsdlMockOperation mockOperation = (WsdlMockOperation) param;
057:                if (mockOperation != null)
058:                    mockService = mockOperation.getMockService();
059:
060:                WsdlProject project = (WsdlProject) request.getOperation()
061:                        .getInterface().getProject();
062:
063:                while (mockService == null) {
064:                    if (project.getMockServiceCount() > 0) {
065:                        String[] mockServices = ModelSupport.getNames(project
066:                                .getMockServices(),
067:                                new String[] { CREATE_MOCKSUITE_OPTION });
068:
069:                        // prompt
070:                        String option = (String) UISupport.prompt(
071:                                "Select MockService for MockOperation", title,
072:                                mockServices);
073:                        if (option == null)
074:                            return;
075:
076:                        mockService = (WsdlMockService) project
077:                                .getMockServiceByName(option);
078:                    }
079:
080:                    // create new mocksuite?
081:                    if (mockService == null) {
082:                        String mockServiceName = UISupport.prompt(
083:                                "Enter name of new MockService", title,
084:                                "MockService "
085:                                        + (project.getMockServiceCount() + 1));
086:                        if (mockServiceName == null
087:                                || mockServiceName.trim().length() == 0)
088:                            return;
089:
090:                        mockService = (WsdlMockService) project
091:                                .addNewMockService(mockServiceName);
092:                    }
093:
094:                    mockOperation = mockService.getMockOperation(request
095:                            .getOperation());
096:                    if (mockOperation != null) {
097:                        Boolean retval = UISupport
098:                                .confirmOrCancel(
099:                                        "MockService ["
100:                                                + mockService.getName()
101:                                                + "] already has a MockOperation for ["
102:                                                + request.getOperation()
103:                                                        .getName()
104:                                                + "],\r\nShould MockResponse be added to this MockOperation instead",
105:                                        "Add Request to MockService");
106:
107:                        if (retval == null)
108:                            return;
109:
110:                        if (!retval.booleanValue())
111:                            mockService = null;
112:                    }
113:                }
114:
115:                // add mockoperation
116:                if (mockOperation == null)
117:                    mockOperation = (WsdlMockOperation) mockService
118:                            .addNewMockOperation(request.getOperation());
119:
120:                WsdlMockResponse mockResponse = mockOperation
121:                        .addNewMockResponse("Response "
122:                                + (1 + mockOperation.getMockResponseCount()),
123:                                false);
124:
125:                // add expected response if available
126:                if (request != null && request.getResponse() != null) {
127:                    WsdlResponse response = (WsdlResponse) request
128:                            .getResponse();
129:                    mockResponse.setResponseContent(response
130:                            .getContentAsString());
131:
132:                    Attachment[] attachments = response.getAttachments();
133:                    for (Attachment attachment : attachments) {
134:                        mockResponse.addAttachment(attachment);
135:                    }
136:
137:                    if (mockResponse.getResponseHeaders() != null
138:                            && mockResponse.getResponseHeaders().size() > 0
139:                            && UISupport
140:                                    .confirm(
141:                                            "Add current Response HTTP Headers to MockResponse",
142:                                            title))
143:                        mockResponse.setResponseHeaders(response
144:                                .getResponseHeaders());
145:                } else {
146:                    mockResponse.setResponseContent(request.getOperation()
147:                            .createResponse(true));
148:                }
149:
150:                if (UISupport.confirm("Open MockResponse editor?", title)) {
151:                    SoapUI.getDesktop().showDesktopPanel(mockResponse);
152:                }
153:            }
154:        }
w_ww__.__j__av___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.