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.systest.provider;
019:
020: import java.lang.reflect.UndeclaredThrowableException;
021: import java.net.URL;
022:
023: import javax.xml.namespace.QName;
024:
025: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
026: import org.apache.hello_world_rpclit.GreeterRPCLit;
027: import org.apache.hello_world_rpclit.SOAPServiceRPCLit;
028: import org.junit.BeforeClass;
029: import org.junit.Test;
030:
031: public class ProviderRPCClientServerTest extends
032: AbstractBusClientServerTestBase {
033:
034: @BeforeClass
035: public static void startServers() throws Exception {
036: assertTrue("server did not launch correctly",
037: launchServer(Server.class));
038: }
039:
040: private void doGreeterRPCLit(SOAPServiceRPCLit service,
041: QName portName, int count) throws Exception {
042: String response1 = new String("TestGreetMeResponse");
043: String response2 = new String("TestSayHiResponse");
044: try {
045: GreeterRPCLit greeter = service.getPort(portName,
046: GreeterRPCLit.class);
047: for (int idx = 0; idx < count; idx++) {
048: String greeting = greeter.greetMe("Milestone-" + idx);
049: assertNotNull("no response received from service",
050: greeting);
051: assertEquals(response1, greeting);
052:
053: String reply = greeter.sayHi();
054: assertNotNull("no response received from service",
055: reply);
056: assertEquals(response2, reply);
057: }
058: } catch (UndeclaredThrowableException ex) {
059: throw (Exception) ex.getCause();
060: }
061: }
062:
063: @Test
064: public void testSOAPMessageModeRPC() throws Exception {
065:
066: QName serviceName = new QName(
067: "http://apache.org/hello_world_rpclit",
068: "SOAPServiceProviderRPCLit");
069: QName portName = new QName(
070: "http://apache.org/hello_world_rpclit",
071: "SoapPortProviderRPCLit1");
072:
073: URL wsdl = getClass().getResource(
074: "/wsdl/hello_world_rpc_lit.wsdl");
075: assertNotNull(wsdl);
076:
077: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
078: serviceName);
079: assertNotNull(service);
080:
081: doGreeterRPCLit(service, portName, 2);
082: }
083:
084: @Test
085: public void testSOAPMessageModeWithDOMSourceData() throws Exception {
086: QName serviceName = new QName(
087: "http://apache.org/hello_world_rpclit",
088: "SOAPServiceProviderRPCLit");
089: QName portName = new QName(
090: "http://apache.org/hello_world_rpclit",
091: "SoapPortProviderRPCLit2");
092:
093: URL wsdl = getClass().getResource(
094: "/wsdl/hello_world_rpc_lit.wsdl");
095: assertNotNull(wsdl);
096:
097: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
098: serviceName);
099: assertNotNull(service);
100:
101: doGreeterRPCLit(service, portName, 2);
102: }
103:
104: @Test
105: public void testPayloadModeWithDOMSourceData() throws Exception {
106: URL wsdl = getClass().getResource(
107: "/wsdl/hello_world_rpc_lit.wsdl");
108: assertNotNull(wsdl);
109:
110: QName serviceName = new QName(
111: "http://apache.org/hello_world_rpclit",
112: "SOAPServiceProviderRPCLit");
113: QName portName = new QName(
114: "http://apache.org/hello_world_rpclit",
115: "SoapPortProviderRPCLit3");
116:
117: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
118: serviceName);
119: assertNotNull(service);
120:
121: doGreeterRPCLit(service, portName, 1);
122: }
123:
124: @Test
125: public void testPayloadModeWithSourceData() throws Exception {
126: URL wsdl = getClass().getResource(
127: "/wsdl/hello_world_rpc_lit.wsdl");
128: assertNotNull(wsdl);
129:
130: QName serviceName = new QName(
131: "http://apache.org/hello_world_rpclit",
132: "SOAPServiceProviderRPCLit");
133: QName portName = new QName(
134: "http://apache.org/hello_world_rpclit",
135: "SoapPortProviderRPCLit8");
136:
137: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
138: serviceName);
139: assertNotNull(service);
140:
141: String response1 = new String(
142: "TestGreetMeResponseServerLogicalHandlerServerSOAPHandler");
143: try {
144: GreeterRPCLit greeter = service.getPort(portName,
145: GreeterRPCLit.class);
146: String greeting = greeter.greetMe("Milestone-0");
147: assertNotNull("no response received from service", greeting);
148: assertEquals(response1, greeting);
149: } catch (UndeclaredThrowableException ex) {
150: throw (Exception) ex.getCause();
151: }
152:
153: }
154:
155: @Test
156: public void testMessageModeWithSAXSourceData() throws Exception {
157: URL wsdl = getClass().getResource(
158: "/wsdl/hello_world_rpc_lit.wsdl");
159: assertNotNull(wsdl);
160:
161: QName serviceName = new QName(
162: "http://apache.org/hello_world_rpclit",
163: "SOAPServiceProviderRPCLit");
164: QName portName = new QName(
165: "http://apache.org/hello_world_rpclit",
166: "SoapPortProviderRPCLit4");
167:
168: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
169: serviceName);
170: assertNotNull(service);
171:
172: doGreeterRPCLit(service, portName, 1);
173: }
174:
175: @Test
176: public void testMessageModeWithStreamSourceData() throws Exception {
177: URL wsdl = getClass().getResource(
178: "/wsdl/hello_world_rpc_lit.wsdl");
179: assertNotNull(wsdl);
180:
181: QName serviceName = new QName(
182: "http://apache.org/hello_world_rpclit",
183: "SOAPServiceProviderRPCLit");
184: QName portName = new QName(
185: "http://apache.org/hello_world_rpclit",
186: "SoapPortProviderRPCLit5");
187:
188: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
189: serviceName);
190: assertNotNull(service);
191:
192: doGreeterRPCLit(service, portName, 1);
193: }
194:
195: @Test
196: public void testPayloadModeWithSAXSourceData() throws Exception {
197: URL wsdl = getClass().getResource(
198: "/wsdl/hello_world_rpc_lit.wsdl");
199: assertNotNull(wsdl);
200:
201: QName serviceName = new QName(
202: "http://apache.org/hello_world_rpclit",
203: "SOAPServiceProviderRPCLit");
204: QName portName = new QName(
205: "http://apache.org/hello_world_rpclit",
206: "SoapPortProviderRPCLit6");
207:
208: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
209: serviceName);
210: assertNotNull(service);
211:
212: doGreeterRPCLit(service, portName, 1);
213: }
214:
215: }
|