Source Code Cross Referenced for JaxWsServiceConfigurationTest.java in  » Web-Services-apache-cxf-2.0.1 » frontend » org » apache » cxf » jaxws » support » 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 » frontend » org.apache.cxf.jaxws.support 
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.jaxws.support;
019:
020:        import java.lang.reflect.Method;
021:
022:        import java.util.Iterator;
023:
024:        import javax.jws.WebMethod;
025:        import javax.jws.WebService;
026:        import javax.jws.soap.SOAPBinding;
027:        import javax.wsdl.Definition;
028:        import javax.wsdl.Service;
029:        import javax.wsdl.factory.WSDLFactory;
030:        import javax.wsdl.xml.WSDLReader;
031:        import javax.xml.namespace.QName;
032:
033:        import org.apache.cxf.Bus;
034:        import org.apache.cxf.binding.BindingFactoryManager;
035:        import org.apache.cxf.service.model.MessageInfo;
036:        import org.apache.cxf.service.model.OperationInfo;
037:        import org.apache.cxf.service.model.ServiceInfo;
038:        import org.apache.cxf.transport.DestinationFactoryManager;
039:        import org.apache.cxf.wsdl11.WSDLLocatorImpl;
040:        import org.apache.cxf.wsdl11.WSDLServiceBuilder;
041:        import org.easymock.classextension.EasyMock;
042:        import org.easymock.classextension.IMocksControl;
043:        import org.junit.Assert;
044:        import org.junit.Before;
045:        import org.junit.Test;
046:
047:        public class JaxWsServiceConfigurationTest extends Assert {
048:
049:            @Before
050:            public void setUp() throws Exception {
051:
052:            }
053:
054:            @Test
055:            public void testGetInPartName() throws Exception {
056:                QName opName = new QName("http://cxf.com/", "sayHello");
057:                Method sayHelloMethod = Hello.class.getMethod("sayHello",
058:                        new Class[] { String.class, String.class });
059:                ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
060:                JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
061:                bean.setServiceClass(Hello.class);
062:                JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean
063:                        .getServiceConfigurations().get(0);
064:                jwsc.setServiceFactory(bean);
065:
066:                OperationInfo op = si.getInterface().getOperation(opName);
067:                op.setInput("input", new MessageInfo(op, new QName(
068:                        "http://cxf.com/", "input")));
069:                op.setOutput("output", new MessageInfo(op, new QName(
070:                        "http://cxf.com/", "output")));
071:
072:                QName partName = jwsc.getInPartName(op, sayHelloMethod, 0);
073:                assertEquals("get wrong in partName for first param",
074:                        new QName("http://cxf.com/", "arg0"), partName);
075:
076:                op.getInput().addMessagePart(new QName("arg0"));
077:
078:                partName = jwsc.getInPartName(op, sayHelloMethod, 1);
079:                assertEquals("get wrong in partName for first param",
080:                        new QName("http://cxf.com/", "arg1"), partName);
081:            }
082:
083:            @Test
084:            public void testDefaultStyle() throws Exception {
085:                JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
086:                bean.setServiceClass(HelloDefault.class);
087:                JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean
088:                        .getServiceConfigurations().get(0);
089:                jwsc.setServiceFactory(bean);
090:
091:                assertEquals("document", jwsc.getStyle());
092:                assertNull(jwsc.isWrapped());
093:            }
094:
095:            @Test
096:            public void testRPCStyle() throws Exception {
097:                JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
098:                bean.setServiceClass(HelloRPC.class);
099:                JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean
100:                        .getServiceConfigurations().get(0);
101:                jwsc.setServiceFactory(bean);
102:
103:                assertEquals("rpc", jwsc.getStyle());
104:                assertFalse(jwsc.isWrapped());
105:            }
106:
107:            @Test
108:            public void testDocumentWrappedStyle() throws Exception {
109:                JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
110:                bean.setServiceClass(HelloWrapped.class);
111:                JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean
112:                        .getServiceConfigurations().get(0);
113:                jwsc.setServiceFactory(bean);
114:
115:                assertEquals("document", jwsc.getStyle());
116:                assertTrue(jwsc.isWrapped());
117:            }
118:
119:            @Test
120:            public void testDocumentBareStyle() throws Exception {
121:                JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
122:                bean.setServiceClass(HelloBare.class);
123:                JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean
124:                        .getServiceConfigurations().get(0);
125:                jwsc.setServiceFactory(bean);
126:
127:                assertEquals("document", jwsc.getStyle());
128:                assertFalse(jwsc.isWrapped());
129:            }
130:
131:            @Test
132:            public void testGetOutPartName() throws Exception {
133:                QName opName = new QName("http://cxf.com/", "sayHi");
134:                Method sayHiMethod = Hello.class.getMethod("sayHi",
135:                        new Class[] {});
136:                ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
137:                JaxWsServiceConfiguration jwsc = new JaxWsServiceConfiguration();
138:                JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
139:                bean.setServiceClass(Hello.class);
140:                jwsc.setServiceFactory(bean);
141:
142:                // clear the output
143:                OperationInfo op = si.getInterface().getOperation(opName);
144:                op.setOutput("output", new MessageInfo(op, new QName(
145:                        "http://cxf.com/", "output")));
146:
147:                QName partName = jwsc.getOutPartName(op, sayHiMethod, -1);
148:                assertEquals("get wrong return partName", new QName(
149:                        "http://cxf.com/", "return"), partName);
150:            }
151:
152:            private ServiceInfo getMockedServiceModel(String wsdlUrl)
153:                    throws Exception {
154:                WSDLReader wsdlReader = WSDLFactory.newInstance()
155:                        .newWSDLReader();
156:                wsdlReader.setFeature("javax.wsdl.verbose", false);
157:                Definition def = wsdlReader.readWSDL(new WSDLLocatorImpl(
158:                        wsdlUrl));
159:
160:                IMocksControl control = EasyMock.createNiceControl();
161:                Bus bus = control.createMock(Bus.class);
162:                BindingFactoryManager bindingFactoryManager = control
163:                        .createMock(BindingFactoryManager.class);
164:                DestinationFactoryManager dfm = control
165:                        .createMock(DestinationFactoryManager.class);
166:                WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(
167:                        bus);
168:
169:                Service service = null;
170:                for (Iterator<?> it = def.getServices().values().iterator(); it
171:                        .hasNext();) {
172:                    Object obj = it.next();
173:                    if (obj instanceof  Service) {
174:                        service = (Service) obj;
175:                        break;
176:                    }
177:                }
178:
179:                EasyMock.expect(bus.getExtension(BindingFactoryManager.class))
180:                        .andReturn(bindingFactoryManager);
181:                EasyMock.expect(
182:                        bus.getExtension(DestinationFactoryManager.class))
183:                        .andStubReturn(dfm);
184:                control.replay();
185:
186:                ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def,
187:                        service).get(0);
188:                serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION,
189:                        null);
190:                serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
191:                return serviceInfo;
192:            }
193:
194:            @WebService(name="Hello",targetNamespace="http://cxf.com/")
195:            @SOAPBinding(parameterStyle=javax.jws.soap.SOAPBinding.ParameterStyle.BARE,style=javax.jws.soap.SOAPBinding.Style.RPC,use=javax.jws.soap.SOAPBinding.Use.LITERAL)
196:            public interface Hello {
197:                @WebMethod(operationName="sayHi",exclude=false)
198:                String sayHi();
199:
200:                @WebMethod(operationName="sayHello",exclude=false)
201:                String sayHello(String asdf1, String asdf2);
202:            }
203:
204:            @WebService(name="Hello",targetNamespace="http://cxf.com/")
205:            public interface HelloDefault {
206:                @WebMethod(operationName="sayHi",exclude=false)
207:                String sayHi();
208:
209:                @WebMethod(operationName="sayHello",exclude=false)
210:                String sayHello(String asdf1, String asdf2);
211:            }
212:
213:            @SOAPBinding(style=javax.jws.soap.SOAPBinding.Style.RPC)
214:            public interface HelloRPC {
215:                String sayHi();
216:            }
217:
218:            @SOAPBinding(style=javax.jws.soap.SOAPBinding.Style.DOCUMENT)
219:            public interface HelloWrapped {
220:                String sayHi();
221:            }
222:
223:            @SOAPBinding(parameterStyle=javax.jws.soap.SOAPBinding.ParameterStyle.BARE,style=javax.jws.soap.SOAPBinding.Style.DOCUMENT)
224:            public interface HelloBare {
225:                String sayHi();
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.