You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2016/03/18 16:39:48 UTC
cxf git commit: [CXF-5193] Fix anonymous fixed IDL type handling This
closes #123
Repository: cxf
Updated Branches:
refs/heads/master 1184e08f0 -> ea618d7af
[CXF-5193] Fix anonymous fixed IDL type handling
This closes #123
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ea618d7a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ea618d7a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ea618d7a
Branch: refs/heads/master
Commit: ea618d7af68ab2025fbcd63ece4a7e3f28afcd0b
Parents: 1184e08
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Thu Mar 17 13:41:25 2016 +0100
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri Mar 18 11:39:18 2016 -0400
----------------------------------------------------------------------
.../corba/processors/idl/FixedVisitor.java | 42 ++++++---
.../processors/IDLToWSDLGenerationTest.java | 5 +
.../src/test/resources/idl/FixedStruct.idl | 32 +++++++
.../resources/idl/expected_FixedStruct.wsdl | 98 ++++++++++++++++++++
4 files changed, 166 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/ea618d7a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
----------------------------------------------------------------------
diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
index 6b108cf..1cc9e5f 100644
--- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
+++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
@@ -24,6 +24,8 @@ import javax.xml.namespace.QName;
import antlr.collections.AST;
+import org.apache.cxf.binding.corba.wsdl.Anonfixed;
+import org.apache.cxf.binding.corba.wsdl.CorbaType;
import org.apache.cxf.binding.corba.wsdl.Fixed;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet;
@@ -76,7 +78,12 @@ public class FixedVisitor extends VisitorBase {
AST digitsNode = fixedNode.getFirstChild();
AST scaleNode = digitsNode.getNextSibling();
- Scope scopedName = new Scope(getScope(), identifierNode);
+ Scope scopedName = null;
+ if (identifierNode == null) {
+ scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
+ } else {
+ scopedName = new Scope(getScope(), identifierNode);
+ }
// validate digits and scale
Long digits = Long.valueOf(digitsNode.toString());
@@ -109,17 +116,30 @@ public class FixedVisitor extends VisitorBase {
// add xmlschema:fixed
setSchemaType(fixedSimpleType);
-
- // corba:fixed
- Fixed corbaFixed = new Fixed();
- corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
- corbaFixed.setDigits(digits);
- corbaFixed.setScale(scale);
- corbaFixed.setRepositoryID(scopedName.toIDLRepositoryID());
- //corbaFixed.setType(Constants.XSD_DECIMAL);
- corbaFixed.setType(fixedSimpleType.getQName());
+ CorbaType type = null;
+ if (identifierNode != null) {
+ // corba:fixed
+ Fixed corbaFixed = new Fixed();
+ corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
+ corbaFixed.setDigits(digits);
+ corbaFixed.setScale(scale);
+ corbaFixed.setRepositoryID(scopedName.toIDLRepositoryID());
+ //corbaFixed.setType(Constants.XSD_DECIMAL);
+ corbaFixed.setType(fixedSimpleType.getQName());
+ type = corbaFixed;
+ } else {
+ // corba:anonfixed
+ Anonfixed corbaFixed = new Anonfixed();
+ corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
+ corbaFixed.setDigits(digits);
+ corbaFixed.setScale(scale);
+ //corbaFixed.setType(Constants.XSD_DECIMAL);
+ corbaFixed.setType(fixedSimpleType.getQName());
+ typeMap.getStructOrExceptionOrUnion().add(corbaFixed);
+ type = corbaFixed;
+ }
// add corba:fixed
- setCorbaType(corbaFixed);
+ setCorbaType(type);
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/ea618d7a/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
----------------------------------------------------------------------
diff --git a/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java b/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
index e3de3e1..7d47d71 100644
--- a/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
+++ b/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
@@ -165,6 +165,11 @@ public class IDLToWSDLGenerationTest extends ProcessorTestBase {
}
@Test
+ public void testFixedStructGeneration() throws Exception {
+ testWSDLGeneration("/idl/FixedStruct.idl", "/idl/expected_FixedStruct.wsdl");
+ }
+
+ @Test
public void testTypedefGeneration() throws Exception {
testWSDLGeneration("/idl/Typedef.idl", "/idl/expected_Typedef.wsdl");
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/ea618d7a/tools/corba/src/test/resources/idl/FixedStruct.idl
----------------------------------------------------------------------
diff --git a/tools/corba/src/test/resources/idl/FixedStruct.idl b/tools/corba/src/test/resources/idl/FixedStruct.idl
new file mode 100644
index 0000000..bdcf8e4
--- /dev/null
+++ b/tools/corba/src/test/resources/idl/FixedStruct.idl
@@ -0,0 +1,32 @@
+/*
+ * 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.
+*/
+
+module fixeds
+{
+ struct FixedStruct
+ {
+ string<5> oddString;
+ fixed<5,2> oddFixed;
+ };
+
+ interface FunctionTest
+ {
+ FixedStruct testFixeds(in FixedStruct aFixedStruct);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cxf/blob/ea618d7a/tools/corba/src/test/resources/idl/expected_FixedStruct.wsdl
----------------------------------------------------------------------
diff --git a/tools/corba/src/test/resources/idl/expected_FixedStruct.wsdl b/tools/corba/src/test/resources/idl/expected_FixedStruct.wsdl
new file mode 100644
index 0000000..7036f11
--- /dev/null
+++ b/tools/corba/src/test/resources/idl/expected_FixedStruct.wsdl
@@ -0,0 +1,98 @@
+<?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 xmlns:corba="http://cxf.apache.org/bindings/corba" xmlns:tns="http://cxf.apache.org/bindings/corba/idl/FixedStruct" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://cxf.apache.org/bindings/corba/idl/FixedStruct">
+ <corba:typeMapping xmlns:corba="http://cxf.apache.org/bindings/corba" targetNamespace="http://cxf.apache.org/bindings/corba/idl/FixedStruct/typemap">
+ <corba:anonstring xmlns:tns="http://cxf.apache.org/bindings/corba/idl/FixedStruct" bound="5" name="fixeds._Anon1_FixedStruct" type="tns:fixeds._Anon1_FixedStruct" />
+ <corba:anonfixed xmlns:tns="http://cxf.apache.org/bindings/corba/idl/FixedStruct" digits="5" name="fixeds._Anon2_FixedStruct" scale="2" type="tns:fixeds._Anon2_FixedStruct"/>
+ <corba:struct xmlns:tns="http://cxf.apache.org/bindings/corba/idl/FixedStruct" name="fixeds.FixedStruct" repositoryID="IDL:fixeds/FixedStruct:1.0" type="tns:fixeds.FixedStruct">
+ <corba:member xmlns="http://cxf.apache.org/bindings/corba/idl/FixedStruct/typemap" idltype="fixeds._Anon1_FixedStruct" name="oddString" />
+ <corba:member xmlns="http://cxf.apache.org/bindings/corba/idl/FixedStruct/typemap" idltype="fixeds._Anon2_FixedStruct" name="oddFixed" />
+ </corba:struct>
+ </corba:typeMapping>
+ <wsdl:types>
+ <xs:schema xmlns="http://cxf.apache.org/bindings/corba/idl/FixedStruct" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://cxf.apache.org/bindings/corba/idl/FixedStruct">
+ <xs:complexType name="fixeds.FixedStruct">
+ <xs:sequence>
+ <xs:element name="oddString" type="fixeds._Anon1_FixedStruct" />
+ <xs:element name="oddFixed" type="fixeds._Anon2_FixedStruct" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:simpleType name="fixeds._Anon1_FixedStruct">
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="5" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="fixeds._Anon2_FixedStruct">
+ <xs:restriction base="xs:decimal">
+ <xs:totalDigits value="5" />
+ <xs:fractionDigits fixed="true" value="2" />
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:element name="testFixeds">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="aFixedStruct" type="fixeds.FixedStruct" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="testFixedsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="fixeds.FixedStruct" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="testFixeds">
+ <wsdl:part element="tns:testFixeds" name="inparameter">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="testFixedsResponse">
+ <wsdl:part element="tns:testFixedsResponse" name="outparameter">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="fixeds.FunctionTest">
+ <wsdl:operation name="testFixeds">
+ <wsdl:input message="tns:testFixeds" name="testFixedsRequest">
+ </wsdl:input>
+ <wsdl:output message="tns:testFixedsResponse" name="testFixedsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="fixeds.FunctionTestCORBABinding" type="tns:fixeds.FunctionTest">
+ <corba:binding xmlns:corba="http://cxf.apache.org/bindings/corba" repositoryID="IDL:fixeds/FunctionTest:1.0" />
+ <wsdl:operation name="testFixeds">
+ <corba:operation xmlns:corba="http://cxf.apache.org/bindings/corba" name="testFixeds">
+ <corba:param xmlns="http://cxf.apache.org/bindings/corba/idl/FixedStruct/typemap" idltype="fixeds.FixedStruct" mode="in" name="aFixedStruct" />
+ <corba:return xmlns="http://cxf.apache.org/bindings/corba/idl/FixedStruct/typemap" idltype="fixeds.FixedStruct" name="return" />
+ </corba:operation>
+ <wsdl:input name="testFixedsRequest">
+ </wsdl:input>
+ <wsdl:output name="testFixedsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="fixeds.FunctionTestCORBAService">
+ <wsdl:port binding="tns:fixeds.FunctionTestCORBABinding" name="fixeds.FunctionTestCORBAPort">
+ <corba:address xmlns:corba="http://cxf.apache.org/bindings/corba" location="IOR:" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>