You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by bi...@apache.org on 2009/04/19 03:15:07 UTC
svn commit: r766410 - in /webservices/commons/trunk/modules/XmlSchema/src:
main/java/org/apache/ws/commons/schema/SchemaBuilder.java
test/java/tests/WSCommons378Test.java test/test-resources/wscommons-378.xsd
Author: bimargulies
Date: Sun Apr 19 01:15:06 2009
New Revision: 766410
URL: http://svn.apache.org/viewvc?rev=766410&view=rev
Log:
merge fix to WSCOMMONS-378 to trunk.
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCommons378Test.java
- copied, changed from r766408, webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/wscommons-378.xsd
- copied, changed from r766408, webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=766410&r1=766409&r2=766410&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java Sun Apr 19 01:15:06 2009
@@ -1759,8 +1759,11 @@
"annotation")) {
XmlSchemaAnnotation facetAnnotation = handleAnnotation(el);
facet.setAnnotation(facetAnnotation);
+
}
restriction.facets.add(facet);
+ //process extra attributes and elements
+ processExtensibilityComponents(facet, el);
}
}
return restriction;
@@ -1856,6 +1859,8 @@
XmlSchemaAnnotation facetAnnotation = handleAnnotation(annotation);
facet.setAnnotation(facetAnnotation);
}
+ //process extra attributes and elements
+ processExtensibilityComponents(facet, el);
restriction.facets.add(facet);
}
Copied: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCommons378Test.java (from r766408, webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCommons378Test.java?p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCommons378Test.java&p1=webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java&r1=766408&r2=766410&rev=766410&view=diff
==============================================================================
--- webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/java/tests/WSCommons378Test.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCommons378Test.java Sun Apr 19 01:15:06 2009
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,80 +19,80 @@
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 org.w3c.dom.Attr;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.constants.Constants;
-import junit.framework.TestCase;
+
+import org.junit.Assert;
+import org.junit.Test;
/**
- * Test case for <a
- * href="https://issues.apache.org/jira/browse/WSCOMMONS-378">WSCOMMONS-378</a>
+ * 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 {
+public class WSCommons378Test extends Assert {
+
/**
- * Tests that {@link SchemaBuilder} correctly reads additional enumeration
- * facet attributes
+ * Tests that {@link SchemaBuilder} correctly reads additional enumeration facet attributes
*
- * @throws Exception
- * Any exception encountered
+ * @throws Exception Any exception encountered
*/
+ @Test
public void test() throws Exception {
- InputStream is = new FileInputStream(Resources
- .asURI("wscommons-378.xsd"));
- XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- schemaCol.read(new StreamSource(is), null);
+ InputStream is = new FileInputStream(Resources.asURI("wscommons-378.xsd"));
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ schemaCol.read(new StreamSource(is));
- XmlSchemaSimpleType type = (XmlSchemaSimpleType) schemaCol
- .getTypeByQName(new QName("foo"));
- XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) type
- .getContent();
- XmlSchemaObjectCollection facets = restriction.getFacets();
+ XmlSchemaSimpleType type = (XmlSchemaSimpleType)schemaCol.getTypeByQName(new QName("foo"));
+ XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)type.getContent();
+ XmlSchemaObjectCollection facets = restriction.getFacets();
- assertEquals(2, facets.getCount());
+ assertEquals(2, facets.getCount());
- XmlSchemaEnumerationFacet facet1 = (XmlSchemaEnumerationFacet) facets
- .getItem(0);
- XmlSchemaEnumerationFacet facet2 = (XmlSchemaEnumerationFacet) facets
- .getItem(1);
+ 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);
+ 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);
+ assertNotNull(externalAttributes1);
+ assertNotNull(externalAttributes2);
- assertEquals(1, externalAttributes1.size());
- assertEquals(1, externalAttributes2.size());
+ assertEquals(1, externalAttributes1.size());
+ assertEquals(1, externalAttributes2.size());
- Attr attr1 = (Attr) externalAttributes1.values().iterator().next();
- Attr attr2 = (Attr) externalAttributes2.values().iterator().next();
+ Attr attr1 = (Attr)externalAttributes1.values().iterator().next();
+ Attr attr2 = (Attr)externalAttributes2.values().iterator().next();
- assertNotNull(attr1);
- assertNotNull(attr2);
+ assertNotNull(attr1);
+ assertNotNull(attr2);
- assertEquals("http://testuri.org/", attr1.getNamespaceURI());
- assertEquals("http://testuri.org/", attr2.getNamespaceURI());
+ assertEquals("http://testuri.org/", attr1.getNamespaceURI());
+ assertEquals("http://testuri.org/", attr2.getNamespaceURI());
- assertEquals("test", attr1.getPrefix());
- assertEquals("test", attr2.getPrefix());
+ assertEquals("test", attr1.getPrefix());
+ assertEquals("test", attr2.getPrefix());
- assertEquals("attr1", attr1.getLocalName());
- assertEquals("attr2", attr2.getLocalName());
+ assertEquals("attr1", attr1.getLocalName());
+ assertEquals("attr2", attr2.getLocalName());
- assertEquals("attr1-value", attr1.getValue());
- assertEquals("attr2-value", attr2.getValue());
+ assertEquals("attr1-value", attr1.getValue());
+ assertEquals("attr2-value", attr2.getValue());
}
}
Copied: webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/wscommons-378.xsd (from r766408, webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/wscommons-378.xsd?p2=webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/wscommons-378.xsd&p1=webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd&r1=766408&r2=766410&rev=766410&view=diff
==============================================================================
--- webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/test/test-resources/wscommons-378.xsd (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/wscommons-378.xsd Sun Apr 19 01:15:06 2009
@@ -1,3 +1,4 @@
+<?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
@@ -16,14 +17,11 @@
~ 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:schema xmlns:test="http://testuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:simpleType name="foo" >
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration test:attr1="attr1-value" value="value1"/>
+ <xsd:enumeration test:attr2="attr2-value" value="value2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>