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.handlers;
19:
20: import java.lang.reflect.UndeclaredThrowableException;
21:
22: import javax.xml.ws.Endpoint;
23:
24: import org.apache.cxf.greeter_control.Greeter;
25: import org.apache.cxf.greeter_control.GreeterService;
26: import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
27: import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
28: import org.junit.BeforeClass;
29: import org.junit.Test;
30:
31: /**
32: * Tests the use of a SOAPHandler which does not use the underlying SOAP message but simply
33: * returns true instead.
34: */
35: public class TrivialSOAPHandlerTest extends
36: AbstractClientServerTestBase {
37:
38: public static class Server extends AbstractBusTestServerBase {
39:
40: protected void run() {
41: Object implementor = new TrivialSOAPHandlerAnnotatedGreeterImpl();
42: String address = "http://localhost:9020/SoapContext/GreeterPort";
43: Endpoint.publish(address, implementor);
44: }
45:
46: public static void main(String[] args) {
47: try {
48: Server s = new Server();
49: s.start();
50: } catch (Exception ex) {
51: ex.printStackTrace();
52: System.exit(-1);
53: } finally {
54: System.out.println("done!");
55: }
56: }
57: }
58:
59: @BeforeClass
60: public static void startServers() throws Exception {
61: assertTrue("server did not launch correctly",
62: launchServer(Server.class));
63: }
64:
65: @Test
66: public void testInvocation() throws Exception {
67:
68: GreeterService service = new GreeterService();
69: assertNotNull(service);
70:
71: try {
72: Greeter greeter = service.getGreeterPort();
73:
74: String greeting = greeter.greetMe("Bonjour");
75: assertNotNull("no response received from service", greeting);
76: assertEquals("BONJOUR", greeting);
77:
78: } catch (UndeclaredThrowableException ex) {
79: throw (Exception) ex.getCause();
80: }
81: }
82:
83: }
|