01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.systest.provider;
19:
20: import java.lang.reflect.UndeclaredThrowableException;
21: import java.net.URL;
22:
23: import javax.xml.namespace.QName;
24: import javax.xml.ws.Endpoint;
25:
26: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
27: import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
28: import org.apache.hello_world_soap_http.Greeter;
29: import org.apache.hello_world_soap_http.SOAPService;
30: import org.junit.BeforeClass;
31: import org.junit.Test;
32:
33: public class ProviderClientServerTest extends
34: AbstractBusClientServerTestBase {
35: public static class Server extends AbstractBusTestServerBase {
36:
37: protected void run() {
38: Object implementor = new HWSoapMessageDocProvider();
39: String address = "http://localhost:9003/SoapContext/SoapProviderPort";
40: Endpoint.publish(address, implementor);
41: }
42:
43: public static void main(String[] args) {
44: try {
45: Server s = new Server();
46: s.start();
47: } catch (Exception ex) {
48: ex.printStackTrace();
49: System.exit(-1);
50: } finally {
51: System.out.println("done!");
52: }
53: }
54: }
55:
56: @BeforeClass
57: public static void startServers() throws Exception {
58: assertTrue("server did not launch correctly",
59: launchServer(Server.class));
60: }
61:
62: @Test
63: public void testSOAPMessageModeDocLit() throws Exception {
64:
65: QName serviceName = new QName(
66: "http://apache.org/hello_world_soap_http",
67: "SOAPProviderService");
68: QName portName = new QName(
69: "http://apache.org/hello_world_soap_http",
70: "SoapProviderPort");
71:
72: URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
73: assertNotNull(wsdl);
74:
75: SOAPService service = new SOAPService(wsdl, serviceName);
76: assertNotNull(service);
77:
78: String response1 = new String("TestSOAPOutputPMessage");
79: String response2 = new String("Bonjour");
80: try {
81: Greeter greeter = service.getPort(portName, Greeter.class);
82: for (int idx = 0; idx < 2; idx++) {
83: String greeting = greeter.greetMe("Milestone-" + idx);
84: assertNotNull("no response received from service",
85: greeting);
86: assertEquals(response1, greeting);
87:
88: String reply = greeter.sayHi();
89: assertNotNull("no response received from service",
90: reply);
91: assertEquals(response2, reply);
92: }
93: } catch (UndeclaredThrowableException ex) {
94: throw (Exception) ex.getCause();
95: }
96: }
97:
98: }
|