Source Code Cross Referenced for WSDLValidationTest.java in  » Web-Services-apache-cxf-2.0.1 » tools-validator » org » apache » cxf » tools » validator » 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 apache cxf 2.0.1 » tools validator » org.apache.cxf.tools.validator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.tools.validator;
019:
020:        import java.io.File;
021:        import java.net.URL;
022:        import java.util.Enumeration;
023:
024:        import org.apache.cxf.tools.common.ToolTestBase;
025:        import org.junit.Before;
026:        import org.junit.Test;
027:
028:        public class WSDLValidationTest extends ToolTestBase {
029:            @Before
030:            public void setUp() {
031:                super .setUp();
032:            }
033:
034:            @Test
035:            public void testValidateUniqueBody() {
036:                try {
037:
038:                    String[] args = new String[] { "-verbose",
039:                            getLocation("/validator_wsdl/doc_lit_bare.wsdl") };
040:                    WSDLValidator.main(args);
041:                    assertTrue(
042:                            "Non Unique Body Parts Error should be discovered: "
043:                                    + getStdErr(), getStdErr().indexOf(
044:                                    "Non unique body part") > -1);
045:                } catch (Exception e) {
046:                    e.printStackTrace();
047:                }
048:            }
049:
050:            @Test
051:            public void testValidateMixedStyle() {
052:                try {
053:
054:                    String[] args = new String[] {
055:                            "-verbose",
056:                            getLocation("/validator_wsdl/hello_world_mixed_style.wsdl") };
057:                    WSDLValidator.main(args);
058:                    assertTrue(
059:                            "Mixed style. Error should have been discovered: "
060:                                    + getStdErr(), getStdErr().indexOf(
061:                                    "Mixed style, invalid WSDL") > -1);
062:
063:                } catch (Exception e) {
064:                    e.printStackTrace();
065:                }
066:            }
067:
068:            @Test
069:            public void testValidateTypeElement() {
070:                try {
071:
072:                    String[] args = new String[] {
073:                            "-verbose",
074:                            getLocation("/validator_wsdl/hello_world_doc_lit_type.wsdl") };
075:                    WSDLValidator.main(args);
076:                    assertTrue(
077:                            "Must refer to type element error should have been discovered: "
078:                                    + getStdErr(), getStdErr().indexOf(
079:                                    "using the element attribute") > -1);
080:                } catch (Exception e) {
081:                    e.printStackTrace();
082:                }
083:            }
084:
085:            @Test
086:            public void testValidateAttribute() {
087:                try {
088:
089:                    String[] args = new String[] {
090:                            "-verbose",
091:                            getLocation("/validator_wsdl/hello_world_error_attribute.wsdl") };
092:                    WSDLValidator.main(args);
093:                    String expected = "WSDLException (at /wsdl:definitions/wsdl:message[1]/wsdl:part): "
094:                            + "faultCode=INVALID_WSDL: Encountered illegal extension attribute 'test'. "
095:                            + "Extension attributes must be in a namespace other than WSDL's";
096:                    assertTrue("Attribute error should be discovered: "
097:                            + getStdErr(), getStdErr().indexOf(expected) > -1);
098:
099:                } catch (Exception e) {
100:                    e.printStackTrace();
101:                }
102:            }
103:
104:            @Test
105:            public void testValidateReferenceError() throws Exception {
106:
107:                try {
108:
109:                    String[] args = new String[] {
110:                            "-verbose",
111:                            getLocation("/validator_wsdl/hello_world_error_reference.wsdl") };
112:                    WSDLValidator.main(args);
113:                    assertTrue(getStdErr().indexOf("[147,3]") != -1);
114:                    assertTrue(getStdErr()
115:                            .indexOf(
116:                                    "Caused by {http://apache.org/hello_world_soap_http}"
117:                                            + "[binding:Greeter_SOAPBinding1] not exist.") != -1);
118:                } catch (Exception e) {
119:                    e.printStackTrace();
120:                }
121:            }
122:
123:            @Test
124:            public void testBug305872() throws Exception {
125:                try {
126:                    String[] args = new String[] { "-verbose",
127:                            getLocation("/validator_wsdl/bug305872/http.xsd") };
128:                    WSDLValidator.main(args);
129:                    String expected = "Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.";
130:                    assertTrue(
131:                            "Tools should check if this file is a wsdl file: "
132:                                    + getStdErr(), getStdErr()
133:                                    .indexOf(expected) > -1);
134:                } catch (Exception e) {
135:                    e.printStackTrace();
136:                }
137:
138:            }
139:
140:            @Test
141:            public void testImportWsdlValidation() throws Exception {
142:                try {
143:                    String[] args = new String[] {
144:                            "-verbose",
145:                            getLocation("/validator_wsdl/hello_world_import.wsdl") };
146:                    WSDLValidator.main(args);
147:
148:                    assertTrue("Is not valid wsdl!: " + getStdOut(),
149:                            getStdOut().indexOf("Passed Validation") > -1);
150:                } catch (Exception e) {
151:                    e.printStackTrace();
152:                }
153:
154:            }
155:
156:            @Test
157:            public void testImportSchemaValidation() throws Exception {
158:                try {
159:                    String[] args = new String[] {
160:                            "-verbose",
161:                            getLocation("/validator_wsdl/hello_world_schema_import.wsdl") };
162:                    WSDLValidator.main(args);
163:
164:                    assertTrue("Is not valid wsdl: " + getStdOut(), getStdOut()
165:                            .indexOf("Passed Validation") > -1);
166:                } catch (Exception e) {
167:                    e.printStackTrace();
168:                }
169:
170:            }
171:
172:            @Test
173:            public void testWSIBP2210() throws Exception {
174:                try {
175:                    String[] args = new String[] { "-verbose",
176:                            getLocation("/validator_wsdl/soapheader.wsdl") };
177:                    WSDLValidator.main(args);
178:                    assertTrue(getStdErr().indexOf("WSI-BP-1.0 R2210") > -1);
179:                } catch (Exception e) {
180:                    e.printStackTrace();
181:                }
182:            }
183:
184:            @Test
185:            public void testWSIBPR2726() throws Exception {
186:                try {
187:                    String[] args = new String[] { "-verbose",
188:                            getLocation("/validator_wsdl/jms_test.wsdl") };
189:                    WSDLValidator.main(args);
190:                    assertTrue(getStdErr().indexOf("WSI-BP-1.0 R2726") > -1);
191:                } catch (Exception e) {
192:                    e.printStackTrace();
193:                }
194:            }
195:
196:            @Test
197:            public void testWSIBPR2205() throws Exception {
198:                try {
199:                    String[] args = new String[] { "-verbose",
200:                            getLocation("/validator_wsdl/jms_test2.wsdl") };
201:                    WSDLValidator.main(args);
202:                    assertTrue(getStdErr().indexOf("WSI-BP-1.0 R2205") > -1);
203:                } catch (Exception e) {
204:                    e.printStackTrace();
205:                }
206:            }
207:
208:            @Test
209:            public void testWSIBPR2203() throws Exception {
210:                try {
211:                    String[] args = new String[] { "-verbose",
212:                            getLocation("/validator_wsdl/header_rpc_lit.wsdl") };
213:                    WSDLValidator.main(args);
214:                    assertTrue(getStdOut().indexOf(
215:                            "Passed Validation : Valid WSDL") > -1);
216:                } catch (Exception e) {
217:                    e.printStackTrace();
218:                    fail("No exception expected here, header_rpc_lit is a valid wsdl");
219:                }
220:
221:                try {
222:                    String[] args = new String[] {
223:                            "-verbose",
224:                            getLocation("/validator_wsdl/header_rpc_lit_2203_in.wsdl") };
225:                    WSDLValidator.main(args);
226:                    assertTrue(getStdErr()
227:                            .indexOf(
228:                                    "soapbind:body element(s), only to wsdl:part element(s)") > -1);
229:                } catch (Exception e) {
230:                    e.printStackTrace();
231:                }
232:
233:                try {
234:                    String[] args = new String[] {
235:                            "-verbose",
236:                            getLocation("/validator_wsdl/header_rpc_lit_2203_out.wsdl") };
237:                    WSDLValidator.main(args);
238:                    assertTrue(getStdErr()
239:                            .indexOf(
240:                                    "soapbind:body element(s), only to wsdl:part element(s)") > -1);
241:                } catch (Exception e) {
242:                    e.printStackTrace();
243:                }
244:            }
245:
246:            @Override
247:            protected String getLocation(String wsdlFile) throws Exception {
248:                Enumeration<URL> e = WSDLValidationTest.class.getClassLoader()
249:                        .getResources(wsdlFile);
250:                while (e.hasMoreElements()) {
251:                    URL u = e.nextElement();
252:                    File f = new File(u.toURI());
253:                    if (f.exists() && f.isDirectory()) {
254:                        return f.toString();
255:                    }
256:                }
257:
258:                return WSDLValidationTest.class.getResource(wsdlFile).toURI()
259:                        .getPath();
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.