Source Code Cross Referenced for HeaderClientServerTest.java in  » Web-Services-apache-cxf-2.0.1 » frontend » org » apache » cxf » jaxws » header » 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.header 
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.header;
019:
020:        import java.lang.reflect.UndeclaredThrowableException;
021:        import java.net.URL;
022:        import javax.xml.namespace.QName;
023:        import javax.xml.ws.Endpoint;
024:        import javax.xml.ws.Holder;
025:
026:        import org.apache.cxf.BusFactory;
027:        import org.apache.cxf.interceptor.LoggingInInterceptor;
028:        import org.apache.cxf.interceptor.LoggingOutInterceptor;
029:        import org.apache.cxf.jaxws.AbstractJaxWsTest;
030:        import org.apache.cxf.jaxws.EndpointImpl;
031:        import org.apache.header_test.SOAPHeaderService;
032:        import org.apache.header_test.TestHeader;
033:        import org.apache.header_test.TestHeaderImpl;
034:        import org.apache.header_test.rpc.SOAPRPCHeaderService;
035:        import org.apache.header_test.rpc.TestRPCHeader;
036:        import org.apache.header_test.rpc.TestRPCHeaderImpl;
037:        import org.apache.header_test.rpc.types.HeaderMessage;
038:        import org.apache.header_test.types.TestHeader1;
039:        import org.apache.header_test.types.TestHeader1Response;
040:        import org.apache.header_test.types.TestHeader2;
041:        import org.apache.header_test.types.TestHeader2Response;
042:        import org.apache.header_test.types.TestHeader3;
043:        import org.apache.header_test.types.TestHeader3Response;
044:        import org.apache.header_test.types.TestHeader5;
045:        import org.apache.header_test.types.TestHeader5ResponseBody;
046:        import org.apache.header_test.types.TestHeader6;
047:        import org.apache.header_test.types.TestHeader6Response;
048:        import org.apache.tests.type_test.all.SimpleAll;
049:        import org.apache.tests.type_test.choice.SimpleChoice;
050:        import org.apache.tests.type_test.sequence.SimpleStruct;
051:        import org.junit.Before;
052:        import org.junit.Test;
053:
054:        public class HeaderClientServerTest extends AbstractJaxWsTest {
055:            private final QName serviceName = new QName(
056:                    "http://apache.org/header_test", "SOAPHeaderService");
057:            private final QName portName = new QName(
058:                    "http://apache.org/header_test", "SoapHeaderPort");
059:
060:            @Before
061:            public void setUp() throws Exception {
062:                BusFactory.setDefaultBus(getBus());
063:
064:                Object implementor = new TestHeaderImpl();
065:                String address = "http://localhost:9104/SoapHeaderContext/SoapHeaderPort";
066:                EndpointImpl e = (EndpointImpl) Endpoint.publish(address,
067:                        implementor);
068:                e.getServer().getEndpoint().getInInterceptors().add(
069:                        new LoggingInInterceptor());
070:                e.getServer().getEndpoint().getOutInterceptors().add(
071:                        new LoggingOutInterceptor());
072:
073:                implementor = new TestRPCHeaderImpl();
074:                address = "http://localhost:9104/SoapHeaderRPCContext/SoapHeaderRPCPort";
075:                e = (EndpointImpl) Endpoint.publish(address, implementor);
076:                e.getServer().getEndpoint().getInInterceptors().add(
077:                        new LoggingInInterceptor());
078:                e.getServer().getEndpoint().getOutInterceptors().add(
079:                        new LoggingOutInterceptor());
080:            }
081:
082:            @Test
083:            public void testInHeader() throws Exception {
084:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
085:                assertNotNull(wsdl);
086:
087:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
088:                        serviceName);
089:                assertNotNull(service);
090:                TestHeader proxy = service.getPort(portName, TestHeader.class);
091:                try {
092:                    TestHeader1 val = new TestHeader1();
093:                    for (int idx = 0; idx < 2; idx++) {
094:                        TestHeader1Response returnVal = proxy.testHeader1(val,
095:                                val);
096:                        assertNotNull(returnVal);
097:                        assertEquals(TestHeader1.class.getSimpleName(),
098:                                returnVal.getResponseType());
099:                    }
100:                } catch (UndeclaredThrowableException ex) {
101:                    throw (Exception) ex.getCause();
102:                }
103:            }
104:
105:            @Test
106:            public void testOutHeader() throws Exception {
107:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
108:                assertNotNull(wsdl);
109:
110:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
111:                        serviceName);
112:                assertNotNull(service);
113:                TestHeader proxy = service.getPort(portName, TestHeader.class);
114:                try {
115:                    TestHeader2 in = new TestHeader2();
116:                    String val = new String(TestHeader2Response.class
117:                            .getSimpleName());
118:                    Holder<TestHeader2Response> out = new Holder<TestHeader2Response>();
119:                    Holder<TestHeader2Response> outHeader = new Holder<TestHeader2Response>();
120:                    for (int idx = 0; idx < 2; idx++) {
121:                        val += idx;
122:                        in.setRequestType(val);
123:                        proxy.testHeader2(in, out, outHeader);
124:
125:                        assertEquals(val, out.value.getResponseType());
126:                        assertEquals(val, outHeader.value.getResponseType());
127:                    }
128:                } catch (UndeclaredThrowableException ex) {
129:                    ex.printStackTrace();
130:                    throw (Exception) ex.getCause();
131:                }
132:            }
133:
134:            @Test
135:            public void testInOutHeader() throws Exception {
136:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
137:                assertNotNull(wsdl);
138:
139:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
140:                        serviceName);
141:                assertNotNull(service);
142:                TestHeader proxy = service.getPort(portName, TestHeader.class);
143:
144:                try {
145:                    TestHeader3 in = new TestHeader3();
146:                    String val = new String(TestHeader3.class.getSimpleName());
147:                    Holder<TestHeader3> inoutHeader = new Holder<TestHeader3>();
148:                    for (int idx = 0; idx < 2; idx++) {
149:                        val += idx;
150:                        in.setRequestType(val);
151:                        inoutHeader.value = new TestHeader3();
152:                        TestHeader3Response returnVal = proxy.testHeader3(in,
153:                                inoutHeader);
154:                        //inoutHeader copied to return
155:                        //in copied to inoutHeader
156:                        assertNotNull(returnVal);
157:                        assertNull(returnVal.getResponseType());
158:                        assertEquals(val, inoutHeader.value.getRequestType());
159:
160:                        in.setRequestType(null);
161:                        inoutHeader.value.setRequestType(val);
162:                        returnVal = proxy.testHeader3(in, inoutHeader);
163:                        assertNotNull(returnVal);
164:                        assertEquals(val, returnVal.getResponseType());
165:                        assertNull(inoutHeader.value.getRequestType());
166:                    }
167:                } catch (UndeclaredThrowableException ex) {
168:                    throw (Exception) ex.getCause();
169:                }
170:            }
171:
172:            @Test
173:            public void testReturnHeader() throws Exception {
174:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
175:                assertNotNull(wsdl);
176:
177:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
178:                        serviceName);
179:                assertNotNull(service);
180:                TestHeader proxy = service.getPort(portName, TestHeader.class);
181:                try {
182:                    Holder<TestHeader5ResponseBody> out = new Holder<TestHeader5ResponseBody>();
183:                    Holder<TestHeader5> outHeader = new Holder<TestHeader5>();
184:                    TestHeader5 in = new TestHeader5();
185:                    String val = new String(TestHeader5.class.getSimpleName());
186:                    for (int idx = 0; idx < 2; idx++) {
187:                        val += idx;
188:                        in.setRequestType(val);
189:                        proxy.testHeader5(out, outHeader, in);
190:                        assertEquals(1000, out.value.getResponseType());
191:                        assertEquals(val, outHeader.value.getRequestType());
192:                    }
193:                } catch (UndeclaredThrowableException ex) {
194:                    throw (Exception) ex.getCause();
195:                }
196:            }
197:
198:            @Test
199:            public void testHeaderPartBeforeBodyPart() throws Exception {
200:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
201:                assertNotNull(wsdl);
202:
203:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
204:                        serviceName);
205:                assertNotNull(service);
206:                TestHeader proxy = service.getPort(portName, TestHeader.class);
207:
208:                TestHeader6 in = new TestHeader6();
209:                String val = new String(TestHeader6.class.getSimpleName());
210:                Holder<TestHeader3> inoutHeader = new Holder<TestHeader3>();
211:                for (int idx = 0; idx < 1; idx++) {
212:                    val += idx;
213:                    in.setRequestType(val);
214:                    inoutHeader.value = new TestHeader3();
215:                    TestHeader6Response returnVal = proxy
216:                            .testHeaderPartBeforeBodyPart(inoutHeader, in);
217:                    //inoutHeader copied to return
218:                    //in copied to inoutHeader
219:                    assertNotNull(returnVal);
220:                    assertNull(returnVal.getResponseType());
221:                    assertEquals(val, inoutHeader.value.getRequestType());
222:
223:                    in.setRequestType(null);
224:                    inoutHeader.value.setRequestType(val);
225:                    returnVal = proxy.testHeaderPartBeforeBodyPart(inoutHeader,
226:                            in);
227:                    assertNotNull(returnVal);
228:                    assertEquals(val, returnVal.getResponseType());
229:                    assertNull(inoutHeader.value.getRequestType());
230:                }
231:            }
232:
233:            @Test
234:            public void testHeader4() {
235:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
236:                assertNotNull(wsdl);
237:
238:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
239:                        serviceName);
240:                assertNotNull(service);
241:                TestHeader proxy = service.getPort(portName, TestHeader.class);
242:                try {
243:                    proxy.testHeader4("cxf");
244:                } catch (Exception e) {
245:                    // REVISIT
246:                    // fail("No exception should happen in testHeader4");
247:                }
248:            }
249:
250:            @Test
251:            public void testRPCInHeader() throws Exception {
252:                URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
253:                assertNotNull(wsdl);
254:
255:                SOAPRPCHeaderService service = new SOAPRPCHeaderService(wsdl,
256:                        new QName("http://apache.org/header_test/rpc",
257:                                "SOAPRPCHeaderService"));
258:                assertNotNull(service);
259:                TestRPCHeader proxy = service.getSoapRPCHeaderPort();
260:                try {
261:                    HeaderMessage header = new HeaderMessage();
262:                    header.setHeaderVal("header");
263:
264:                    for (int idx = 0; idx < 2; idx++) {
265:                        String returnVal = proxy.testHeader1("part", header);
266:                        assertNotNull(returnVal);
267:                        assertEquals("part/header", returnVal);
268:                    }
269:                } catch (UndeclaredThrowableException ex) {
270:                    throw (Exception) ex.getCause();
271:                }
272:            }
273:
274:            @Test
275:            public void testRPCInOutHeader() throws Exception {
276:                URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
277:                assertNotNull(wsdl);
278:
279:                SOAPRPCHeaderService service = new SOAPRPCHeaderService(wsdl,
280:                        new QName("http://apache.org/header_test/rpc",
281:                                "SOAPRPCHeaderService"));
282:                assertNotNull(service);
283:                TestRPCHeader proxy = service.getSoapRPCHeaderPort();
284:                try {
285:                    HeaderMessage header = new HeaderMessage();
286:                    Holder<HeaderMessage> holder = new Holder<HeaderMessage>(
287:                            header);
288:
289:                    for (int idx = 0; idx < 2; idx++) {
290:                        holder.value.setHeaderVal("header" + idx);
291:                        String returnVal = proxy.testInOutHeader("part" + idx,
292:                                holder);
293:
294:                        assertNotNull(returnVal);
295:                        assertEquals("header" + idx, returnVal);
296:                        assertEquals("part" + idx, holder.value.getHeaderVal());
297:                    }
298:                } catch (UndeclaredThrowableException ex) {
299:                    throw (Exception) ex.getCause();
300:                }
301:            }
302:
303:            @Test
304:            public void testHolderOutIsTheFirstMessagePart() throws Exception {
305:                URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
306:                assertNotNull(wsdl);
307:                SOAPHeaderService service = new SOAPHeaderService(wsdl,
308:                        serviceName);
309:                assertNotNull(service);
310:                TestHeader proxy = service.getPort(portName, TestHeader.class);
311:                Holder<SimpleAll> simpleAll = new Holder<SimpleAll>();
312:                SimpleAll sa = new SimpleAll();
313:                sa.setVarAttrString("varAttrString");
314:                sa.setVarInt(100);
315:                sa.setVarString("varString");
316:                simpleAll.value = sa;
317:                SimpleChoice sc = new SimpleChoice();
318:                sc.setVarString("scVarString");
319:                SimpleStruct ss = proxy.sendReceiveAnyType(simpleAll, sc);
320:                assertEquals(simpleAll.value.getVarString(), "scVarString");
321:                assertEquals(ss.getVarInt(), 200);
322:                assertEquals(ss.getVarAttrString(), "varAttrStringRet");
323:            }
324:
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.