001: package org.objectweb.celtix.systest.provider;
002:
003: import java.lang.reflect.UndeclaredThrowableException;
004: import java.net.URL;
005: import javax.xml.namespace.QName;
006:
007: import junit.framework.Test;
008: import junit.framework.TestSuite;
009:
010: import org.objectweb.celtix.systest.common.ClientServerSetupBase;
011: import org.objectweb.celtix.systest.common.ClientServerTestBase;
012:
013: import org.objectweb.hello_world_rpclit.GreeterRPCLit;
014: import org.objectweb.hello_world_rpclit.SOAPServiceRPCLit;
015:
016: public class ProviderClientServerTest extends ClientServerTestBase {
017:
018: public static Test suite() throws Exception {
019: TestSuite suite = new TestSuite(ProviderClientServerTest.class);
020: return new ClientServerSetupBase(suite) {
021: public void startServers() throws Exception {
022: assertTrue("server did not launch correctly",
023: launchServer(Server.class));
024: }
025: };
026: }
027:
028: public void testMessageModeWithSOAPMessageData() throws Exception {
029:
030: QName serviceName = new QName(
031: "http://objectweb.org/hello_world_rpclit",
032: "SOAPServiceRPCLit");
033: QName portName = new QName(
034: "http://objectweb.org/hello_world_rpclit",
035: "SoapPortRPCLit");
036:
037: URL wsdl = getClass().getResource(
038: "/wsdl/hello_world_rpc_lit.wsdl");
039: assertNotNull(wsdl);
040:
041: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
042: serviceName);
043: assertNotNull(service);
044:
045: String response1 = new String("TestGreetMeResponse");
046: String response2 = new String("TestSayHiResponse");
047: try {
048: GreeterRPCLit greeter = service.getPort(portName,
049: GreeterRPCLit.class);
050: for (int idx = 0; idx < 2; idx++) {
051: String greeting = greeter.greetMe("Milestone-" + idx);
052: assertNotNull("no response received from service",
053: greeting);
054: assertEquals(response1, greeting);
055:
056: String reply = greeter.sayHi();
057: assertNotNull("no response received from service",
058: reply);
059: assertEquals(response2, reply);
060: }
061: } catch (UndeclaredThrowableException ex) {
062: throw (Exception) ex.getCause();
063: }
064: }
065:
066: public void testMessageModeWithDOMSourceData() throws Exception {
067: QName serviceName = new QName(
068: "http://objectweb.org/hello_world_rpclit",
069: "SOAPServiceRPCLit1");
070: QName portName = new QName(
071: "http://objectweb.org/hello_world_rpclit",
072: "SoapPortRPCLit1");
073:
074: URL wsdl = getClass().getResource(
075: "/wsdl/hello_world_rpc_lit.wsdl");
076: assertNotNull(wsdl);
077:
078: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
079: serviceName);
080: assertNotNull(service);
081:
082: String response1 = new String("TestGreetMeResponse");
083: String response2 = new String("TestSayHiResponse");
084: try {
085: GreeterRPCLit greeter = service.getPort(portName,
086: GreeterRPCLit.class);
087: for (int idx = 0; idx < 2; idx++) {
088: String greeting = greeter.greetMe("Milestone-" + idx);
089: assertNotNull("no response received from service",
090: greeting);
091: assertEquals(response1, greeting);
092:
093: String reply = greeter.sayHi();
094: assertNotNull("no response received from service",
095: reply);
096: assertEquals(response2, reply);
097: }
098: } catch (UndeclaredThrowableException ex) {
099: throw (Exception) ex.getCause();
100: }
101: }
102:
103: public void testPayloadModeWithDOMSourceData() throws Exception {
104: URL wsdl = getClass().getResource(
105: "/wsdl/hello_world_rpc_lit.wsdl");
106: assertNotNull(wsdl);
107:
108: QName serviceName = new QName(
109: "http://objectweb.org/hello_world_rpclit",
110: "SOAPServiceRPCLit2");
111: QName portName = new QName(
112: "http://objectweb.org/hello_world_rpclit",
113: "SoapPortRPCLit2");
114:
115: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
116: serviceName);
117: assertNotNull(service);
118:
119: String response1 = new String("TestGreetMeResponse");
120: String response2 = new String("TestSayHiResponse");
121: try {
122: GreeterRPCLit greeter = service.getPort(portName,
123: GreeterRPCLit.class);
124: for (int idx = 0; idx < 1; idx++) {
125: String greeting = greeter.greetMe("Milestone-" + idx);
126: assertNotNull("no response received from service",
127: greeting);
128: assertEquals(response1, greeting);
129:
130: String reply = greeter.sayHi();
131: assertNotNull("no response received from service",
132: reply);
133: assertEquals(response2, reply);
134: }
135: } catch (UndeclaredThrowableException ex) {
136: throw (Exception) ex.getCause();
137: }
138: }
139:
140: public void testMessageModeWithSAXSourceData() throws Exception {
141: URL wsdl = getClass().getResource(
142: "/wsdl/hello_world_rpc_lit.wsdl");
143: assertNotNull(wsdl);
144:
145: QName serviceName = new QName(
146: "http://objectweb.org/hello_world_rpclit",
147: "SOAPServiceRPCLit3");
148: QName portName = new QName(
149: "http://objectweb.org/hello_world_rpclit",
150: "SoapPortRPCLit3");
151:
152: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
153: serviceName);
154: assertNotNull(service);
155:
156: String response1 = new String("TestGreetMeResponse");
157: String response2 = new String("TestSayHiResponse");
158: try {
159: GreeterRPCLit greeter = service.getPort(portName,
160: GreeterRPCLit.class);
161: for (int idx = 0; idx < 1; idx++) {
162: String greeting = greeter.greetMe("Milestone-" + idx);
163: assertNotNull("no response received from service",
164: greeting);
165: assertEquals(response1, greeting);
166:
167: String reply = greeter.sayHi();
168: assertNotNull("no response received from service",
169: reply);
170: assertEquals(response2, reply);
171: }
172: } catch (UndeclaredThrowableException ex) {
173: throw (Exception) ex.getCause();
174: }
175: }
176:
177: public void testMessageModeWithStreamSourceData() throws Exception {
178: URL wsdl = getClass().getResource(
179: "/wsdl/hello_world_rpc_lit.wsdl");
180: assertNotNull(wsdl);
181:
182: QName serviceName = new QName(
183: "http://objectweb.org/hello_world_rpclit",
184: "SOAPServiceRPCLit4");
185: QName portName = new QName(
186: "http://objectweb.org/hello_world_rpclit",
187: "SoapPortRPCLit4");
188:
189: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
190: serviceName);
191: assertNotNull(service);
192:
193: String response1 = new String("TestGreetMeResponse");
194: String response2 = new String("TestSayHiResponse");
195: try {
196: GreeterRPCLit greeter = service.getPort(portName,
197: GreeterRPCLit.class);
198: for (int idx = 0; idx < 1; idx++) {
199: String greeting = greeter.greetMe("Milestone-" + idx);
200: assertNotNull("no response received from service",
201: greeting);
202: assertEquals(response1, greeting);
203:
204: String reply = greeter.sayHi();
205: assertNotNull("no response received from service",
206: reply);
207: assertEquals(response2, reply);
208: }
209: } catch (UndeclaredThrowableException ex) {
210: throw (Exception) ex.getCause();
211: }
212: }
213:
214: public void testPayloadModeWithSAXSourceData() throws Exception {
215: URL wsdl = getClass().getResource(
216: "/wsdl/hello_world_rpc_lit.wsdl");
217: assertNotNull(wsdl);
218:
219: QName serviceName = new QName(
220: "http://objectweb.org/hello_world_rpclit",
221: "SOAPServiceRPCLit5");
222: QName portName = new QName(
223: "http://objectweb.org/hello_world_rpclit",
224: "SoapPortRPCLit5");
225:
226: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
227: serviceName);
228: assertNotNull(service);
229:
230: String response1 = new String("TestGreetMeResponse");
231: String response2 = new String("TestSayHiResponse");
232: try {
233: GreeterRPCLit greeter = service.getPort(portName,
234: GreeterRPCLit.class);
235: for (int idx = 0; idx < 1; idx++) {
236: String greeting = greeter.greetMe("Milestone-" + idx);
237: assertNotNull("no response received from service",
238: greeting);
239: assertEquals(response1, greeting);
240:
241: String reply = greeter.sayHi();
242: assertNotNull("no response received from service",
243: reply);
244: assertEquals(response2, reply);
245: }
246: } catch (UndeclaredThrowableException ex) {
247: throw (Exception) ex.getCause();
248: }
249: }
250:
251: public void testPayloadModeWithStreamSourceData() throws Exception {
252: URL wsdl = getClass().getResource(
253: "/wsdl/hello_world_rpc_lit.wsdl");
254: assertNotNull(wsdl);
255:
256: QName serviceName = new QName(
257: "http://objectweb.org/hello_world_rpclit",
258: "SOAPServiceRPCLit6");
259: QName portName = new QName(
260: "http://objectweb.org/hello_world_rpclit",
261: "SoapPortRPCLit6");
262:
263: SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl,
264: serviceName);
265: assertNotNull(service);
266:
267: String response1 = new String("TestGreetMeResponse");
268: String response2 = new String("TestSayHiResponse");
269: try {
270: GreeterRPCLit greeter = service.getPort(portName,
271: GreeterRPCLit.class);
272: for (int idx = 0; idx < 1; idx++) {
273: String greeting = greeter.greetMe("Milestone-" + idx);
274: assertNotNull("no response received from service",
275: greeting);
276: assertEquals(response1, greeting);
277:
278: String reply = greeter.sayHi();
279: assertNotNull("no response received from service",
280: reply);
281: assertEquals(response2, reply);
282: }
283: } catch (UndeclaredThrowableException ex) {
284: throw (Exception) ex.getCause();
285: }
286: }
287:
288: public static void main(String[] args) {
289: junit.textui.TestRunner.run(ProviderClientServerTest.class);
290: }
291: }
|