Source Code Cross Referenced for ServiceAnnotationTests.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 junit.framework.TestCase;
022:        import org.apache.log4j.BasicConfigurator;
023:
024:        import javax.jws.WebService;
025:        import javax.xml.ws.Provider;
026:        import javax.xml.ws.WebServiceProvider;
027:
028:        public class ServiceAnnotationTests extends TestCase {
029:            static {
030:                // Note you will probably need to increase the java heap size, for example
031:                // -Xmx512m.  This can be done by setting maven.junit.jvmargs in project.properties.
032:                // To change the settings, edit the log4j.property file
033:                // in the test-resources directory.
034:                BasicConfigurator.configure();
035:            }
036:
037:            public void testWebServiceDefaults() {
038:                String className = "WebServiceDefaultTest";
039:                EndpointDescriptionJava testEndpointDesc = getEndpointDesc(WebServiceDefaultTest.class);
040:                assertNotNull(testEndpointDesc.getAnnoWebService());
041:                assertNull(testEndpointDesc.getAnnoWebServiceProvider());
042:                assertEquals(className, testEndpointDesc
043:                        .getAnnoWebServiceName());
044:                assertEquals("", testEndpointDesc
045:                        .getAnnoWebServiceEndpointInterface());
046:                assertEquals("http://description.jaxws.axis2.apache.org/",
047:                        testEndpointDesc.getAnnoWebServiceTargetNamespace());
048:                assertEquals(className + "Service", testEndpointDesc
049:                        .getAnnoWebServiceServiceName());
050:                assertEquals(className + "Port", testEndpointDesc
051:                        .getAnnoWebServicePortName());
052:                assertEquals("", testEndpointDesc
053:                        .getAnnoWebServiceWSDLLocation());
054:            }
055:
056:            public void testWebServiceProviderDefaults() {
057:                String className = "WebServiceProviderDefaultTest";
058:                EndpointDescriptionJava testEndpointDesc = getEndpointDesc(WebServiceProviderDefaultTest.class);
059:                assertNull(testEndpointDesc.getAnnoWebService());
060:                assertNotNull(testEndpointDesc.getAnnoWebServiceProvider());
061:                // name element not allowed on WebServiceProvider
062:                assertEquals("", testEndpointDesc.getAnnoWebServiceName());
063:                // EndpointInterface element not allowed on WebServiceProvider
064:                assertEquals("", testEndpointDesc
065:                        .getAnnoWebServiceEndpointInterface());
066:                assertEquals("http://description.jaxws.axis2.apache.org/",
067:                        testEndpointDesc.getAnnoWebServiceTargetNamespace());
068:                assertEquals(className + "Service", testEndpointDesc
069:                        .getAnnoWebServiceServiceName());
070:                assertEquals(className + "Port", testEndpointDesc
071:                        .getAnnoWebServicePortName());
072:                assertEquals("", testEndpointDesc
073:                        .getAnnoWebServiceWSDLLocation());
074:            }
075:
076:            public void testWebServiceName() {
077:                String className = "WebServiceName";
078:                EndpointDescriptionJava testEndpointDesc = getEndpointDesc(WebServiceName.class);
079:                assertNotNull(testEndpointDesc.getAnnoWebService());
080:                assertNull(testEndpointDesc.getAnnoWebServiceProvider());
081:                assertEquals("WebServiceNameElement", testEndpointDesc
082:                        .getAnnoWebServiceName());
083:                assertEquals("", testEndpointDesc
084:                        .getAnnoWebServiceEndpointInterface());
085:                assertEquals("http://description.jaxws.axis2.apache.org/",
086:                        testEndpointDesc.getAnnoWebServiceTargetNamespace());
087:                // Note that per JSR-181 MR Sec 4.1 pg 16, the portName uses WebService.name, but serviceName does not!
088:                assertEquals(className + "Service", testEndpointDesc
089:                        .getAnnoWebServiceServiceName());
090:                assertEquals("WebServiceNameElementPort", testEndpointDesc
091:                        .getAnnoWebServicePortName());
092:                assertEquals("", testEndpointDesc
093:                        .getAnnoWebServiceWSDLLocation());
094:            }
095:
096:            public void testWebServiceNameAndPort() {
097:                String className = "WebServiceNameAndPort";
098:                EndpointDescriptionJava testEndpointDesc = getEndpointDesc(WebServiceNameAndPort.class);
099:                assertNotNull(testEndpointDesc.getAnnoWebService());
100:                assertNull(testEndpointDesc.getAnnoWebServiceProvider());
101:                assertEquals("WebServiceNameAndPortElement", testEndpointDesc
102:                        .getAnnoWebServiceName());
103:                assertEquals("", testEndpointDesc
104:                        .getAnnoWebServiceEndpointInterface());
105:                assertEquals("http://description.jaxws.axis2.apache.org/",
106:                        testEndpointDesc.getAnnoWebServiceTargetNamespace());
107:                // Note that per JSR-181 MR Sec 4.1 pg 16, the portName uses WebService.name, but serviceName does not!
108:                assertEquals(className + "Service", testEndpointDesc
109:                        .getAnnoWebServiceServiceName());
110:                assertEquals("WebServicePortName", testEndpointDesc
111:                        .getAnnoWebServicePortName());
112:                assertEquals("", testEndpointDesc
113:                        .getAnnoWebServiceWSDLLocation());
114:            }
115:
116:            public void testWebServiceAll() {
117:                String className = "WebServiceAll";
118:                EndpointDescriptionJava testEndpointDesc = getEndpointDesc(WebServiceAll.class);
119:                assertNotNull(testEndpointDesc.getAnnoWebService());
120:                assertNull(testEndpointDesc.getAnnoWebServiceProvider());
121:                assertEquals("WebServiceAll", testEndpointDesc
122:                        .getAnnoWebServiceName());
123:                assertEquals(
124:                        "org.apache.axis2.jaxws.description.MyEndpointInterface",
125:                        testEndpointDesc.getAnnoWebServiceEndpointInterface());
126:                assertEquals("http://namespace.target.jaxws.axis2.apache.org/",
127:                        testEndpointDesc.getAnnoWebServiceTargetNamespace());
128:                assertEquals("WebServiceAllServiceElement", testEndpointDesc
129:                        .getAnnoWebServiceServiceName());
130:                assertEquals("WebServiceAllPortElement", testEndpointDesc
131:                        .getAnnoWebServicePortName());
132:                // TODO: When the JavaReflection-to-DBC converter is fixed to read in WSDL, then add this check back in.
133:                //        assertEquals("http://my.wsdl.location/foo.wsdl", testEndpointDesc.getAnnoWebServiceWSDLLocation());
134:            }
135:
136:            public void testWebServiceProviderAll() {
137:                String className = "WebServiceProviderAll";
138:                EndpointDescriptionJava testEndpointDesc = getEndpointDesc(WebServiceProviderAll.class);
139:                assertNull(testEndpointDesc.getAnnoWebService());
140:                assertNotNull(testEndpointDesc.getAnnoWebServiceProvider());
141:                assertEquals("", testEndpointDesc.getAnnoWebServiceName());
142:                assertEquals("", testEndpointDesc
143:                        .getAnnoWebServiceEndpointInterface());
144:                assertEquals("http://namespace.target.jaxws.axis2.apache.org/",
145:                        testEndpointDesc.getAnnoWebServiceTargetNamespace());
146:                assertEquals("WebServiceProviderAllServiceElement",
147:                        testEndpointDesc.getAnnoWebServiceServiceName());
148:                assertEquals("WebServiceProviderAllPortElement",
149:                        testEndpointDesc.getAnnoWebServicePortName());
150:                assertEquals("http://my.wsdl.other.location/foo.wsdl",
151:                        testEndpointDesc.getAnnoWebServiceWSDLLocation());
152:
153:            }
154:
155:            /*
156:             * Method to return the endpoint interface description for a given implementation class.
157:             */
158:            private EndpointDescriptionJava getEndpointDesc(
159:                    Class implementationClass) {
160:                // Use the description factory directly; this will be done within the JAX-WS runtime
161:                ServiceDescription serviceDesc = DescriptionFactory
162:                        .createServiceDescription(implementationClass);
163:                assertNotNull(serviceDesc);
164:
165:                EndpointDescription[] endpointDesc = serviceDesc
166:                        .getEndpointDescriptions();
167:                assertNotNull(endpointDesc);
168:                assertEquals(1, endpointDesc.length);
169:
170:                // TODO: How will the JAX-WS dispatcher get the appropriate port (i.e. endpoint)?  Currently assumes [0]
171:                EndpointDescription testEndpointDesc = endpointDesc[0];
172:                return (EndpointDescriptionJava) testEndpointDesc;
173:            }
174:        }
175:
176:        // ===============================================
177:        // WebService Defaults test impl
178:        // ===============================================
179:
180:        @WebService()
181:        class WebServiceDefaultTest {
182:
183:        }
184:
185:        @WebServiceProvider()
186:        class WebServiceProviderDefaultTest implements  Provider<String> {
187:            public WebServiceProviderDefaultTest() {
188:            }
189:
190:            public String invoke(String obj) {
191:                return null;
192:            }
193:
194:        }
195:
196:        // ===============================================
197:        // WebService Name test impl
198:        // ===============================================
199:        // Note that name is only allowed on @WebService; not @WebServiceProvider
200:
201:        @WebService(name="WebServiceNameElement")
202:        class WebServiceName {
203:
204:        }
205:
206:        @WebService(name="WebServiceNameAndPortElement",portName="WebServicePortName")
207:        class WebServiceNameAndPort {
208:
209:        }
210:
211:        // ===============================================
212:        // WebService All test impl
213:        // ===============================================
214:        // TODO: When the JavaReflection-to-DBC converter is fixed to read in the WSDL, then specify a valid WSDL file here
215:
216:        @WebService(endpointInterface="org.apache.axis2.jaxws.description.MyEndpointInterface",targetNamespace="http://namespace.target.jaxws.axis2.apache.org/",serviceName="WebServiceAllServiceElement",portName="WebServiceAllPortElement")
217:        class WebServiceAll {
218:
219:        }
220:
221:        @WebService()
222:        interface MyEndpointInterface {
223:
224:        }
225:
226:        @WebServiceProvider(targetNamespace="http://namespace.target.jaxws.axis2.apache.org/",serviceName="WebServiceProviderAllServiceElement",portName="WebServiceProviderAllPortElement",wsdlLocation="http://my.wsdl.other.location/foo.wsdl")
227:        class WebServiceProviderAll implements  Provider<String> {
228:            public WebServiceProviderAll() {
229:            }
230:
231:            public String invoke(String obj) {
232:                return null;
233:            }
234:
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.