Author: ajith
Date: Mon Dec 3 13:50:27 2007
New Revision: 600703
URL: http://svn.apache.org/viewvc?rev=600703&view=rev
Log:
1. Fixed issue WSCOMMONS-273. Also added a test case and the relevant schema
file
Added:
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/java/tests/EnumValueTest.java
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/test-resources/enum.xsd
Modified:
webservices/commons/branches/modules/XmlSchema/1.3.3/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
Modified:
webservices/commons/branches/modules/XmlSchema/1.3.3/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1.3.3/src/main/java/org/apache/ws/commons/schema/constants/Enum.java?rev=600703&r1=600702&r2=600703&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1.3.3/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1.3.3/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
Mon Dec 3 13:50:27 2007
@@ -39,15 +39,23 @@
if (value.equals(Enum.NULL))
this.value = Enum.NULL;
else {
- String values[] = getValues();
- for (int i = 0; i < values.length; i++) {
- if (values[i].equals(value)) {
- this.value = value;
- break;
+ //the value can be a list of space seperated items
+ String possibleValues[] = getValues();
+ String[] valuesToBeTested = value.split("\\s");
+ for (int i = 0; i < valuesToBeTested.length; i++) {
+ for (int j = 0; j < possibleValues.length; j++) {
+ if (possibleValues[j].equals(valuesToBeTested[i])) {
+ break;
+ }
+ if (i == possibleValues.length - 1)
+ throw new EnumValueException("Bad Enumeration value '"
+ value + "'");
}
- if (i == values.length - 1)
- throw new EnumValueException("Bad Enumeration value '" +
value + "'");
}
+
+ //when we reach here we have tested all the values to be correct
(applicable)
+ this.value = value;
+
+
}
}
@@ -66,11 +74,11 @@
public static class EnumValueException extends RuntimeException {
/**
- *
- */
- private static final long serialVersionUID = 1L;
+ *
+ */
+ private static final long serialVersionUID = 1L;
- public EnumValueException(String mesg) {
+ public EnumValueException(String mesg) {
super(mesg);
}
}
Added:
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/java/tests/EnumValueTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/java/tests/EnumValueTest.java?rev=600703&view=auto
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/java/tests/EnumValueTest.java
(added)
+++
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/java/tests/EnumValueTest.java
Mon Dec 3 13:50:27 2007
@@ -0,0 +1,30 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: ajith
+ */
+public class EnumValueTest extends TestCase {
+
+
+ public void testValue() throws Exception{
+ //create a DOM document
+ DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder().
+ parse(Resources.asURI("enum.xsd"));
+
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema s = schemaCol.read(doc.getDocumentElement());
+
+ assertNotNull(s);
+ }
+}
Added:
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/test-resources/enum.xsd
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/test-resources/enum.xsd?rev=600703&view=auto
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/test-resources/enum.xsd
(added)
+++
webservices/commons/branches/modules/XmlSchema/1.3.3/src/test/test-resources/enum.xsd
Mon Dec 3 13:50:27 2007
@@ -0,0 +1,28 @@
+<!--
+ ~ 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="http://soapinterop.org/types"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:complexType name="foo" final="extension restriction">
+ <xsd:sequence>
+ <xsd:element name="bar" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]