Author: dkulp Date: Mon Jan 14 19:38:35 2013 New Revision: 1433076 URL: http://svn.apache.org/viewvc?rev=1433076&view=rev Log: Merged revisions 1433068 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
........ r1433068 | dkulp | 2013-01-14 14:31:52 -0500 (Mon, 14 Jan 2013) | 18 lines Merged revisions 1433011 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes ........ r1433011 | dkulp | 2013-01-14 12:58:39 -0500 (Mon, 14 Jan 2013) | 10 lines Merged revisions 1433007 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1433007 | dkulp | 2013-01-14 12:44:36 -0500 (Mon, 14 Jan 2013) | 2 lines [CXF-4750] Allow XMLBeans to work with enums ........ ........ ........ Modified: cxf/branches/2.5.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java cxf/branches/2.5.x-fixes/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl Modified: cxf/branches/2.5.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java?rev=1433076&r1=1433075&r2=1433076&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java (original) +++ cxf/branches/2.5.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java Mon Jan 14 19:38:35 2013 @@ -90,7 +90,14 @@ public final class XMLBeansSchemaTypeUti public static String getNaturalJavaClassName(SchemaType st) { SchemaType schemaType = st; String result = null; - if (st.isSimpleType() && !st.isBuiltinType()) { + if (st.getBaseEnumType() != null) { + if (hasBase(st)) { + schemaType = st.getBaseEnumType(); + return schemaType.getFullJavaName().replace('$', '.') + ".Enum"; + } else { + return st.getFullJavaName().replace('$', '.') + ".Enum"; + } + } else if (st.isSimpleType() && !st.isBuiltinType()) { schemaType = st.getBaseType(); while (schemaType != null && !schemaType.isBuiltinType()) { schemaType = schemaType.getBaseType(); @@ -104,5 +111,18 @@ public final class XMLBeansSchemaTypeUti return result; } - + private static boolean hasBase(SchemaType sType) { + boolean hasBase; + SchemaType baseEnumType = sType.getBaseEnumType(); + if (baseEnumType.isAnonymousType() && baseEnumType.isSkippedAnonymousType()) { + if (sType.getContentBasedOnType() != null) { + hasBase = sType.getContentBasedOnType().getBaseType() != baseEnumType; + } else { + hasBase = sType.getBaseType() != baseEnumType; + } + } else { + hasBase = baseEnumType != sType; + } + return hasBase; + } } Modified: cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java?rev=1433076&r1=1433075&r2=1433076&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java (original) +++ cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java Mon Jan 14 19:38:35 2013 @@ -51,6 +51,7 @@ import org.apache.cxf.xmlbeans.docLitBar import org.apache.cxf.xmlbeans.doc_lit_bare.PutLastTradedPricePortType; import org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.FaultDetailDocument; import org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.FaultDetailDocument.FaultDetail; +import org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.TestEnum; import org.apache.hello_world_soap_http_xmlbeans.xmlbeans.GreetMeFault; import org.apache.hello_world_soap_http_xmlbeans.xmlbeans.Greeter; import org.apache.hello_world_soap_http_xmlbeans.xmlbeans.PingMeFault; @@ -132,6 +133,11 @@ public class ClientServerXmlBeansTest ex String resp; ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); + + TestEnum.Enum response = port.sayHiEnum(TestEnum.ONE); + assertEquals(TestEnum.ONE, response); + + resp = port.sayHi(); assertEquals("We should get the right response", "Bonjour", resp); @@ -167,7 +173,6 @@ public class ClientServerXmlBeansTest ex assertEquals("Wrong faultDetail major", detail.getMajor(), 2); assertEquals("Wrong faultDetail minor", detail.getMinor(), 1); } - } @Test Modified: cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java?rev=1433076&r1=1433075&r2=1433076&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java (original) +++ cxf/branches/2.5.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/GreeterImpl.java Mon Jan 14 19:38:35 2013 @@ -24,6 +24,7 @@ import java.util.logging.Logger; import org.apache.cxf.common.logging.LogUtils; import org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.FaultDetailDocument; import org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.FaultDetailDocument.FaultDetail; +import org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.TestEnum; import org.apache.hello_world_soap_http_xmlbeans.xmlbeans.GreetMeFault; import org.apache.hello_world_soap_http_xmlbeans.xmlbeans.Greeter; import org.apache.hello_world_soap_http_xmlbeans.xmlbeans.PingMeFault; @@ -83,4 +84,8 @@ public class GreeterImpl implements Gree System.arraycopy(requests, 0, ret, 1, requests.length); return ret; } + + public TestEnum.Enum sayHiEnum(TestEnum.Enum request) { + return request; + } } Modified: cxf/branches/2.5.x-fixes/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl?rev=1433076&r1=1433075&r2=1433076&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl (original) +++ cxf/branches/2.5.x-fixes/systests/databinding/src/test/resources/wsdl_systest_databinding/xmlbeans/hello_world.wsdl Mon Jan 14 19:38:35 2013 @@ -34,7 +34,14 @@ <maxLength value="30" /> </restriction> </simpleType> - + <xsd:simpleType name="TestEnum"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="ONE" /> + <xsd:enumeration value="TWO" /> + <xsd:enumeration value="THREE" /> + </xsd:restriction> + </xsd:simpleType> + <element name="sayHi"> <complexType/> </element> @@ -60,6 +67,20 @@ </sequence> </complexType> </element> + <element name="sayHiEnum"> + <complexType> + <sequence> + <element name="request" type="tns:TestEnum"/> + </sequence> + </complexType> + </element> + <element name="sayHiEnumResponse"> + <complexType> + <sequence> + <element name="response" type="tns:TestEnum"/> + </sequence> + </complexType> + </element> <element name="greetMe"> <complexType> @@ -111,6 +132,12 @@ <wsdl:message name="sayHiArrayResponse"> <wsdl:part element="x1:sayHiArrayResponse" name="out"/> </wsdl:message> + <wsdl:message name="sayHiEnumRequest"> + <wsdl:part element="x1:sayHiEnum" name="in"/> + </wsdl:message> + <wsdl:message name="sayHiEnumResponse"> + <wsdl:part element="x1:sayHiEnumResponse" name="out"/> + </wsdl:message> <wsdl:message name="greetMeRequest"> <wsdl:part element="x1:greetMe" name="in"/> </wsdl:message> @@ -143,6 +170,10 @@ <wsdl:input message="tns:sayHiArrayRequest" name="sayHiArrayRequest"/> <wsdl:output message="tns:sayHiArrayResponse" name="sayHiArrayResponse"/> </wsdl:operation> + <wsdl:operation name="sayHiEnum"> + <wsdl:input message="tns:sayHiEnumRequest" name="sayHiEnumRequest"/> + <wsdl:output message="tns:sayHiEnumResponse" name="sayHiEnumResponse"/> + </wsdl:operation> <wsdl:operation name="greetMe"> @@ -185,6 +216,15 @@ <soap:body use="literal"/> </wsdl:output> </wsdl:operation> + <wsdl:operation name="sayHiEnum"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="sayHiEnumRequest"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="sayHiEnumResponse"> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> <wsdl:operation name="greetMe">
