Author: bimargulies Date: Thu Feb 26 17:44:33 2009 New Revision: 748224 URL: http://svn.apache.org/viewvc?rev=748224&view=rev Log: WSCOMMONS-378.
Added: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java (with props) webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd (with props) Modified: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java Modified: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java URL: http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=748224&r1=748223&r2=748224&view=diff ============================================================================== --- webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java (original) +++ webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java Thu Feb 26 17:44:33 2009 @@ -456,6 +456,9 @@ XmlSchemaAnnotation facetAnnotation = handleAnnotation(annotation); facet.setAnnotation(facetAnnotation); } + + //process extra attributes and elements + processExtensibilityComponents(facet, el); restriction.facets.add(facet); } Added: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java URL: http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java?rev=748224&view=auto ============================================================================== --- webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java (added) +++ webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java Thu Feb 26 17:44:33 2009 @@ -0,0 +1,98 @@ +/* + * 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 tests; + +import org.apache.ws.commons.schema.*; +import org.apache.ws.commons.schema.constants.Constants; +import org.w3c.dom.Attr; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.transform.stream.StreamSource; + +import junit.framework.TestCase; + +/** + * Test case for <a + * href="https://issues.apache.org/jira/browse/WSCOMMONS-378">WSCOMMONS-378</a> + * + * @author Sergey Vladimirov (vlsergey at gmail dot com) + */ +public class WSCommons378Test extends TestCase { + + /** + * Tests that {...@link SchemaBuilder} correctly reads additional enumeration + * facet attributes + * + * @throws Exception + * Any exception encountered + */ + public void test() throws Exception { + InputStream is = new FileInputStream(Resources + .asURI("wscommons-378.xsd")); + XmlSchemaCollection schemaCol = new XmlSchemaCollection(); + schemaCol.read(new StreamSource(is), null); + + XmlSchemaSimpleType type = (XmlSchemaSimpleType) schemaCol + .getTypeByQName(new QName("foo")); + XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) type + .getContent(); + XmlSchemaObjectCollection facets = restriction.getFacets(); + + assertEquals(2, facets.getCount()); + + XmlSchemaEnumerationFacet facet1 = (XmlSchemaEnumerationFacet) facets + .getItem(0); + XmlSchemaEnumerationFacet facet2 = (XmlSchemaEnumerationFacet) facets + .getItem(1); + + final Map externalAttributes1 = (Map) facet1.getMetaInfoMap().get( + Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES); + final Map externalAttributes2 = (Map) facet2.getMetaInfoMap().get( + Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES); + + assertNotNull(externalAttributes1); + assertNotNull(externalAttributes2); + + assertEquals(1, externalAttributes1.size()); + assertEquals(1, externalAttributes2.size()); + + Attr attr1 = (Attr) externalAttributes1.values().iterator().next(); + Attr attr2 = (Attr) externalAttributes2.values().iterator().next(); + + assertNotNull(attr1); + assertNotNull(attr2); + + assertEquals("http://testuri.org/", attr1.getNamespaceURI()); + assertEquals("http://testuri.org/", attr2.getNamespaceURI()); + + assertEquals("test", attr1.getPrefix()); + assertEquals("test", attr2.getPrefix()); + + assertEquals("attr1", attr1.getLocalName()); + assertEquals("attr2", attr2.getLocalName()); + + assertEquals("attr1-value", attr1.getValue()); + assertEquals("attr2-value", attr2.getValue()); + } +} Propchange: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd URL: http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd?rev=748224&view=auto ============================================================================== --- webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd (added) +++ webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd Thu Feb 26 17:44:33 2009 @@ -0,0 +1,29 @@ +<!-- + ~ 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. + --> + +<xsd:schema + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:test="http://testuri.org/"> + <xsd:simpleType name="foo"> + <xsd:restriction> + <xsd:enumeration value="value1" test:attr1="attr1-value" /> + <xsd:enumeration value="value2" test:attr2="attr2-value" /> + </xsd:restriction> + </xsd:simpleType> +</xsd:schema> Propchange: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xml