Source Code Cross Referenced for WSDLDescriptionTests.java in  » Web-Services-AXIS2 » jax-ws » 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 » jax ws » 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:
020:        package org.apache.axis2.jaxws.description;
021:
022:        import java.net.URL;
023:
024:        import javax.jws.WebMethod;
025:        import javax.jws.WebParam;
026:        import javax.jws.WebParam.Mode;
027:        import javax.jws.WebService;
028:        import javax.xml.namespace.QName;
029:        import javax.xml.transform.Source;
030:        import javax.xml.ws.Dispatch;
031:        import javax.xml.ws.Holder;
032:        import javax.xml.ws.RequestWrapper;
033:        import javax.xml.ws.ResponseWrapper;
034:        import javax.xml.ws.Service;
035:        import javax.xml.ws.WebServiceException;
036:
037:        import junit.framework.TestCase;
038:        import org.apache.axis2.jaxws.spi.ServiceDelegate;
039:        import org.apache.ws.axis2.tests.EchoPort;
040:
041:        /**
042:         * Directly test the Description classes built with a WSDL file.
043:         */
044:        public class WSDLDescriptionTests extends TestCase {
045:
046:            private Service service;
047:            private ServiceDelegate serviceDelegate;
048:            private ServiceDescription serviceDescription;
049:
050:            private static final String VALID_PORT = "EchoPort";
051:            private static final String VALID_NAMESPACE = "http://ws.apache.org/axis2/tests";
052:            private QName validPortQName = new QName(VALID_NAMESPACE,
053:                    VALID_PORT);
054:
055:            protected void setUp() {
056:                // Create a new service for each test to test various valid and invalid
057:                // flows
058:                String namespaceURI = VALID_NAMESPACE;
059:                String localPart = "EchoService";
060:                URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
061:                assertNotNull(wsdlURL);
062:                service = Service.create(wsdlURL, new QName(namespaceURI,
063:                        localPart));
064:                serviceDelegate = DescriptionTestUtils2
065:                        .getServiceDelegate(service);
066:                serviceDescription = serviceDelegate.getServiceDescription();
067:            }
068:
069:            /*
070:             * ========================================================================
071:             * ServiceDescription Tests
072:             * ========================================================================
073:             */
074:            public void testInvalidLocalpartServiceGetEndpoint() {
075:                QName invalidPortQname = new QName(VALID_NAMESPACE,
076:                        "InvalidEchoPort");
077:                EndpointDescription endpointDescription = serviceDescription
078:                        .getEndpointDescription(invalidPortQname);
079:                assertNull("EndpointDescription should not be found",
080:                        endpointDescription);
081:            }
082:
083:            public void testInvalidNamespaceServiceGetEndpoint() {
084:                QName invalidPortQname = new QName(
085:                        "http://ws.apache.org/axis2/tests/INVALID", VALID_PORT);
086:                EndpointDescription endpointDescription = serviceDescription
087:                        .getEndpointDescription(invalidPortQname);
088:                assertNull("EndpointDescription should not be found",
089:                        endpointDescription);
090:            }
091:
092:            // ========================================================================
093:            // EndpointDescription Tests
094:            // ========================================================================
095:
096:            public void testValidGetPortWithClass() {
097:                try {
098:                    EchoPort echoPort = service.getPort(EchoPort.class);
099:                } catch (Exception e) {
100:                    fail("Caught unexpected exception");
101:                }
102:            }
103:
104:            public void testValidGetPortWithClassAndQName() {
105:                EchoPort echoPort = service.getPort(validPortQName,
106:                        EchoPort.class);
107:                assertNotNull(echoPort);
108:
109:                EndpointDescription endpointDesc = serviceDescription
110:                        .getEndpointDescription(validPortQName);
111:                assertNotNull(endpointDesc);
112:                EndpointDescription endpointDescViaSEI = serviceDescription
113:                        .getEndpointDescription(EchoPort.class)[0];
114:                assertNotNull(endpointDescViaSEI);
115:                assertEquals(endpointDesc, endpointDescViaSEI);
116:
117:                EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc
118:                        .getEndpointInterfaceDescription();
119:                assertNotNull(endpointInterfaceDesc);
120:                Class sei = endpointInterfaceDesc.getSEIClass();
121:                assertEquals(EchoPort.class, sei);
122:            }
123:
124:            public void testValidMultipleGetPort() {
125:                EchoPort echoPort = service.getPort(validPortQName,
126:                        EchoPort.class);
127:                assertNotNull(echoPort);
128:
129:                EchoPort echoPort2 = service.getPort(validPortQName,
130:                        EchoPort.class);
131:                assertNotNull(echoPort2);
132:            }
133:
134:            public void testInvalidMultipleGetPort() {
135:                EchoPort echoPort = service.getPort(validPortQName,
136:                        EchoPort.class);
137:                assertNotNull(echoPort);
138:
139:                try {
140:                    EchoPort2 echoPort2 = service.getPort(validPortQName,
141:                            EchoPort2.class);
142:                    fail("Should have caught exception");
143:                } catch (WebServiceException e) {
144:                    // Expected flow
145:                } catch (Exception e) {
146:                    fail("Caught unexpected exception" + e);
147:                }
148:
149:            }
150:
151:            public void testValidAddPort() {
152:                QName dispatchPortQN = new QName(VALID_NAMESPACE,
153:                        "dispatchPort");
154:                service.addPort(dispatchPortQN, null, null);
155:
156:                EndpointDescription endpointDesc = serviceDescription
157:                        .getEndpointDescription(dispatchPortQN);
158:                assertNotNull(endpointDesc);
159:
160:                EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc
161:                        .getEndpointInterfaceDescription();
162:                assertNull(endpointInterfaceDesc);
163:            }
164:
165:            public void testInvalidAddPortExists() {
166:                try {
167:                    service.addPort(validPortQName, null, null);
168:                    fail("Shouldn't be able to add a port that exists in the WSDL");
169:                } catch (WebServiceException e) {
170:                    // Expected path
171:                }
172:            }
173:
174:            public void testInvalidAddPort() {
175:                // Null portQname
176:                try {
177:                    service.addPort(null, null, null);
178:                    fail("Shouldn't be able to add a port with a null QName");
179:                } catch (WebServiceException e) {
180:                    // Expected path
181:                } catch (Exception e) {
182:                    fail("Unexpected exception caught " + e);
183:                }
184:
185:                // Empty Port QName
186:                try {
187:                    service.addPort(new QName("", ""), null, null);
188:                    fail("Shouldn't be able to add an empty port QName");
189:                } catch (WebServiceException e) {
190:                    // Expected path
191:                } catch (Exception e) {
192:                    fail("Unexpected exception caught " + e);
193:                }
194:
195:                // Empty binding ID
196:                try {
197:                    service.addPort(
198:                            new QName(VALID_NAMESPACE, "dispatchPort2"), "",
199:                            null);
200:                    fail("Shouldn't be able to add a port with an empty binding type");
201:                } catch (WebServiceException e) {
202:                    // Expected path
203:                } catch (Exception e) {
204:                    fail("Unexpected exception caught " + e);
205:                }
206:
207:                // Invalid binding ID
208:                try {
209:                    service.addPort(
210:                            new QName(VALID_NAMESPACE, "dispatchPort3"),
211:                            "InvalidBindingType", null);
212:                    fail("Shouldn't be able to add a port with an invalid binding type");
213:                } catch (WebServiceException e) {
214:                    // Expected path
215:                } catch (Exception e) {
216:                    fail("Unexpected exception caught " + e);
217:                }
218:
219:            }
220:
221:            public void testValidAddAndGetPort() {
222:                QName dispatchPortQN = new QName(VALID_NAMESPACE,
223:                        "dispatchPort");
224:                service.addPort(dispatchPortQN, null, null);
225:
226:                EchoPort echoPort = service.getPort(validPortQName,
227:                        EchoPort.class);
228:                assertNotNull(echoPort);
229:
230:                EndpointDescription endpointDesc = serviceDescription
231:                        .getEndpointDescription(validPortQName);
232:                assertNotNull(endpointDesc);
233:                EndpointDescription endpointDescViaSEI = serviceDescription
234:                        .getEndpointDescription(EchoPort.class)[0];
235:                assertNotNull(endpointDescViaSEI);
236:                assertEquals(endpointDesc, endpointDescViaSEI);
237:
238:                EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc
239:                        .getEndpointInterfaceDescription();
240:                assertNotNull(endpointInterfaceDesc);
241:                Class sei = endpointInterfaceDesc.getSEIClass();
242:                assertEquals(EchoPort.class, sei);
243:
244:                EndpointDescription endpointDescDispatch = serviceDescription
245:                        .getEndpointDescription(dispatchPortQN);
246:                assertNotNull(endpointDescDispatch);
247:
248:                EndpointInterfaceDescription endpointInterfaceDescDispatch = endpointDescDispatch
249:                        .getEndpointInterfaceDescription();
250:                assertNull(endpointInterfaceDescDispatch);
251:            }
252:
253:            public void testValidCreateDispatch() {
254:                Dispatch<Source> dispatch = service.createDispatch(
255:                        validPortQName, Source.class, Service.Mode.PAYLOAD);
256:                assertNotNull(dispatch);
257:
258:                EndpointDescription endpointDesc = serviceDescription
259:                        .getEndpointDescription(validPortQName);
260:                assertNotNull(endpointDesc);
261:                // Since ther is no SEI, can not get the endpointDescription based on the sei class
262:                EndpointDescription[] endpointDescViaSEI = serviceDescription
263:                        .getEndpointDescription(EchoPort.class);
264:                assertNull(endpointDescViaSEI);
265:
266:                // There will be an EndpointInterfaceDescription because the service was created with 
267:                // WSDL, however there will be no SEI created because a getPort has not been done
268:                EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc
269:                        .getEndpointInterfaceDescription();
270:                assertNotNull(endpointInterfaceDesc);
271:                assertNull(endpointInterfaceDesc.getSEIClass());
272:            }
273:
274:            public void testValidCreateAndGet() {
275:                Dispatch<Source> dispatch = service.createDispatch(
276:                        validPortQName, Source.class, Service.Mode.PAYLOAD);
277:                assertNotNull(dispatch);
278:                EndpointDescription endpointDesc = serviceDescription
279:                        .getEndpointDescription(validPortQName);
280:                assertNotNull(endpointDesc);
281:                // Since ther is no SEI, can not get the endpointDescription based on the sei class
282:                EndpointDescription[] endpointDescViaSEI = serviceDescription
283:                        .getEndpointDescription(EchoPort.class);
284:                assertNull(endpointDescViaSEI);
285:                EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc
286:                        .getEndpointInterfaceDescription();
287:                assertNotNull(endpointInterfaceDesc);
288:                assertNull(endpointInterfaceDesc.getSEIClass());
289:
290:                EchoPort echoPort = service.getPort(validPortQName,
291:                        EchoPort.class);
292:                assertNotNull(echoPort);
293:                // Since a getPort has been done, should now be able to get things based on the SEI
294:                endpointDesc = serviceDescription
295:                        .getEndpointDescription(validPortQName);
296:                assertNotNull(endpointDesc);
297:                // Since ther is no SEI, can not get the endpointDescription based on the sei class
298:                endpointDescViaSEI = serviceDescription
299:                        .getEndpointDescription(EchoPort.class);
300:                assertNotNull(endpointDescViaSEI);
301:                assertEquals(endpointDesc, endpointDescViaSEI[0]);
302:                endpointInterfaceDesc = endpointDesc
303:                        .getEndpointInterfaceDescription();
304:                assertNotNull(endpointInterfaceDesc);
305:                assertEquals(EchoPort.class, endpointInterfaceDesc
306:                        .getSEIClass());
307:            }
308:
309:            public void testValidGetAndCreate() {
310:                EchoPort echoPort = service.getPort(validPortQName,
311:                        EchoPort.class);
312:                assertNotNull(echoPort);
313:                Dispatch<Source> dispatch = service.createDispatch(
314:                        validPortQName, Source.class, Service.Mode.PAYLOAD);
315:                assertNotNull(dispatch);
316:
317:                // Since a getPort has been done, should now be able to get things based on the SEI
318:                EndpointDescription endpointDesc = serviceDescription
319:                        .getEndpointDescription(validPortQName);
320:                assertNotNull(endpointDesc);
321:                // Since ther is no SEI, can not get the endpointDescription based on the sei class
322:                EndpointDescription[] endpointDescViaSEI = serviceDescription
323:                        .getEndpointDescription(EchoPort.class);
324:                assertNotNull(endpointDescViaSEI);
325:                assertEquals(endpointDesc, endpointDescViaSEI[0]);
326:                EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc
327:                        .getEndpointInterfaceDescription();
328:                assertNotNull(endpointInterfaceDesc);
329:                assertEquals(EchoPort.class, endpointInterfaceDesc
330:                        .getSEIClass());
331:            }
332:
333:            // TODO: Need to add a similar test with no WSDL present; note that it currently would not pass
334:            public void testInvalidAddAndGetPort() {
335:                // Should not be able to do a getPort on one that was added with addPort
336:                QName dispatchPortQN = new QName(VALID_NAMESPACE,
337:                        "dispatchPort");
338:                service.addPort(dispatchPortQN, null, null);
339:                try {
340:                    EchoPort echoPort = service.getPort(dispatchPortQN,
341:                            EchoPort.class);
342:                    fail("Should have thrown a WebServiceException");
343:                } catch (WebServiceException e) {
344:                    // Expected path
345:                }
346:            }
347:        }
348:
349:        // EchoPort2 is identical to EchoPort, but it should still cause an exception
350:        // if it is used on a subsequent getPort after getPort(EchoPort.class) is done.
351:        @WebService(name="EchoPort",targetNamespace="http://ws.apache.org/axis2/tests",wsdlLocation="\\work\\apps\\eclipse\\workspace\\axis2-live\\modules\\jaxws\\test-resources\\wsdl\\WSDLTests.wsdl")
352:        interface EchoPort2 {
353:
354:            /**
355:             * 
356:             * @param text
357:             */
358:            @WebMethod(operationName="Echo",action="http://ws.apache.org/axis2/tests/echo")
359:            @RequestWrapper(localName="Echo",targetNamespace="http://ws.apache.org/axis2/tests",className="org.apache.ws.axis2.tests.Echo")
360:            @ResponseWrapper(localName="EchoResponse",targetNamespace="http://ws.apache.org/axis2/tests",className="org.apache.ws.axis2.tests.EchoResponse")
361:            public void echo(
362:                    @WebParam(name="text",targetNamespace="",mode=Mode.INOUT)
363:                    Holder<String> text);
364:
365:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.