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.jaxws;
19:
20: import java.net.URL;
21:
22: import org.w3c.dom.Node;
23:
24: import org.apache.cxf.frontend.ServerFactoryBean;
25: import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
26: import org.apache.cxf.service.Service;
27: import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
28: import org.apache.cxf.service.invoker.BeanInvoker;
29: import org.apache.cxf.transport.local.LocalTransportFactory;
30: import org.apache.hello_world_soap_http.GreeterImpl;
31: import org.junit.Test;
32:
33: public class GreeterTest extends AbstractJaxWsTest {
34:
35: @Test
36: public void testEndpoint() throws Exception {
37: ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
38: URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
39: assertNotNull(resource);
40: bean.setWsdlURL(resource.toString());
41: bean.setBus(bus);
42: bean.setServiceClass(GreeterImpl.class);
43: GreeterImpl greeter = new GreeterImpl();
44: BeanInvoker invoker = new BeanInvoker(greeter);
45: bean.setInvoker(invoker);
46:
47: Service service = bean.create();
48:
49: assertEquals("SOAPService", service.getName().getLocalPart());
50: assertEquals("http://apache.org/hello_world_soap_http", service
51: .getName().getNamespaceURI());
52:
53: ServerFactoryBean svr = new ServerFactoryBean();
54: svr.setBus(bus);
55: svr.setServiceFactory(bean);
56:
57: svr.create();
58:
59: Node response = invoke(
60: "http://localhost:9000/SoapContext/SoapPort",
61: LocalTransportFactory.TRANSPORT_ID,
62: "GreeterMessage.xml");
63:
64: assertEquals(1, greeter.getInvocationCount());
65:
66: assertNotNull(response);
67:
68: addNamespace("h",
69: "http://apache.org/hello_world_soap_http/types");
70:
71: assertValid("/s:Envelope/s:Body", response);
72: assertValid("//h:sayHiResponse", response);
73: }
74: }
|