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.js;
19:
20: import java.lang.reflect.UndeclaredThrowableException;
21: import java.net.URL;
22:
23: import javax.xml.namespace.QName;
24:
25: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
26: import org.apache.hello_world_soap_http.Greeter;
27: import org.apache.hello_world_soap_http.SOAPService;
28: import org.apache.hello_world_soap_http.SOAPServiceTest1;
29: import org.junit.BeforeClass;
30: import org.junit.Test;
31:
32: public class JSClientServerTest extends AbstractBusClientServerTestBase {
33:
34: private static final String NS = "http://apache.org/hello_world_soap_http";
35:
36: @BeforeClass
37: public static void startServers() throws Exception {
38: assertTrue("server did not launch correctly",
39: launchServer(Server.class));
40: }
41:
42: @Test
43: public void testJSMessageMode() throws Exception {
44: QName serviceName = new QName(NS, "SOAPService");
45: QName portName = new QName(NS, "SoapPort");
46:
47: URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
48: assertNotNull(wsdl);
49:
50: SOAPService service = new SOAPService(wsdl, serviceName);
51: assertNotNull(service);
52:
53: String response1 = new String("TestGreetMeResponse");
54: String response2 = new String("TestSayHiResponse");
55: try {
56: Greeter greeter = service.getPort(portName, Greeter.class);
57: String greeting = greeter.greetMe("TestGreetMeRequest");
58: assertNotNull("no response received from service", greeting);
59: assertEquals(response1, greeting);
60:
61: String reply = greeter.sayHi();
62: assertNotNull("no response received from service", reply);
63: assertEquals(response2, reply);
64: } catch (UndeclaredThrowableException ex) {
65: ex.printStackTrace();
66: throw (Exception) ex.getCause();
67: }
68: }
69:
70: @Test
71: public void testJSPayloadMode() throws Exception {
72: URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
73: assertNotNull(wsdl);
74:
75: QName serviceName = new QName(NS, "SOAPService_Test1");
76: QName portName = new QName(NS, "SoapPort_Test1");
77:
78: SOAPServiceTest1 service = new SOAPServiceTest1(wsdl,
79: serviceName);
80: assertNotNull(service);
81:
82: String response1 = new String("TestGreetMeResponse");
83: String response2 = new String("TestSayHiResponse");
84: try {
85: Greeter greeter = service.getPort(portName, Greeter.class);
86: String greeting = greeter.greetMe("TestGreetMeRequest");
87: assertNotNull("no response received from service", greeting);
88: assertEquals(response1, greeting);
89:
90: String reply = greeter.sayHi();
91: assertNotNull("no response received from service", reply);
92: assertEquals(response2, reply);
93: } catch (UndeclaredThrowableException ex) {
94: ex.printStackTrace();
95: throw (Exception) ex.getCause();
96: }
97: }
98:
99: }
|