Source Code Cross Referenced for ValidationClientServerTest.java in  » Web-Services-apache-cxf-2.0.1 » systests » org » apache » cxf » systest » schema_validation » 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 » systests » org.apache.cxf.systest.schema_validation 
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.systest.schema_validation;
019:
020:        import java.io.Serializable;
021:        import java.net.URL;
022:        import java.util.List;
023:
024:        import javax.xml.namespace.QName;
025:        import javax.xml.ws.WebServiceException;
026:
027:        import org.apache.cxf.interceptor.Fault;
028:        import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
029:        import org.apache.schema_validation.SchemaValidation;
030:        import org.apache.schema_validation.SchemaValidationService;
031:        import org.apache.schema_validation.types.ComplexStruct;
032:        import org.apache.schema_validation.types.OccuringStruct;
033:        import org.junit.BeforeClass;
034:        import org.junit.Test;
035:
036:        public class ValidationClientServerTest extends
037:                AbstractBusClientServerTestBase {
038:
039:            private final QName serviceName = new QName(
040:                    "http://apache.org/schema_validation",
041:                    "SchemaValidationService");
042:            private final QName portName = new QName(
043:                    "http://apache.org/schema_validation", "SoapPort");
044:
045:            @BeforeClass
046:            public static void startservers() throws Exception {
047:                // set up configuration to enable schema validation
048:                URL url = ValidationClientServerTest.class
049:                        .getResource("cxf-config.xml");
050:                assertNotNull("cannot find test resource", url);
051:                defaultConfigFileName = url.toString();
052:
053:                assertTrue("server did not launch correctly",
054:                        launchServer(ValidationServer.class));
055:            }
056:
057:            // TODO : Change this test so that we test the combinations of
058:            // client and server with schema validation enabled/disabled...
059:            // Only tests client side validation enabled/server side disabled.
060:            @Test
061:            public void testSchemaValidation() throws Exception {
062:                System.setProperty("cxf.config.file.url", getClass()
063:                        .getResource("cxf-config.xml").toString());
064:                URL wsdl = getClass().getResource(
065:                        "/wsdl/schema_validation.wsdl");
066:                assertNotNull(wsdl);
067:
068:                SchemaValidationService service = new SchemaValidationService(
069:                        wsdl, serviceName);
070:                assertNotNull(service);
071:
072:                SchemaValidation validation = service.getPort(portName,
073:                        SchemaValidation.class);
074:
075:                ComplexStruct complexStruct = new ComplexStruct();
076:                complexStruct.setElem1("one");
077:                // Don't initialize a member of the structure.  
078:                // Client side validation should throw an exception.
079:                // complexStruct.setElem2("two");
080:                complexStruct.setElem3(3);
081:                try {
082:                    /*boolean result =*/
083:                    validation.setComplexStruct(complexStruct);
084:                    fail("Set ComplexStruct hould have thrown ProtocolException");
085:                } catch (WebServiceException e) {
086:                    assertTrue(e.getCause() instanceof  Fault);
087:                    String expected = "'{\"http://apache.org/schema_validation/types\":elem2}' is expected.";
088:                    assertTrue(e.getCause().getMessage().indexOf(expected) != -1);
089:                }
090:
091:                OccuringStruct occuringStruct = new OccuringStruct();
092:                // Populate the list in the wrong order.
093:                // Client side validation should throw an exception.
094:                List<Serializable> floatIntStringList = occuringStruct
095:                        .getVarFloatAndVarIntAndVarString();
096:                floatIntStringList.add(new Integer(42));
097:                floatIntStringList.add(new Float(4.2f));
098:                floatIntStringList.add("Goofus and Gallant");
099:                try {
100:                    /*boolean result =*/
101:                    validation.setOccuringStruct(occuringStruct);
102:                    fail("Set OccuringStruct hould have thrown ProtocolException");
103:                } catch (WebServiceException e) {
104:                    assertTrue(e.getCause() instanceof  Fault);
105:                    String expected = "'{\"http://apache.org/schema_validation/types\":varFloat}' is expected.";
106:                    assertTrue(e.getCause().getMessage().indexOf(expected) != -1);
107:                }
108:
109:                try {
110:                    // The server will attempt to return an invalid ComplexStruct
111:                    // When validation is disabled on the server side, we'll get the
112:                    // exception while unmarshalling the invalid response.
113:                    /*complexStruct =*/
114:                    validation.getComplexStruct("Hello");
115:                    fail("Get ComplexStruct should have thrown ProtocolException");
116:                } catch (WebServiceException e) {
117:                    assertTrue(e.getCause() instanceof  Fault);
118:                    String expected = "'{\"http://apache.org/schema_validation/types\":elem2}' is expected.";
119:                    assertTrue("Found message " + e.getCause().getMessage(), e
120:                            .getCause().getMessage().indexOf(expected) != -1);
121:                }
122:
123:                try {
124:                    // The server will attempt to return an invalid OccuringStruct
125:                    // When validation is disabled on the server side, we'll get the
126:                    // exception while unmarshalling the invalid response.
127:                    /*occuringStruct =*/
128:                    validation.getOccuringStruct("World");
129:                    fail("Get OccuringStruct should have thrown ProtocolException");
130:                } catch (WebServiceException e) {
131:                    assertTrue(e.getCause() instanceof  Fault);
132:                    String expected = "'{\"http://apache.org/schema_validation/types\":varFloat}' is expected.";
133:                    assertTrue(e.getCause().getMessage().indexOf(expected) != -1);
134:                }
135:            }
136:
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.