Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BD5FF9991 for ; Thu, 27 Oct 2011 14:40:46 +0000 (UTC) Received: (qmail 87766 invoked by uid 500); 27 Oct 2011 14:40:46 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 87708 invoked by uid 500); 27 Oct 2011 14:40:46 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 87701 invoked by uid 99); 27 Oct 2011 14:40:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2011 14:40:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2011 14:40:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 891E123888FE for ; Thu, 27 Oct 2011 14:40:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1189786 - in /cxf/trunk/systests/databinding: ./ src/test/java/org/apache/cxf/systest/source/ src/test/resources/wsdl_systest_databinding/source/ Date: Thu, 27 Oct 2011 14:40:18 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111027144018.891E123888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Thu Oct 27 14:40:17 2011 New Revision: 1189786 URL: http://svn.apache.org/viewvc?rev=1189786&view=rev Log: [CXF-3885] Add system test for source databinding Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java (with props) cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java (with props) cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java (with props) cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java (with props) cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml (with props) cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/ cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl (with props) cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl (with props) Modified: cxf/trunk/systests/databinding/pom.xml Modified: cxf/trunk/systests/databinding/pom.xml URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/pom.xml?rev=1189786&r1=1189785&r2=1189786&view=diff ============================================================================== --- cxf/trunk/systests/databinding/pom.xml (original) +++ cxf/trunk/systests/databinding/pom.xml Thu Oct 27 14:40:17 2011 @@ -136,6 +136,20 @@ jibx + + ${basedir}/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl + + -db + domsource + + + + ${basedir}/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl + + -db + domsource + + Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java (added) +++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java Thu Oct 27 14:40:17 2011 @@ -0,0 +1,124 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.systest.source; + +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.transform.dom.DOMSource; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import org.apache.cxf.Bus; +import org.apache.cxf.BusFactory; +import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.frontend.ClientProxy; +import org.apache.cxf.helpers.DOMUtils; +import org.apache.cxf.helpers.XMLUtils; +import org.apache.cxf.interceptor.LoggingInInterceptor; +import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.cxf.testutil.common.TestUtil; +import org.apache.hello_world_soap_http_source.source.GreetMeFault; +import org.apache.hello_world_soap_http_source.source.Greeter; +import org.apache.hello_world_soap_http_source.source.SOAPService; + +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + */ +public class ClientServerSourceTest extends AbstractBusClientServerTestBase { + static final String WSDL_PORT = TestUtil.getPortNumber(Server.class); + + private static final QName SERVICE_NAME + = new QName("http://apache.org/hello_world_soap_http_source/source", "SOAPService"); + + + @BeforeClass + public static void startServers() throws Exception { + assertTrue("server did not launch correctly", launchServer(Server.class, true)); + } + + private Element getElement(Node nd) { + if (nd instanceof Document) { + return ((Document)nd).getDocumentElement(); + } + return (Element)nd; + } + + @Test + public void testCallFromClient() throws Exception { + SpringBusFactory factory = new SpringBusFactory(); + Bus bus = factory.createBus("org/apache/cxf/systest/source/cxf.xml"); + BusFactory.setDefaultBus(bus); + URL wsdl = this.getClass().getResource("/wsdl_systest_databinding/source/hello_world.wsdl"); + assertNotNull("We should have found the WSDL here. " , wsdl); + + SOAPService ss = new SOAPService(wsdl, SERVICE_NAME); + Greeter port = ss.getSoapPort(); + updateAddressPort(port, WSDL_PORT); + + ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); + ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); + + Document doc = XMLUtils.newDocument(); + doc.appendChild(doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:sayHi")); + DOMSource ds = new DOMSource(doc); + DOMSource resp = port.sayHi(ds); + assertEquals("We should get the right response", "Bonjour", + DOMUtils.getContent(getElement(resp.getNode()))); + + doc = XMLUtils.newDocument(); + Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:greetMe"); + Element el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:requestType"); + el2.appendChild(doc.createTextNode("Willem")); + el.appendChild(el2); + doc.appendChild(el); + ds = new DOMSource(doc); + resp = port.greetMe(ds); + assertEquals("We should get the right response", "Hello Willem", + DOMUtils.getContent(DOMUtils.getFirstElement(getElement(resp.getNode())))); + + try { + doc = XMLUtils.newDocument(); + el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:greetMe"); + el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:requestType"); + el2.appendChild(doc.createTextNode("fault")); + el.appendChild(el2); + doc.appendChild(el); + ds = new DOMSource(doc); + port.greetMe(ds); + fail("Should have been a fault"); + } catch (GreetMeFault ex) { + assertEquals("Some fault detail", DOMUtils.getContent(getElement(ex.getFaultInfo().getNode()))); + } + + } + +} Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java (added) +++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java Thu Oct 27 14:40:17 2011 @@ -0,0 +1,103 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.systest.source; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.dom.DOMSource; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import org.apache.cxf.helpers.DOMUtils; +import org.apache.cxf.helpers.XMLUtils; +import org.apache.hello_world_soap_http_source.source.GreetMeFault; +import org.apache.hello_world_soap_http_source.source.Greeter; +import org.apache.hello_world_soap_http_source.source.PingMeFault; + +@javax.jws.WebService(portName = "SoapPort", serviceName = "SOAPService", + targetNamespace = "http://apache.org/hello_world_soap_http_source/source", + endpointInterface = "org.apache.hello_world_soap_http_source.source.Greeter") +public class GreeterImpl implements Greeter { + + public void greetMeOneWay(DOMSource in) { + // TODO Auto-generated method stub + + } + + public DOMSource sayHi(DOMSource in) { + try { + Document doc = XMLUtils.newDocument(); + Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:sayHiResponse"); + el.appendChild(doc.createTextNode("Bonjour")); + doc.appendChild(el); + + return new DOMSource(doc); + } catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + } + private Element getElement(Node nd) { + if (nd instanceof Document) { + return ((Document)nd).getDocumentElement(); + } + return (Element)nd; + } + + public DOMSource greetMe(DOMSource in) throws GreetMeFault { + Element eval = getElement(in.getNode()); + eval = DOMUtils.getFirstElement(eval); + String val = DOMUtils.getContent(eval); + try { + if ("fault".equals(val)) { + Document doc = XMLUtils.newDocument(); + Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/" + + "source/types", + "ns1:greetMeFaultDetail"); + el.appendChild(doc.createTextNode("Some fault detail")); + doc.appendChild(el); + + throw new GreetMeFault("Fault String", new DOMSource(doc)); + } + + Document doc = XMLUtils.newDocument(); + Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:greetMeResponse"); + Element el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types", + "ns1:responseType"); + el2.appendChild(doc.createTextNode("Hello " + val)); + el.appendChild(el2); + + doc.appendChild(el); + + return new DOMSource(doc); + } catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + } + + public void pingMe() throws PingMeFault { + // TODO Auto-generated method stub + + } + + +} Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java (added) +++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java Thu Oct 27 14:40:17 2011 @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.systest.source; + +import javax.jws.WebService; +import javax.xml.transform.dom.DOMSource; +import javax.xml.ws.Holder; + +import org.apache.cxf.source.doc_lit_bare.PutLastTradedPricePortType; + +/** + * + */ +@WebService(targetNamespace = "http://cxf.apache.org/source/doc_lit_bare", + portName = "SoapPort", serviceName = "SOAPService", + endpointInterface = "org.apache.cxf.source.doc_lit_bare.PutLastTradedPricePortType" +) +public class PutLastTradePriceImpl implements PutLastTradedPricePortType { + + public DOMSource nillableParameter(DOMSource theRequest) { + // TODO Auto-generated method stub + return null; + } + + public void sayHi(Holder body) { + // TODO Auto-generated method stub + + } + + public void putLastTradedPrice(DOMSource body) { + // TODO Auto-generated method stub + + } + + public DOMSource bareNoParam() { + // TODO Auto-generated method stub + return null; + } + + +} Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/PutLastTradePriceImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java (added) +++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java Thu Oct 27 14:40:17 2011 @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.systest.source; + +import javax.xml.ws.Endpoint; + + +import org.apache.cxf.Bus; +import org.apache.cxf.BusFactory; +import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; + +public class Server extends AbstractBusTestServerBase { + static final String PORT = TestUtil.getPortNumber(Server.class); + + protected void run() { + // set the configuration file + SpringBusFactory factory = new SpringBusFactory(); + Bus bus = factory.createBus("org/apache/cxf/systest/source/cxf.xml"); + BusFactory.setDefaultBus(bus); + setBus(bus); + Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort", + new GreeterImpl()); + + Endpoint.publish("http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPort", + new PutLastTradePriceImpl()); + } + + public static void main(String args[]) { + try { + Server s = new Server(); + s.start(); + } catch (Exception ex) { + ex.printStackTrace(); + System.exit(-1); + } finally { + System.out.println("done!"); + } + } +} Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/Server.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml (added) +++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml Thu Oct 27 14:40:17 2011 @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/cxf.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl (added) +++ cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl Thu Oct 27 14:40:17 2011 @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/doc_lit_bare.wsdl ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl?rev=1189786&view=auto ============================================================================== --- cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl (added) +++ cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl Thu Oct 27 14:40:17 2011 @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/systests/databinding/src/test/resources/wsdl_systest_databinding/source/hello_world.wsdl ------------------------------------------------------------------------------ svn:mime-type = text/xml