You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2008/11/03 15:56:59 UTC
svn commit: r710076 - in /cxf/trunk:
rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/
rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/
testutils/src/main/resources/wsdl/
Author: seanoc
Date: Mon Nov 3 06:56:59 2008
New Revision: 710076
URL: http://svn.apache.org/viewvc?rev=710076&view=rev
Log:
Added test of xmlbeans data binding
Added:
cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMine.java
cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMineImpl.java
cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/XmlBeansTest.java
cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf.xml
cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf2.xml
cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/xmlbeanstest.wsdl
cxf/trunk/testutils/src/main/resources/wsdl/xmlbeanstest.wsdl
Modified:
cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java?rev=710076&r1=710075&r2=710076&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java (original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java Mon Nov 3 06:56:59 2008
@@ -28,6 +28,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
@@ -169,11 +170,13 @@
mapClass(part, clazz);
}
private void mapClass(MessagePartInfo part, Class clazz) {
+
if (!XmlObject.class.isAssignableFrom(clazz)) {
Class<? extends XmlAnySimpleType> type = CLASS_MAP.get(clazz);
if (type == null) {
- System.out.println(clazz);
+ LOG.log(Level.SEVERE, clazz.getName() + " was not found in class map");
+ return;
}
SchemaTypeSystem sts = BuiltinSchemaTypeSystem.get();
SchemaType st2 = sts.typeForClassname(type.getName());
@@ -185,6 +188,7 @@
part.setXmlSchema(xmlSchema);
return;
}
+
try {
Field field = clazz.getField("type");
SchemaType st = (SchemaType)field.get(null);
Added: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMine.java?rev=710076&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMine.java (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMine.java Mon Nov 3 06:56:59 2008
@@ -0,0 +1,48 @@
+/**
+ * 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.xmlbeans;
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+//import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * This class was generated by Apache CXF 2.2-SNAPSHOT
+ * Tue Oct 21 11:29:37 BST 2008
+ * Generated source version: 2.2-SNAPSHOT
+ *
+ */
+
+@WebService(targetNamespace = "http://cxf.apache.org/xmlbeans", name = "GreeterMine")
+//@XmlSeeAlso({ObjectFactory.class })
+public interface GreeterMine {
+
+ @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+ @Oneway
+ @WebMethod(action = "sayHi2")
+ void sayHi2(
+ @WebParam(partName = "in", name = "sayHi2",
+ targetNamespace = "http://cxf.apache.org/xmlbeans")
+ StringListType in
+ );
+}
Added: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMineImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMineImpl.java?rev=710076&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMineImpl.java (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/GreeterMineImpl.java Mon Nov 3 06:56:59 2008
@@ -0,0 +1,45 @@
+/**
+ * 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.xmlbeans;
+
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+
+@WebService(endpointInterface = "org.apache.cxf.xmlbeans.GreeterMine",
+ targetNamespace = "http://org.apache.cxf/xmlbeans",
+ portName = "SoapPort",
+ serviceName = "SOAPMineService",
+ name = "GreeterMine")
+@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING)
+public class GreeterMineImpl implements GreeterMine {
+
+/*
+ public String sayHi() {
+ System.out.println("****** Executing the operation sayHi *****");
+ return "Bonjour";
+ }
+*/
+ public void sayHi2(StringListType stringList) {
+ System.out.println("****** Executing the operation sayHi2 *****");
+ }
+
+
+
+}
Added: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/XmlBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/XmlBeansTest.java?rev=710076&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/XmlBeansTest.java (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/XmlBeansTest.java Mon Nov 3 06:56:59 2008
@@ -0,0 +1,96 @@
+/**
+ * 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.xmlbeans;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.test.AbstractCXFTest;
+
+import org.junit.After;
+import org.junit.Before;
+//import org.junit.Ignore;
+import org.junit.Test;
+
+public class XmlBeansTest extends AbstractCXFTest {
+
+ private static final String CONFIG1 = "org/apache/cxf/xmlbeans/cxf.xml";
+ private static final String CONFIG2 = "org/apache/cxf/xmlbeans/cxf2.xml";
+ private static final String ERROR_MSG = "Service class org.apache.cxf.xmlbeans.GreeterMine method "
+ + "sayHi2 part {http://cxf.apache.org/xmlbeans}in cannot be mapped to schema";
+ private static final String ERROR_MSG2 = "Could not send Message";
+ private SpringBusFactory bf;
+
+ @Before
+ public void setUp() throws Exception {
+ bf = new SpringBusFactory();
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (bus != null) {
+ bus.shutdown(false);
+ bus = null;
+ }
+ BusFactory.setDefaultBus(null);
+ }
+
+
+ @Test
+ public void testBusCreationFails() throws Exception {
+ try {
+ bf = new SpringBusFactory();
+ bus = bf.createBus(CONFIG1);
+ BusFactory.setDefaultBus(bus);
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().contains(ERROR_MSG));
+ }
+ }
+
+ @Test
+ public void testBasicFails() throws Exception {
+
+ try {
+ bf = new SpringBusFactory();
+ bus = bf.createBus(CONFIG2);
+ BusFactory.setDefaultBus(bus);
+ URL wsdlURL = XmlBeansTest.class.getResource("xmlbeanstest.wsdl");
+ SOAPMineService ss =
+ new SOAPMineService(wsdlURL,
+ new QName("http://cxf.apache.org/xmlbeans", "SOAPMineService"));
+ GreeterMine port = ss.getSoapPort();
+
+ StringListType stringListType = new StringListType();
+ stringListType.setMyname("sean");
+ stringListType.setMyaddress("home");
+ port.sayHi2(stringListType);
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().contains(ERROR_MSG2));
+ //ex.printStackTrace();
+ }
+ }
+
+
+
+}
Added: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf.xml?rev=710076&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf.xml (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf.xml Mon Nov 3 06:56:59 2008
@@ -0,0 +1,36 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+
+ <bean id="GreeterImpl"
+ class="org.apache.cxf.xmlbeans.GreeterMineImpl"
+ scope="prototype" />
+
+ <!--bean id="xmlBeansBean"
+ class="org.apache.cxf.jaxb.JAXBDataBinding"
+ scope="prototype" /-->
+
+ <bean id="xmlBeansBean"
+ class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"
+ scope="prototype"/>
+
+ <bean id="testServiceFactory"
+ class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
+ scope="singleton">
+ <property name="dataBinding" ref="xmlBeansBean" />
+ </bean>
+
+ <jaxws:endpoint id="greeterMineEndpoint"
+ address="http://localhost:9000/SoapContext/SoapPort"
+ implementor="org.apache.cxf.xmlbeans.GreeterMineImpl"
+ serviceName="ns:SOAPMineService"
+ xmlns:ns="http://cxf.apache.org/xmlbeans">
+ <jaxws:serviceFactory>
+ <ref bean="testServiceFactory"/>
+ </jaxws:serviceFactory>
+ </jaxws:endpoint>
+</beans>
Added: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf2.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf2.xml?rev=710076&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf2.xml (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/cxf2.xml Mon Nov 3 06:56:59 2008
@@ -0,0 +1,37 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+
+ <bean id="GreeterImpl"
+ class="org.apache.cxf.xmlbeans.GreeterMineImpl"
+ scope="prototype" />
+
+ <!--bean id="xmlBeansBean"
+ class="org.apache.cxf.jaxb.JAXBDataBinding"
+ scope="prototype" /-->
+
+ <bean id="xmlBeansBean"
+ class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"
+ scope="prototype"/>
+
+ <bean id="testServiceFactory"
+ class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
+ scope="singleton">
+ <property name="dataBinding" ref="xmlBeansBean" />
+ </bean>
+
+ <jaxws:endpoint id="greeterMineEndpoint"
+ address="http://localhost:9000/SoapContext/SoapPort"
+ wsdlLocation="src/test/java/org/apache/cxf/xmlbeans/xmlbeanstest.wsdl"
+ implementor="org.apache.cxf.xmlbeans.GreeterMineImpl"
+ serviceName="ns:SOAPMineService"
+ xmlns:ns="http://cxf.apache.org/xmlbeans">
+ <jaxws:serviceFactory>
+ <ref bean="testServiceFactory"/>
+ </jaxws:serviceFactory>
+ </jaxws:endpoint>
+</beans>
Added: cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/xmlbeanstest.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/xmlbeanstest.wsdl?rev=710076&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/xmlbeanstest.wsdl (added)
+++ cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/xmlbeanstest.wsdl Mon Nov 3 06:56:59 2008
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://cxf.apache.org/xmlbeans"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://cxf.apache.org/xmlbeans"
+ xmlns:x1="http://cxf.apache.org/xmlbeans"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+
+ <wsdl:types>
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://cxf.apache.org/xmlbeans"
+ xmlns:x1="http://cxf.apache.org/xmlbeans"
+ elementFormDefault="qualified">
+
+ <complexType name="StringListType">
+ <all>
+ <element minOccurs="1" maxOccurs="1" name="myname" type="string" />
+ <element minOccurs="1" maxOccurs="1" name="myaddress" type="string" />
+ </all>
+ </complexType>
+
+ <element name="sayHi2Message" type="x1:StringListType" />
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="sayHiRequest2">
+ <wsdl:part element="x1:sayHi2Message" name="in"/>
+ </wsdl:message>
+
+ <wsdl:portType name="GreeterMine">
+ <wsdl:operation name="sayHi2">
+ <wsdl:input message="tns:sayHiRequest2" name="sayHiRequest2"/>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:GreeterMine">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sayHi2">
+ <soap:operation soapAction="sayHi2" style="document"/>
+ <wsdl:input name="sayHiRequest2">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SOAPMineService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
Added: cxf/trunk/testutils/src/main/resources/wsdl/xmlbeanstest.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/resources/wsdl/xmlbeanstest.wsdl?rev=710076&view=auto
==============================================================================
--- cxf/trunk/testutils/src/main/resources/wsdl/xmlbeanstest.wsdl (added)
+++ cxf/trunk/testutils/src/main/resources/wsdl/xmlbeanstest.wsdl Mon Nov 3 06:56:59 2008
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://cxf.apache.org/xmlbeans"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://cxf.apache.org/xmlbeans"
+ xmlns:x1="http://cxf.apache.org/xmlbeans"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+
+ <wsdl:types>
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://cxf.apache.org/xmlbeans"
+ xmlns:x1="http://cxf.apache.org/xmlbeans"
+ elementFormDefault="qualified">
+
+ <complexType name="StringListType">
+ <all>
+ <element minOccurs="1" maxOccurs="1" name="myname" type="string" />
+ <element minOccurs="1" maxOccurs="1" name="myaddress" type="string" />
+ </all>
+ </complexType>
+
+ <element name="sayHi2Message" type="x1:StringListType" />
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="sayHiRequest2">
+ <wsdl:part element="x1:sayHi2Message" name="in"/>
+ </wsdl:message>
+
+ <wsdl:portType name="GreeterMine">
+ <wsdl:operation name="sayHi2">
+ <wsdl:input message="tns:sayHiRequest2" name="sayHiRequest2"/>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:GreeterMine">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sayHi2">
+ <soap:operation soapAction="sayHi2" style="document"/>
+ <wsdl:input name="sayHiRequest2">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SOAPMineService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+