Source Code Cross Referenced for AnnotationServiceImplWithDBCTests.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:
020:        package org.apache.axis2.jaxws.description;
021:
022:        import junit.framework.TestCase;
023:        import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
024:        import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
025:        import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite;
026:        import org.apache.axis2.jaxws.description.builder.WebMethodAnnot;
027:        import org.apache.axis2.jaxws.description.builder.WebParamAnnot;
028:        import org.apache.axis2.jaxws.description.builder.WebServiceAnnot;
029:
030:        import javax.jws.WebParam;
031:        import javax.xml.ws.WebServiceException;
032:        import java.util.HashMap;
033:        import java.util.List;
034:
035:        /**
036:         * Tests the creation of the Description classes based on a service implementation bean and various
037:         * combinations of annotations
038:         */
039:        public class AnnotationServiceImplWithDBCTests extends TestCase {
040:            /**
041:             * Create the description classes with a service implementation that contains the @WebService
042:             * JSR-181 annotation which references an SEI.
043:             */
044:
045:            //Test creation of a Service Description from DBC, using a basic list.
046:            //An implicit SEI that extends only java.lang.object
047:            public void testServiceImplAsImplicitSEI() {
048:                //org.apache.log4j.BasicConfigurator.configure();
049:
050:                //Build a Hashmap of DescriptionBuilderComposites that contains the serviceImpl and
051:                //all necessary associated DBC's possibly including SEI and superclasses
052:                HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
053:
054:                DescriptionBuilderComposite dbc = buildDBCNoEndpointInterface();
055:
056:                dbcMap.put(dbc.getClassName(), dbc);
057:
058:                // TODO: This test is invalid as is.  It does not specify WSDL, and WSDL generator is not currently available in Open Source
059:                //       So, an exception is currently being thrown.  It may be the correct fix is to NOT always try to generate WSDL; and only
060:                //       try to generate it if it is asked for.
061:                try {
062:                    List<ServiceDescription> serviceDescList = DescriptionFactory
063:                            .createServiceDescriptionFromDBCMap(dbcMap);
064:                    assertNotNull(serviceDescList.get(0));
065:
066:                    //We know this list contains only one SD, so no need to loop
067:                    EndpointDescription[] endpointDesc = serviceDescList.get(0)
068:                            .getEndpointDescriptions();
069:                    assertNotNull(endpointDesc);
070:                    assertEquals(endpointDesc.length, 1);
071:
072:                    // TODO: How will the JAX-WS dispatcher get the appropriate port (i.e. endpoint)?  Currently assumes [0]
073:                    EndpointInterfaceDescription endpointIntfDesc = endpointDesc[0]
074:                            .getEndpointInterfaceDescription();
075:                    assertNotNull(endpointIntfDesc);
076:
077:                } catch (WebServiceException e) {
078:                }
079:
080:                /*
081:                 * Deprecated -- this used to be the test for
082:                 * EndpointInterfaceDescription.getOperationForJavaMethod
083:                 */
084:                /*
085:                 OperationDescription[] operations = endpointIntfDesc.getOperations();
086:                
087:                 String[] paramTypes = operations[0].getJavaParameters();
088:                 assertNotNull(paramTypes);
089:                 assertEquals(paramTypes.length, 1);
090:                 assertEquals("javax.xml.ws.Holder", paramTypes[0]);
091:                
092:                 // Test RequestWrapper annotations
093:                 assertEquals(operations[0].getRequestWrapperLocalName(), "Echo");
094:                 assertEquals(operations[0].getRequestWrapperTargetNamespace(), "http://ws.apache.org/axis2/tests");
095:                 assertEquals(operations[0].getRequestWrapperClassName(), "org.apache.ws.axis2.tests.Echo");
096:                
097:                 // Test ResponseWrapper annotations
098:                 assertEquals(operations[0].getResponseWrapperLocalName(), "EchoResponse");
099:                 assertEquals(operations[0].getResponseWrapperTargetNamespace(), "http://ws.apache.org/axis2/tests");
100:                 assertEquals(operations[0].getResponseWrapperClassName(), "org.apache.ws.axis2.tests.EchoResponse");
101:                
102:                 // Test SOAPBinding default; that annotation is not present in the SEI
103:                 // Note that annotation could occur on the operation or the type
104:                 // (although on this SEI it doesn't occur either place).
105:                 assertEquals(SOAPBinding.Style.DOCUMENT, operations[0].getSoapBindingStyle());
106:                 assertEquals(SOAPBinding.Style.DOCUMENT, endpointIntfDesc.getSoapBindingStyle());
107:                 */
108:            }
109:
110:            //TODO: Basic Test with EndpointInterface set to something valid, so another DBC must
111:            // exist in list
112:
113:            //TODO: Basic Test for Provider
114:
115:            //TODO: Validation Tests
116:            // - Setting WS and WSP
117:            // - Fail just one in List, But allow successful ones to pass
118:
119:            /*
120:             * Method to return the endpoint interface description for a given implementation class.
121:             */
122:
123:            //private EndpointInterfaceDescription getEndpointInterfaceDesc(Class implementationClass) {
124:            //    // Use the description factory directly; this will be done within the JAX-WS runtime
125:            //    return (new EndpointInterfaceDescription()); 
126:            //	//return testEndpointInterfaceDesc;
127:            //}
128:            static public DescriptionBuilderComposite buildDBCNoEndpointInterface() {
129:
130:                //Create a WebServiceAnnot
131:                String WSName = "EchoServiceAnnotated";
132:                String WSTargetNamespace = "http://description.jaxws.axis2.apache.org/";
133:                String WSServiceName = "EchoServiceName";
134:                //String WSWsdlLocation = "http://EchoService/wsdl";
135:                String WSWsdlLocation = "";
136:                String WSEndpointInterface = "";
137:                String WSPortName = "EchoServiceAnnotatedPort";
138:
139:                WebServiceAnnot webServiceAnnot = WebServiceAnnot
140:                        .createWebServiceAnnotImpl(WSName, WSTargetNamespace,
141:                                WSServiceName, WSWsdlLocation,
142:                                WSEndpointInterface, WSPortName);
143:
144:                //Create a WebMethodAnnot
145:                String operationName = "echoStringMethod";
146:                String action = "urn:EchoStringMethod";
147:                boolean exclude = false;
148:
149:                WebMethodAnnot webMethodAnnot = WebMethodAnnot
150:                        .createWebMethodAnnotImpl();
151:                webMethodAnnot.setOperationName(operationName);
152:                webMethodAnnot.setAction(action);
153:                webMethodAnnot.setExclude(exclude);
154:
155:                //Create the WebParamAnnot
156:                String WPName = "arg0";
157:                String WPPartName = "sku";
158:                String WPTargetNamespace = "http://description.jaxws.axis2.apache.org/";
159:                WebParam.Mode WPMode = WebParam.Mode.IN;
160:                boolean WPHeader = true;
161:
162:                WebParamAnnot webParamAnnot = WebParamAnnot
163:                        .createWebParamAnnotImpl();
164:                webParamAnnot.setName(WPName);
165:                webParamAnnot.setPartName(WPPartName);
166:                webParamAnnot.setMode(WPMode);
167:                webParamAnnot.setTargetNamespace(WPTargetNamespace);
168:                webParamAnnot.setHeader(WPHeader);
169:
170:                //Build up the the DBC and all necessary composites
171:                ParameterDescriptionComposite pdc = new ParameterDescriptionComposite();
172:                pdc.setParameterType("java.lang.String");
173:                pdc.setWebParamAnnot(webParamAnnot);
174:
175:                MethodDescriptionComposite mdc = new MethodDescriptionComposite();
176:                mdc.setWebMethodAnnot(webMethodAnnot);
177:                mdc.setMethodName(operationName);
178:                mdc.addParameterDescriptionComposite(pdc, 0);
179:
180:                DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
181:                dbc
182:                        .setClassName("org.apache.axis2.samples.EchoServiceAnnotated");
183:                dbc.setWebServiceAnnot(webServiceAnnot);
184:                dbc.addMethodDescriptionComposite(mdc);
185:
186:                return dbc;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.