svn commit: r1360573 - in /axis/axis2/java/core/trunk/modules/adb-codegen: ./ src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/ src/org/apache/axis2/schema/writer/ test-resources/xsd/
Author: sagara Date: Thu Jul 12 08:08:14 2012 New Revision: 1360573 URL: http://svn.apache.org/viewvc?rev=1360573&view=rev Log: Added modification to fix AXIS2-4356 and test cases. Added: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd (with props) axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/ axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java (with props) 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/template/ADBBeanTemplate-bean.xsl axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.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=1360573&r1=1360572&r2=1360573&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 Thu Jul 12 08:08:14 2012 @@ -80,6 +80,7 @@ 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 @@ -941,6 +942,14 @@ public class BeanWriterMetaInfoHolder { public QName getRestrictionBaseType() { return restrictionBaseType; +} + +public boolean isFixed() { +return fixed; +} + +public void setFixed(boolean fixed) { +this.fixed = fixed; } @Override @@ -966,7 +975,7 @@ public class BeanWriterMetaInfoHolder { + restrictionBaseType + ", restrictionClassName=" + restrictionClassName + ", simple=" + simple + ", specialTypeFlagMap=" + specialTypeFlagMap + ", totalDigitsFacet=" + totalDigitsFacet + ", xmlNameJavaNameMap=" -+ xmlNameJavaNameMap + "]"; ++ xmlNameJavaNameMap + ", xmlNameJavaNameMap=" + fixed + "]"; } } 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=1360573&r1=1360572&r2=1360573&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 Thu Jul 12 08:08:14 2012 @@ -547,6 +547,12 @@ public class SchemaCompiler { metainf.registerDefaultValue(xsElt.getQName(),xsElt.getDefaultValue()); } +// register the fixed value if present +if (xsElt.getFixedValue() != null){ + metainf.registerDefaultValue(xsElt.getQName(),xsElt.getFixedValue()); +metainf.setFixed(true); +} + if (isBinary(xsElt)) { metainf.addtStatus(xsElt.getQName(), SchemaConstants.BINARY_TYPE); @@ -1819,6 +1825,10 @@ public class SchemaCompiler { // set the default value if (att.getDefaultValue() != null){ metainf.registerDefaultValue(att.getQName(),att.getDefaultValue()); +} +if(att.getFixedValue() != null){ +metainf.registerDefaultValue(att.getQName(), att.getFixedValue()); +metainf.setFixed(true); } // after } else { @@ -2226,7 +2236,11 @@ public class SchemaCompiler { if (elt.getDefaultValue() != null){ metainfHolder.registerDefaultValue(referencedQName,elt.getDefaultValue()); } - + // register the default value as well +if (elt.getFixedValue() != null){ + metainfHolder.registerDefaultValue(referencedQName,elt.getFixedValue()); + metainfHolder.setFixed(true); +
svn commit: r1360577 - in /axis/axis2/java/core/branches/1_6/modules/adb-codegen: ./ src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/ src/org/apache/axis2/schema/writer/ test-resourc
Author: sagara Date: Thu Jul 12 08:25:23 2012 New Revision: 1360577 URL: http://svn.apache.org/viewvc?rev=1360577&view=rev Log: Merged r1360573 to 1.6 branch. Added: axis/axis2/java/core/branches/1_6/modules/adb-codegen/test-resources/xsd/fixed_value.xsd - copied unchanged from r1360573, axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/fix/ - copied from r1360573, axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/ axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java - copied unchanged from r1360573, axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java axis/axis2/java/core/branches/1_6/modules/adb-codegen/sub-build.xml Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=1360577&r1=1360576&r2=1360577&view=diff == --- axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original) +++ axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Thu Jul 12 08:25:23 2012 @@ -80,6 +80,7 @@ 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 @@ -941,6 +942,14 @@ public class BeanWriterMetaInfoHolder { public QName getRestrictionBaseType() { return restrictionBaseType; +} + +public boolean isFixed() { +return fixed; +} + +public void setFixed(boolean fixed) { +this.fixed = fixed; } @Override @@ -966,7 +975,7 @@ public class BeanWriterMetaInfoHolder { + restrictionBaseType + ", restrictionClassName=" + restrictionClassName + ", simple=" + simple + ", specialTypeFlagMap=" + specialTypeFlagMap + ", totalDigitsFacet=" + totalDigitsFacet + ", xmlNameJavaNameMap=" -+ xmlNameJavaNameMap + "]"; ++ xmlNameJavaNameMap + ", xmlNameJavaNameMap=" + fixed + "]"; } } Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=1360577&r1=1360576&r2=1360577&view=diff == --- axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original) +++ axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Thu Jul 12 08:25:23 2012 @@ -547,6 +547,12 @@ public class SchemaCompiler { metainf.registerDefaultValue(xsElt.getQName(),xsElt.getDefaultValue()); } +// register the fixed value if present +if (xsElt.getFixedValue() != null){ + metainf.registerDefaultValue(xsElt.getQName(),xsElt.getFixedValue()); +metainf.setFixed(true); +} + if (isBinary(xsElt)) { metainf.addtStatus(xsElt.getQName(), SchemaConstants.BINARY_TYPE); @@ -1815,6 +1821,10 @@ public class SchemaCompiler { // set the default value if (att.getDefaultValue() != null){ metainf.registerDefaultValue(att.getQName(),att.getDefaultValue()); +} +if(att.getFixedValue() != null){ +metainf.registerDefaultValue(att.getQName(), att.getFixedValue()); +metainf.setFixed(true); } // after } else { @@ -,7 +2232,11 @@ public class SchemaCompiler { if (elt.getDefaultVa
svn commit: r1360587 - in /axis/axis2/java/core/trunk/modules/adb-codegen: test-resources/xsd/fixed_value.xsd test/org/apache/axis2/schema/fix/DefaultValueTest.java
Author: sagara Date: Thu Jul 12 08:59:02 2012 New Revision: 1360587 URL: http://svn.apache.org/viewvc?rev=1360587&view=rev Log: Added more test coverage to test XSD element @default. Added: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/DefaultValueTest.java (with props) Modified: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd Modified: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd?rev=1360587&r1=1360586&r2=1360587&view=diff == --- axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd (original) +++ axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd Thu Jul 12 08:59:02 2012 @@ -12,10 +12,17 @@ ~ under the License. --> http://www.w3.org/2001/XMLSchema";> + + + + + + \ No newline at end of file Added: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/DefaultValueTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/DefaultValueTest.java?rev=1360587&view=auto == --- axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/DefaultValueTest.java (added) +++ axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/DefaultValueTest.java Thu Jul 12 08:59:02 2012 @@ -0,0 +1,91 @@ +/* + * 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.schema.fix; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; + +import axis2.apache.org.DefaultString; +import axis2.apache.org.DefaultStringElement; +import axis2.apache.org.FixedStringElement; + +import junit.framework.TestCase; + +public class DefaultValueTest extends TestCase { + +public static String ERROR_MSG = "Input values do not follow defined XSD restrictions"; + +public void testDefaultStringElement1() throws Exception { +DefaultStringElement defaultElement = new DefaultStringElement(); +DefaultString defaultString = new DefaultString(); +defaultString.setMsg("XYZ"); +defaultElement.setDefaultStringElement(defaultString); +OMElement omElement = defaultElement.getOMElement(FixedStringElement.MY_QNAME, +OMAbstractFactory.getSOAP11Factory()); +} + +public void testDefaultStringElement2() throws Exception { +DefaultStringElement defaultElement = new DefaultStringElement(); +DefaultString defaultString = new DefaultString(); +defaultString.setMsg("XYZ"); +defaultElement.setDefaultStringElement(defaultString); +OMElement omElement = defaultElement.getOMElement(FixedStringElement.MY_QNAME, +OMAbstractFactory.getSOAP11Factory()); +} + +public void testDefaultStringElementParse1() throws Exception { +OMFactory factory = OMAbstractFactory.getOMFactory(); +OMElement element = factory.createOMElement(new QName("", "defaultStringElement")); +OMElement msg = factory.createOMElement(new QName("", "msg")); +element.addChild(msg); +DefaultStringElement defaultStringElement = DefaultStringElement.Factory.parse(element +.getXMLStreamReader()); +assertNotNull(defaultStringElement.getDefaultStringElement().getMsg()); +assertEquals("", defaultStringElement.getDefaultStringElement().getMsg()); +} + +public void testDefaultStringElementParse2() throws Exception { +OMFactory factory = OMAbstractFactory.getOMFactory(); +OMElement element = factory.createOMElement(new QName("", "defaultStringElement")); +OMElement msg = factory.createOMElement(new QName("", "msg")); +