Author: veithen
Date: Tue Mar 29 18:31:13 2016
New Revision: 1737030
URL: http://svn.apache.org/viewvc?rev=1737030&view=rev
Log:
AXIS2-5750: Correctly implement attributes with fixed values in ADB. Apply
patch provided by Frederik Hansen with some changes to the test case.
Added:
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/ServiceTest.java
(with props)
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/FixedValueServiceImpl.java
(with props)
axis/axis2/java/core/trunk/modules/adb-tests/src/test/wsdl/AXIS2-5750.wsdl
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
axis/axis2/java/core/trunk/modules/adb-tests/pom.xml
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=1737030&r1=1737029&r2=1737030&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
(original)
+++
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
Tue Mar 29 18:31:13 2016
@@ -80,13 +80,13 @@ public class BeanWriterMetaInfoHolder {
protected String itemTypeClassName;
protected boolean isUnion;
protected boolean isList;
- protected boolean fixed = false;
protected boolean isParticleClass;
// keep whether this class has a partical class type variable
protected boolean hasParticleType;
protected List<QName> nillableQNameList = new ArrayList<QName>();
+ protected List<QName> fixedQNameList = new ArrayList<QName>();
//the parent metainfo holder, useful in handling extensions and
//restrictions
@@ -316,6 +316,25 @@ public class BeanWriterMetaInfoHolder {
}
/**
+ * Registers a Qname as fixed
+ * The qName better be of an element
+ *
+ * @param eltQName
+ */
+ public void registerFixedQName(QName eltQName) {
+ fixedQNameList.add(eltQName);
+ }
+
+ /**
+ * Returns whether a QName is fixed or not
+ *
+ * @param eltQName
+ */
+ public boolean isFixed(QName eltQName) {
+ return fixedQNameList.contains(eltQName);
+ }
+
+ /**
* Registers a mapping.
*
* @param qName
@@ -944,14 +963,6 @@ public class BeanWriterMetaInfoHolder {
return restrictionBaseType;
}
- public boolean isFixed() {
- return fixed;
- }
-
- public void setFixed(boolean fixed) {
- this.fixed = fixed;
- }
-
@Override
public String toString() {
return "BeanWriterMetaInfoHolder [anonymous=" + anonymous + ",
choice=" + choice
@@ -975,7 +986,7 @@ public class BeanWriterMetaInfoHolder {
+ restrictionBaseType + ", restrictionClassName=" +
restrictionClassName
+ ", simple=" + simple + ", specialTypeFlagMap=" +
specialTypeFlagMap
+ ", totalDigitsFacet=" + totalDigitsFacet + ",
xmlNameJavaNameMap="
- + xmlNameJavaNameMap + ", xmlNameJavaNameMap=" + fixed + "]";
+ + xmlNameJavaNameMap + ", fixedQNameList=" + fixedQNameList +
"]";
}
}
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=1737030&r1=1737029&r2=1737030&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
(original)
+++
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
Tue Mar 29 18:31:13 2016
@@ -503,7 +503,7 @@ public class SchemaCompiler {
// register the fixed value if present
if (xsElt.getFixedValue() != null) {
metainf.registerDefaultValue(xsElt.getQName(),
xsElt.getFixedValue());
- metainf.setFixed(true);
+ metainf.registerFixedQName(xsElt.getQName());
}
if (isBinary(xsElt)) {
@@ -1861,7 +1861,7 @@ public class SchemaCompiler {
}
if (att.getFixedValue() != null) {
metainf.registerDefaultValue(att.getQName(),
att.getFixedValue());
- metainf.setFixed(true);
+ metainf.registerFixedQName(att.getQName());
}
// after
} else {
@@ -2269,7 +2269,7 @@ public class SchemaCompiler {
// register the default value as well
if (elt.getFixedValue() != null) {
metainfHolder.registerDefaultValue(referencedQName, elt.getFixedValue());
- metainfHolder.setFixed(true);
+ metainfHolder.registerFixedQName(referencedQName);
}
}
}
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=1737030&r1=1737029&r2=1737030&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
(original)
+++
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Tue Mar 29 18:31:13 2016
@@ -882,12 +882,6 @@ public class JavaBeanWriter implements B
XSLTUtils.addAttribute(model, "innerchoice", "yes", property);
}
- if (metainf.isFixed()){
- XSLTUtils.addAttribute(model, "fixed", "yes", property);
- }
-
-
-
if ((parentMetaInf != null) && metainf.isRestriction() &&
missingQNames.contains(name)) {
// this element details should be there with the parent meta
Inf
addAttributesToProperty(
@@ -937,6 +931,10 @@ public class JavaBeanWriter implements B
XSLTUtils.addAttribute(model, "nillable", "yes", property);
}
+ if (metainf.isFixed(name)){
+ XSLTUtils.addAttribute(model, "fixed", "yes", property);
+ }
+
if (metainf.getOptionalAttributeStatusForQName(name)) {
XSLTUtils.addAttribute(model, "optional", "yes", property);
}
Modified: axis/axis2/java/core/trunk/modules/adb-tests/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/pom.xml?rev=1737030&r1=1737029&r2=1737030&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-tests/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/adb-tests/pom.xml Tue Mar 29 18:31:13
2016
@@ -115,6 +115,25 @@
<outputDirectory>${project.build.directory}/wsdl2code/AXIS2-5749</outputDirectory>
</configuration>
</execution>
+ <execution>
+ <id>wsdl2code-axis2-5750</id>
+ <goals>
+ <goal>generate-test-sources</goal>
+ </goals>
+ <configuration>
+ <wsdlFile>src/test/wsdl/AXIS2-5750.wsdl</wsdlFile>
+ <syncMode>sync</syncMode>
+ <unpackClasses>true</unpackClasses>
+ <namespaceURIs>
+ <namespaceURI>
+
<uri>http://ise-online.com/FixedValueService/</uri>
+
<packageName>org.apache.axis2.databinding.axis2_5750.client</packageName>
+ </namespaceURI>
+ </namespaceURIs>
+
<packageName>org.apache.axis2.databinding.axis2_5750.client</packageName>
+
<outputDirectory>${project.build.directory}/wsdl2code/AXIS2-5750</outputDirectory>
+ </configuration>
+ </execution>
</executions>
<configuration>
<databindingName>adb</databindingName>
@@ -194,6 +213,18 @@
<packageName>org.apache.axis2.databinding.axis2_5749.client</packageName>
</configuration>
</execution>
+ <execution>
+ <id>wsimport-axis2-5750</id>
+ <goals>
+ <goal>wsimport-test</goal>
+ </goals>
+ <configuration>
+ <wsdlFiles>
+
<wsdlFile>${basedir}/src/test/wsdl/AXIS2-5750.wsdl</wsdlFile>
+ </wsdlFiles>
+
<packageName>org.apache.axis2.databinding.axis2_5750.service</packageName>
+ </configuration>
+ </execution>
</executions>
<dependencies>
<dependency>
Added:
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/ServiceTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/ServiceTest.java?rev=1737030&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/ServiceTest.java
(added)
+++
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/ServiceTest.java
Tue Mar 29 18:31:13 2016
@@ -0,0 +1,49 @@
+/*
+ * 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.axis2.databinding.axis2_5750;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.axiom.testutils.PortAllocator;
+import org.apache.axis2.databinding.axis2_5750.client.FixedValue;
+import org.apache.axis2.databinding.axis2_5750.client.FixedValueServiceStub;
+import org.apache.axis2.databinding.axis2_5750.client.NonFixedValue_type1;
+import org.apache.axis2.databinding.axis2_5750.service.FixedValueServiceImpl;
+import org.junit.Test;
+
+public class ServiceTest {
+ @Test
+ public void test() throws Exception {
+ int port = PortAllocator.allocatePort();
+ String address = "http://localhost:" + port + "/service";
+ Endpoint endpoint = Endpoint.publish(address, new
FixedValueServiceImpl());
+ try {
+ FixedValue fixedValue = new FixedValue();
+ NonFixedValue_type1 nonFixedValue_type1 = new
NonFixedValue_type1();
+ nonFixedValue_type1.setNonFixedValue_type0("SomeId");
+ fixedValue.setNonFixedValue(nonFixedValue_type1);
+ FixedValueServiceStub stub = new FixedValueServiceStub(address);
+ assertThat(stub.test(fixedValue).getOut()).isEqualTo("OK");
+ } finally {
+ endpoint.stop();
+ }
+ }
+}
Propchange:
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/ServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/FixedValueServiceImpl.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/FixedValueServiceImpl.java?rev=1737030&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/FixedValueServiceImpl.java
(added)
+++
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/FixedValueServiceImpl.java
Tue Mar 29 18:31:13 2016
@@ -0,0 +1,35 @@
+/*
+ * 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.axis2.databinding.axis2_5750.service;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface="org.apache.axis2.databinding.axis2_5750.service.FixedValueService")
+public class FixedValueServiceImpl implements FixedValueService {
+ @Override
+ public FixedValueResponse test(FixedValue parameters) {
+ FixedValueResponse response = new FixedValueResponse();
+ if (parameters.getFixedValue().equals("strict") &&
parameters.getNonFixedValue().equals("SomeId")) {
+ response.setOut("OK");
+ } else {
+ response.setOut("NOK");
+ }
+ return response;
+ }
+}
Propchange:
axis/axis2/java/core/trunk/modules/adb-tests/src/test/java/org/apache/axis2/databinding/axis2_5750/service/FixedValueServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
axis/axis2/java/core/trunk/modules/adb-tests/src/test/wsdl/AXIS2-5750.wsdl
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-tests/src/test/wsdl/AXIS2-5750.wsdl?rev=1737030&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-tests/src/test/wsdl/AXIS2-5750.wsdl
(added)
+++ axis/axis2/java/core/trunk/modules/adb-tests/src/test/wsdl/AXIS2-5750.wsdl
Tue Mar 29 18:31:13 2016
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="FixedValueService"
targetNamespace="http://ise-online.com/FixedValueService/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ise-online.com/FixedValueService/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://ise-online.com/FixedValueService/">
+ <xsd:element name="FixedValue">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="nonFixedValue" minOccurs="0">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:maxLength value="10"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="fixedValue" fixed="strict" type="xsd:string"
use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="FixedValueResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="out" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="TestRequest">
+ <wsdl:part name="parameters" element="tns:FixedValue">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="TestResponse">
+ <wsdl:part name="parameters" element="tns:FixedValueResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="FixedValueService">
+ <wsdl:operation name="Test">
+ <wsdl:input message="tns:TestRequest">
+ </wsdl:input>
+ <wsdl:output message="tns:TestResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="FixedValueServiceSOAP" type="tns:FixedValueService">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="Test">
+ <soap:operation
soapAction="http://ise-online.com/FixedValueService/Test"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="FixedValueService">
+ <wsdl:port name="FixedValueServiceSOAP"
binding="tns:FixedValueServiceSOAP">
+ <soap:address location="http://www.example.org/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>