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.io.InputStream;
21: import java.net.URL;
22:
23: import javax.xml.namespace.QName;
24: import javax.xml.transform.dom.DOMSource;
25: import javax.xml.ws.Dispatch;
26: import javax.xml.ws.Service;
27:
28: import org.w3c.dom.Document;
29: import org.w3c.dom.Node;
30:
31: import org.apache.cxf.helpers.XMLUtils;
32: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
33: import org.apache.hello_world_xml_http.wrapped.XMLService;
34: import org.junit.BeforeClass;
35: import org.junit.Test;
36:
37: public class ProviderXMLClientServerTest extends
38: AbstractBusClientServerTestBase {
39: private final QName serviceName = new QName(
40: "http://apache.org/hello_world_xml_http/wrapped",
41: "XMLService");
42:
43: private final QName portName = new QName(
44: "http://apache.org/hello_world_xml_http/wrapped",
45: "XMLProviderPort");
46:
47: @BeforeClass
48: public static void startServers() throws Exception {
49: assertTrue("server did not launch correctly",
50: launchServer(XMLServer.class));
51: }
52:
53: @Test
54: public void testDOMSourcePAYLOAD() throws Exception {
55: URL wsdl = getClass().getResource(
56: "/wsdl/hello_world_xml_wrapped.wsdl");
57: assertNotNull(wsdl);
58:
59: XMLService service = new XMLService(wsdl, serviceName);
60: assertNotNull(service);
61:
62: InputStream is = getClass().getResourceAsStream(
63: "/messages/XML_GreetMeDocLiteralReq.xml");
64: Document doc = XMLUtils.parse(is);
65: DOMSource reqMsg = new DOMSource(doc);
66: assertNotNull(reqMsg);
67:
68: Dispatch<DOMSource> disp = service.createDispatch(portName,
69: DOMSource.class, Service.Mode.PAYLOAD);
70: DOMSource result = disp.invoke(reqMsg);
71: assertNotNull(result);
72:
73: Node respDoc = result.getNode();
74: assertEquals("greetMeResponse", respDoc.getFirstChild()
75: .getLocalName());
76: assertEquals("TestXMLBindingProviderMessage", respDoc
77: .getFirstChild().getTextContent());
78: }
79:
80: }
|