Source Code Cross Referenced for WSIAnalyzeAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » iface » tools » wsi » 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.iface.tools.wsi 
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.iface.tools.wsi;
014:
015:        import java.awt.Dimension;
016:        import java.io.File;
017:        import java.io.FileWriter;
018:        import java.io.IOException;
019:
020:        import javax.swing.SwingUtilities;
021:        import javax.xml.transform.Source;
022:        import javax.xml.transform.Transformer;
023:        import javax.xml.transform.TransformerFactory;
024:        import javax.xml.transform.stream.StreamResult;
025:        import javax.xml.transform.stream.StreamSource;
026:
027:        import org.apache.log4j.Logger;
028:        import org.wsI.testing.x2003.x03.common.AddStyleSheet;
029:        import org.wsI.testing.x2004.x07.analyzerConfig.AssertionResults;
030:        import org.wsI.testing.x2004.x07.analyzerConfig.Configuration;
031:        import org.wsI.testing.x2004.x07.analyzerConfig.ConfigurationDocument;
032:        import org.wsI.testing.x2004.x07.analyzerConfig.ReportFile;
033:        import org.wsI.testing.x2004.x07.analyzerConfig.WsdlElementReference;
034:        import org.wsI.testing.x2004.x07.analyzerConfig.WsdlElementType;
035:        import org.wsI.testing.x2004.x07.analyzerConfig.WsdlReference;
036:
037:        import com.eviware.soapui.SoapUI;
038:        import com.eviware.soapui.actions.SoapUIPreferencesAction;
039:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.AbstractToolsAction;
040:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ArgumentBuilder;
041:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ProcessToolRunner;
042:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.RunnerContext;
043:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ToolHost;
044:        import com.eviware.soapui.model.iface.Interface;
045:        import com.eviware.soapui.model.settings.Settings;
046:        import com.eviware.soapui.settings.WSISettings;
047:        import com.eviware.soapui.support.Tools;
048:        import com.eviware.soapui.support.UISupport;
049:        import com.eviware.soapui.support.types.StringToStringMap;
050:        import com.eviware.soapui.ui.support.DefaultDesktopPanel;
051:
052:        /**
053:         * Invokes WS-I Analyzer Tool
054:         * 
055:         * @author Ole.Matzura
056:         */
057:
058:        public class WSIAnalyzeAction extends AbstractToolsAction<Interface> {
059:            public final static String SOAPUI_ACTION_ID = "WSIAnalyzeAction";
060:            public final static Logger log = Logger
061:                    .getLogger(WSIAnalyzeAction.class);
062:
063:            private String configFile;
064:
065:            public WSIAnalyzeAction() {
066:                super ("Check WSI Compliance",
067:                        "Validate this WSDL for WSI Basic Profile compliance");
068:            }
069:
070:            protected void generate(StringToStringMap values,
071:                    ToolHost toolHost, Interface modelItem) throws Exception {
072:                String wsiDir = SoapUI.getSettings().getString(
073:                        WSISettings.WSI_LOCATION, null);
074:                if (Tools.isEmpty(wsiDir)) {
075:                    UISupport
076:                            .showErrorMessage("WSI Test Tools directory must be set in global preferences");
077:
078:                    if (UISupport.getMainFrame() != null) {
079:                        if (SoapUIPreferencesAction.getInstance().show(
080:                                SoapUIPreferencesAction.WS_I_SETTINGS)) {
081:                            wsiDir = SoapUI.getSettings().getString(
082:                                    WSISettings.WSI_LOCATION, null);
083:                        }
084:                    }
085:                }
086:
087:                if (Tools.isEmpty(wsiDir))
088:                    return;
089:
090:                ProcessBuilder builder = new ProcessBuilder();
091:
092:                File reportFile = File.createTempFile("wsi-report", ".xml");
093:
094:                ArgumentBuilder args = buildArgs(reportFile, modelItem);
095:                builder.command(args.getArgs());
096:                File wsiToolDir = new File(wsiDir + File.separatorChar + "cs"
097:                        + File.separatorChar + "bin");
098:                if (!wsiToolDir.exists())
099:                    wsiToolDir = new File(wsiDir + File.separatorChar + "java"
100:                            + File.separatorChar + "bin");
101:
102:                builder.directory(wsiToolDir);
103:
104:                toolHost.run(new WSIProcessToolRunner(builder, reportFile,
105:                        modelItem));
106:            }
107:
108:            private ArgumentBuilder buildArgs(File reportFile,
109:                    Interface modelItem) throws IOException {
110:                Settings settings = modelItem.getSettings();
111:
112:                ConfigurationDocument configDoc = createConfigFile(reportFile,
113:                        settings, modelItem);
114:                configFile = configDoc.toString();
115:
116:                File file = File.createTempFile("wsi-analyzer-config", ".xml");
117:
118:                configDoc.save(file);
119:
120:                ArgumentBuilder builder = new ArgumentBuilder(
121:                        new StringToStringMap());
122:                builder.startScript("Analyzer", "", ".sh");
123:
124:                builder.addArgs("-config", file.getAbsolutePath());
125:
126:                // add this to command-line due to bug in wsi-tools (?)
127:                if (settings.getBoolean(WSISettings.ASSERTION_DESCRIPTION))
128:                    builder.addArgs("-assertionDescription", "true");
129:
130:                return builder;
131:            }
132:
133:            private ConfigurationDocument createConfigFile(File reportFile,
134:                    Settings settings, Interface modelItem) {
135:                ConfigurationDocument configDoc = ConfigurationDocument.Factory
136:                        .newInstance();
137:                Configuration config = configDoc.addNewConfiguration();
138:
139:                config.setVerbose(settings.getBoolean(WSISettings.VERBOSE));
140:                AssertionResults results = config.addNewAssertionResults();
141:                results.setType(AssertionResults.Type.Enum.forString(settings
142:                        .getString(WSISettings.RESULTS_TYPE,
143:                                AssertionResults.Type.ONLY_FAILED.toString())));
144:
145:                results.setMessageEntry(settings
146:                        .getBoolean(WSISettings.MESSAGE_ENTRY));
147:                results.setFailureMessage(settings
148:                        .getBoolean(WSISettings.FAILURE_MESSAGE));
149:                results.setAssertionDescription(settings
150:                        .getBoolean(WSISettings.ASSERTION_DESCRIPTION));
151:
152:                ReportFile report = config.addNewReportFile();
153:                report.setLocation(reportFile.getAbsolutePath());
154:                report.setReplace(true);
155:                AddStyleSheet stylesheet = report.addNewAddStyleSheet();
156:                stylesheet
157:                        .setHref(".\\..\\common\\Profiles\\SSBP10_BP11_TAD.xml");
158:                stylesheet.setType("text/xsl");
159:                stylesheet.setAlternate(false);
160:
161:                config
162:                        .setTestAssertionsFile("../../common/profiles/SSBP10_BP11_TAD.xml");
163:
164:                WsdlReference wsdlRef = config.addNewWsdlReference();
165:
166:                StringToStringMap values = new StringToStringMap();
167:                values.put(WSDL, modelItem.getDefinition());
168:                values.put(CACHED_WSDL, Boolean.toString(modelItem.isCached()));
169:
170:                wsdlRef.setWsdlURI(getWsdlUrl(values, modelItem));
171:                WsdlElementReference wsdlElement = wsdlRef.addNewWsdlElement();
172:                wsdlElement.setType(WsdlElementType.BINDING);
173:                wsdlElement.setStringValue(modelItem.getBindingName()
174:                        .getLocalPart());
175:                wsdlElement.setNamespace(modelItem.getBindingName()
176:                        .getNamespaceURI());
177:                return configDoc;
178:            }
179:
180:            public static File transformReport(File reportFile)
181:                    throws Exception {
182:                String dir = SoapUI.getSettings().getString(
183:                        WSISettings.WSI_LOCATION, null);
184:                File xsltFile = new File(dir + File.separatorChar + "common"
185:                        + File.separatorChar + "xsl" + File.separatorChar
186:                        + "report.xsl");
187:
188:                Source xmlSource = new StreamSource(reportFile);
189:                Source xsltSource = new StreamSource(xsltFile);
190:
191:                TransformerFactory transFact = TransformerFactory.newInstance();
192:                Transformer trans = transFact.newTransformer(xsltSource);
193:
194:                String outputFolder = SoapUI.getSettings().getString(
195:                        WSISettings.OUTPUT_FOLDER, null);
196:                File output = outputFolder == null
197:                        || outputFolder.trim().length() == 0 ? null : new File(
198:                        outputFolder);
199:
200:                File tempFile = File.createTempFile("wsi-report", ".html",
201:                        output);
202:                trans.transform(xmlSource, new StreamResult(new FileWriter(
203:                        tempFile)));
204:
205:                log.info("WSI Report created at [" + tempFile.getAbsolutePath()
206:                        + "]");
207:
208:                return tempFile;
209:            }
210:
211:            private class WSIProcessToolRunner extends ProcessToolRunner {
212:                private File reportFile;
213:                private final Interface modelItem;
214:
215:                public WSIProcessToolRunner(ProcessBuilder builder,
216:                        File reportFile, Interface modelItem) {
217:                    super (builder, "WSI Analyzer", modelItem);
218:                    this .reportFile = reportFile;
219:                    this .modelItem = modelItem;
220:                }
221:
222:                public String getDescription() {
223:                    return "Running WSI Analysis tools..";
224:                }
225:
226:                protected void afterRun(int exitCode, RunnerContext context) {
227:                    if (exitCode == 0
228:                            && context.getStatus() == RunnerContext.RunnerStatus.FINISHED) {
229:                        try {
230:                            reportFile = transformReport(reportFile);
231:                        } catch (Exception e1) {
232:                            SoapUI.logError(e1);
233:                        }
234:
235:                        SwingUtilities.invokeLater(new Runnable() {
236:                            public void run() {
237:                                try {
238:                                    WSIReportPanel panel = new WSIReportPanel(
239:                                            reportFile, configFile, null);
240:                                    panel.setPreferredSize(new Dimension(600,
241:                                            400));
242:
243:                                    UISupport
244:                                            .showDesktopPanel(new DefaultDesktopPanel(
245:                                                    "WS-I Report",
246:                                                    "WS-I Report for Interface ["
247:                                                            + modelItem
248:                                                                    .getName()
249:                                                            + "]", panel));
250:                                } catch (Exception e) {
251:                                    UISupport.showErrorMessage(e);
252:                                }
253:                            }
254:                        });
255:                    }
256:
257:                    closeDialog(modelItem);
258:                }
259:
260:                public boolean showLog() {
261:                    return modelItem.getSettings().getBoolean(
262:                            WSISettings.SHOW_LOG);
263:                }
264:            }
265:        }
ww_w.j__a_v___a_2__s_._co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.