Source Code Cross Referenced for ValidateServiceImplTests.java in  » Web-Services-AXIS2 » metadata » org » apache » axis2 » jaxws » description » 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 AXIS2 » metadata » org.apache.axis2.jaxws.description 
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:         */
019:        package org.apache.axis2.jaxws.description;
020:
021:        import java.util.HashMap;
022:        import java.util.List;
023:
024:        import javax.jws.WebService;
025:
026:        import org.apache.axis2.jaxws.ExceptionFactory;
027:        import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
028:        import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
029:        import org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter;
030:
031:        import junit.framework.TestCase;
032:
033:        /**
034:         * 
035:         */
036:        public class ValidateServiceImplTests extends TestCase {
037:
038:            public void testValidServiceImpl() {
039:                try {
040:                    Class serviceImplClass = ServiceImpl.class;
041:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
042:                            serviceImplClass);
043:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
044:                            .produceDBC();
045:                    List<ServiceDescription> serviceDescList = DescriptionFactory
046:                            .createServiceDescriptionFromDBCMap(dbcMap);
047:                    assertNotNull(serviceDescList);
048:                    assertEquals(1, serviceDescList.size());
049:                } catch (Exception e) {
050:                    e.printStackTrace();
051:                    fail("Caught unexpected exception" + e);
052:                }
053:            }
054:
055:            public void testMissingMethods() {
056:                try {
057:                    Class serviceImplClass = MissingMethodsImpl.class;
058:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
059:                            serviceImplClass);
060:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
061:                            .produceDBC();
062:                    List<ServiceDescription> serviceDescList = DescriptionFactory
063:                            .createServiceDescriptionFromDBCMap(dbcMap);
064:                    fail("Should have caused exception");
065:                } catch (Exception e) {
066:                    // Expected path
067:                }
068:            }
069:
070:            public void testInvalidThrows() {
071:                try {
072:                    Class serviceImplClass = InvalidThrowsImpl.class;
073:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
074:                            serviceImplClass);
075:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
076:                            .produceDBC();
077:                    List<ServiceDescription> serviceDescList = DescriptionFactory
078:                            .createServiceDescriptionFromDBCMap(dbcMap);
079:                    fail("Should have caused exception");
080:                } catch (Exception e) {
081:                    // Expected path
082:                }
083:            }
084:
085:            public void testMismatchedReturnTypesDBC() {
086:                try {
087:                    Class serviceImplClass = ServiceImpl.class;
088:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
089:                            serviceImplClass);
090:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
091:                            .produceDBC();
092:                    // Set the return types for one of the methods on the impl class to mismatch the SEI
093:                    DescriptionBuilderComposite implDBC = dbcMap
094:                            .get("org.apache.axis2.jaxws.description.ServiceImpl");
095:                    assertNotNull(implDBC);
096:                    List<MethodDescriptionComposite> m1MDCList = implDBC
097:                            .getMethodDescriptionComposite("method1");
098:                    assertNotNull(m1MDCList);
099:                    assertEquals(1, m1MDCList.size());
100:                    MethodDescriptionComposite m1MDC = m1MDCList.get(0);
101:                    assertEquals("java.lang.String", m1MDC.getReturnType());
102:                    m1MDC.setReturnType("lava.lang.Integer");
103:
104:                    List<ServiceDescription> serviceDescList = DescriptionFactory
105:                            .createServiceDescriptionFromDBCMap(dbcMap);
106:                    fail("Should have caused exception");
107:                } catch (Exception e) {
108:                    // Expected path
109:                }
110:            }
111:
112:            public void testMismatchedReturnTypes() {
113:                try {
114:                    Class serviceImplClass = MismatchedReturnTypesImpl.class;
115:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
116:                            serviceImplClass);
117:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
118:                            .produceDBC();
119:                    List<ServiceDescription> serviceDescList = DescriptionFactory
120:                            .createServiceDescriptionFromDBCMap(dbcMap);
121:                    fail("Should have caused exception");
122:                } catch (Exception e) {
123:                    // Expected path
124:                }
125:            }
126:
127:            public void testMismatchedParameterNumber() {
128:                try {
129:                    Class serviceImplClass = MismatchedParameterNumberImpl.class;
130:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
131:                            serviceImplClass);
132:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
133:                            .produceDBC();
134:                    List<ServiceDescription> serviceDescList = DescriptionFactory
135:                            .createServiceDescriptionFromDBCMap(dbcMap);
136:                    fail("Should have caused exception");
137:                } catch (Exception e) {
138:                    // Expected path
139:                }
140:            }
141:
142:            public void testMismatchedParameterTypes() {
143:                try {
144:                    Class serviceImplClass = MismatchedParameterTypesImpl.class;
145:                    JavaClassToDBCConverter converter = new JavaClassToDBCConverter(
146:                            serviceImplClass);
147:                    HashMap<String, DescriptionBuilderComposite> dbcMap = converter
148:                            .produceDBC();
149:                    List<ServiceDescription> serviceDescList = DescriptionFactory
150:                            .createServiceDescriptionFromDBCMap(dbcMap);
151:                    fail("Should have caused exception");
152:                } catch (Exception e) {
153:                    // Expected path
154:                }
155:            }
156:
157:        }
158:
159:        @WebService
160:        interface EndpointInterface {
161:            public String method1(int param1, int param2) throws MyException;
162:
163:            public void method2(String param1) throws MyException;
164:
165:            public int method3();
166:        }
167:
168:        class MyException extends Exception {
169:
170:        }
171:
172:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.EndpointInterface")
173:        class ServiceImpl {
174:            public String method1(int param1, int param2) throws MyException {
175:                return null;
176:            }
177:
178:            // Intentionally doesn't throw MyException.  It is valid for a service impl to throw
179:            // fewer exceptions than the endpoint interface
180:            public void method2(String param1) {
181:
182:            }
183:
184:            public int method3() {
185:                return 0;
186:            }
187:        }
188:
189:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.EndpointInterface")
190:        class MissingMethodsImpl {
191:            public String method1(int param1, int param2) {
192:                return null;
193:            }
194:
195:            //    public void method2(String param1) {
196:            //        
197:            //    }
198:
199:            public int method3() {
200:                return 0;
201:            }
202:        }
203:
204:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.EndpointInterface")
205:        class InvalidThrowsImpl {
206:            public String method1(int param1, int param2) throws MyException {
207:                return null;
208:            }
209:
210:            // Intentionally doesn't throw MyException.  It is valid for a service impl to throw
211:            // fewer exceptions than the endpoint interface
212:            public void method2(String param1) {
213:
214:            }
215:
216:            // It is invalid to throw more exceptions than the endpoint interface
217:            public int method3() throws MyException {
218:                return 0;
219:            }
220:        }
221:
222:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.EndpointInterface")
223:        class MismatchedReturnTypesImpl {
224:            // Return type doesn't match SEI
225:            public Integer method1(int param1, int param2) throws MyException {
226:                return null;
227:            }
228:
229:            public void method2(String param1) {
230:
231:            }
232:
233:            public int method3() {
234:                return 0;
235:            }
236:        }
237:
238:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.EndpointInterface")
239:        class MismatchedParameterNumberImpl {
240:            public String method1(int param1) throws MyException {
241:                return null;
242:            }
243:
244:            public void method2(String param1) {
245:
246:            }
247:
248:            public int method3() {
249:                return 0;
250:            }
251:        }
252:
253:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.EndpointInterface")
254:        class MismatchedParameterTypesImpl {
255:            public String method1(int param1, String param2) throws MyException {
256:                return null;
257:            }
258:
259:            // Intentionally doesn't throw MyException.  It is valid for a service impl to throw
260:            // fewer exceptions than the endpoint interface
261:            public void method2(String param1) {
262:
263:            }
264:
265:            public int method3() {
266:                return 0;
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.