Source Code Cross Referenced for SchemaComplianceAssertion.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » teststeps » assertions » 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.assertions 
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.assertions;
014:
015:        import org.apache.xmlbeans.XmlObject;
016:
017:        import com.eviware.soapui.config.RequestAssertionConfig;
018:        import com.eviware.soapui.impl.wsdl.WsdlInterface;
019:        import com.eviware.soapui.impl.wsdl.WsdlOperation;
020:        import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
021:        import com.eviware.soapui.impl.wsdl.support.assertions.Assertable;
022:        import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
023:        import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlValidator;
024:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
025:        import com.eviware.soapui.model.iface.SubmitContext;
026:        import com.eviware.soapui.support.UISupport;
027:        import com.eviware.soapui.support.xml.XmlObjectConfigurationBuilder;
028:        import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;
029:
030:        /**
031:         * Asserts that a request or response message complies with its related 
032:         * WSDL definition / XML Schema
033:         * 
034:         * @author Ole.Matzura
035:         */
036:
037:        public class SchemaComplianceAssertion extends WsdlMessageAssertion
038:                implements  RequestAssertion, ResponseAssertion {
039:            public static final String ID = "Schema Compliance";
040:            private String definition;
041:
042:            public SchemaComplianceAssertion(
043:                    RequestAssertionConfig assertionConfig,
044:                    Assertable assertable) {
045:                super (assertionConfig, assertable, false, true);
046:
047:                XmlObjectConfigurationReader reader = new XmlObjectConfigurationReader(
048:                        getConfiguration());
049:                definition = reader.readString("definition", null);
050:            }
051:
052:            protected String internalAssertResponse(
053:                    WsdlMessageExchange messageExchange, SubmitContext context)
054:                    throws AssertionException {
055:                WsdlContext wsdlContext = getWsdlContext(messageExchange);
056:                WsdlValidator validator = new WsdlValidator(wsdlContext);
057:
058:                try {
059:                    AssertionError[] errors = validator.assertResponse(
060:                            messageExchange, false);
061:                    if (errors.length > 0)
062:                        throw new AssertionException(errors);
063:                } catch (AssertionException e) {
064:                    throw e;
065:                } catch (Exception e) {
066:                    throw new AssertionException(new AssertionError(e
067:                            .getMessage()));
068:                }
069:
070:                return "Schema compliance OK";
071:            }
072:
073:            private WsdlContext getWsdlContext(
074:                    WsdlMessageExchange messageExchange) {
075:                WsdlOperation operation = messageExchange.getOperation();
076:                WsdlContext wsdlContext = null;
077:                if (definition == null
078:                        || definition.trim().length() == 0
079:                        || definition.equals(operation.getInterface()
080:                                .getDefinition())) {
081:                    wsdlContext = ((WsdlInterface) operation.getInterface())
082:                            .getWsdlContext();
083:                } else {
084:                    wsdlContext = new WsdlContext(definition,
085:                            ((WsdlInterface) operation.getInterface())
086:                                    .getSoapVersion(), null,
087:                            (WsdlInterface) operation.getInterface());
088:                }
089:                return wsdlContext;
090:            }
091:
092:            public boolean configure() {
093:                String value = definition;
094:
095:                WsdlInterface iface = getAssertable().getInterface();
096:                String orgDef = iface == null ? null : iface.getDefinition();
097:
098:                if (value == null || value.trim().length() == 0) {
099:                    value = orgDef;
100:                }
101:
102:                value = UISupport.prompt(
103:                        "Specify defintion url to validate by",
104:                        "Configure SchemaCompliance Assertion", value);
105:
106:                if (value == null)
107:                    return false;
108:
109:                if (value.trim().length() == 0 || value.equals(orgDef))
110:                    definition = "";
111:                else
112:                    definition = value;
113:
114:                setConfiguration(createConfiguration());
115:                return true;
116:            }
117:
118:            protected XmlObject createConfiguration() {
119:                XmlObjectConfigurationBuilder builder = new XmlObjectConfigurationBuilder();
120:                return builder.add("definition", definition).finish();
121:            }
122:
123:            protected String internalAssertRequest(
124:                    WsdlMessageExchange messageExchange, SubmitContext context)
125:                    throws AssertionException {
126:                WsdlContext wsdlContext = getWsdlContext(messageExchange);
127:                WsdlValidator validator = new WsdlValidator(wsdlContext);
128:
129:                try {
130:                    AssertionError[] errors = validator.assertRequest(
131:                            messageExchange, false);
132:                    if (errors.length > 0)
133:                        throw new AssertionException(errors);
134:                } catch (AssertionException e) {
135:                    throw e;
136:                } catch (Exception e) {
137:                    throw new AssertionException(new AssertionError(e
138:                            .getMessage()));
139:                }
140:
141:                return "Schema compliance OK";
142:            }
143:        }
ww___w___._j___a___v___a__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.