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.callback;
19:
20: import java.net.URL;
21:
22: import javax.xml.namespace.QName;
23: import javax.xml.ws.Endpoint;
24:
25: import org.apache.callback.SOAPService;
26: import org.apache.callback.ServerPortType;
27:
28: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
29:
30: import org.apache.cxf.ws.addressing.EndpointReferenceType;
31: import org.apache.cxf.wsdl.EndpointReferenceUtils;
32: import org.junit.BeforeClass;
33: import org.junit.Test;
34:
35: public class CallbackClientServerTest extends
36: AbstractBusClientServerTestBase {
37: private static final QName SERVICE_NAME = new QName(
38: "http://apache.org/callback", "SOAPService");
39: private static final QName SERVICE_NAME_CALLBACK = new QName(
40: "http://apache.org/callback", "CallbackService");
41:
42: private static final QName PORT_NAME = new QName(
43: "http://apache.org/callback", "SOAPPort");
44:
45: private static final QName PORT_NAME_CALLBACK = new QName(
46: "http://apache.org/callback", "CallbackPort");
47:
48: private static final QName PORT_TYPE_CALLBACK = new QName(
49: "http://apache.org/callback", "CallbackPortType");
50:
51: @BeforeClass
52: public static void startServers() throws Exception {
53: assertTrue("server did not launch correctly",
54: launchServer(Server.class));
55: }
56:
57: @Test
58: public void testCallback() throws Exception {
59:
60: Object implementor = new CallbackImpl();
61: String address = "http://localhost:9005/CallbackContext/CallbackPort";
62: Endpoint.publish(address, implementor);
63:
64: URL wsdlURL = getClass().getResource(
65: "/wsdl/basic_callback_test.wsdl");
66:
67: SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
68: ServerPortType port = ss.getPort(PORT_NAME,
69: ServerPortType.class);
70:
71: EndpointReferenceType ref = null;
72: try {
73: ref = EndpointReferenceUtils.getEndpointReference(wsdlURL,
74: SERVICE_NAME_CALLBACK, PORT_NAME_CALLBACK
75: .getLocalPart());
76: EndpointReferenceUtils.setInterfaceName(ref,
77: PORT_TYPE_CALLBACK);
78: } catch (Exception e) {
79: e.printStackTrace();
80: }
81:
82: String resp = port.registerCallback(ref);
83:
84: assertEquals("registerCallback called", resp);
85:
86: }
87:
88: }
|