xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject svn commit: r164273 - in /xmlbeans/trunk/test/src: scomp/derivation/restriction/detailed/EnumTest.java xmlcursor/xquery/detailed/NISTSuiteRunner.java
Date Fri, 22 Apr 2005 19:25:19 GMT
Author: cezar
Date: Fri Apr 22 12:25:17 2005
New Revision: 164273

URL: http://svn.apache.org/viewcvs?rev=164273&view=rev
Log:
Contributed by Rajiv Balachandran Adding test case for enum restriction issue for simple types


Added:
    xmlbeans/trunk/test/src/scomp/derivation/restriction/detailed/EnumTest.java
Modified:
    xmlbeans/trunk/test/src/xmlcursor/xquery/detailed/NISTSuiteRunner.java

Added: xmlbeans/trunk/test/src/scomp/derivation/restriction/detailed/EnumTest.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/scomp/derivation/restriction/detailed/EnumTest.java?rev=164273&view=auto
==============================================================================
--- xmlbeans/trunk/test/src/scomp/derivation/restriction/detailed/EnumTest.java (added)
+++ xmlbeans/trunk/test/src/scomp/derivation/restriction/detailed/EnumTest.java Fri Apr 22
12:25:17 2005
@@ -0,0 +1,84 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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 scomp.derivation.restriction.detailed;
+
+import scomp.common.BaseCase;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.apache.xmlbeans.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ *
+ */
+public class EnumTest extends BaseCase
+ {
+    /*
+    * Refer CR199528, CR191369.
+    * This fails in V1 and the case is added here to ensure compliance in v2.
+    */
+    public void testEnumRestrictionScomp() throws Exception {
+        String xsdAsString = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+                "\n" +
+                "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
+                "\n" +
+                " <xs:element name=\"ActionTypeElem\" type=\"ACTION_TYPE\" />\n" +
+                " <xs:element name=\"VIPActionTypeElem\" type=\"VIP_ACTION_TYPE\" />\n"
+
+                "\n" +
+                " <xs:simpleType name=\"ACTION_TYPE\">\n" +
+                "  <xs:restriction base=\"xs:string\">\n" +
+                "   <xs:enumeration value=\"PROVIDE\"/>\n" +
+                "   <xs:enumeration value=\"MODIFY\"/>\n" +
+                "   <xs:enumeration value=\"CEASE\"/>\n" +
+                "  </xs:restriction>\n" +
+                " </xs:simpleType>\n" +
+                "\n" +
+                " <xs:simpleType name=\"VIP_ACTION_TYPE\">\n" +
+                "  <xs:restriction base=\"ACTION_TYPE\">\n" +
+                "   <xs:enumeration value=\"QUERY\"/>\n" +
+                "  </xs:restriction>\n" +
+                " </xs:simpleType>\n" +
+                "\n" +
+                "</xs:schema>";
+
+        // load schema file as SchemaDocument XmlObject
+        SchemaDocument sd = SchemaDocument.Factory.parse(xsdAsString.toString());
+
+        // compile loaded XmlObject
+        try
+        {
+        XmlOptions options = new XmlOptions();
+        List errors = new ArrayList();
+        options.setErrorListener(errors);
+        SchemaTypeSystem sts = XmlBeans.compileXsd((XmlObject[]) Collections.singletonList(sd).toArray(new
XmlObject[]{}),
+                XmlBeans.getContextTypeLoader(),
+                options);
+        }
+
+        catch(XmlException xme)
+        {
+            System.out.println(xme.getError().getMessage());
+            assertEquals(XmlErrorCodes.DATATYPE_ENUM_RESTRICTION,xme.getError().getErrorCode());
+        }
+        catch (NullPointerException npe)
+        {
+            fail("Null Pointer Exception thrown for invalid tyoe restriction attempt for
Enum values");
+        }
+
+    }
+}

Modified: xmlbeans/trunk/test/src/xmlcursor/xquery/detailed/NISTSuiteRunner.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/xquery/detailed/NISTSuiteRunner.java?rev=164273&r1=164272&r2=164273&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/xquery/detailed/NISTSuiteRunner.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/xquery/detailed/NISTSuiteRunner.java Fri Apr 22 12:25:17
2005
@@ -26,13 +26,13 @@
 import noNamespace.TestCase;
 import xmlcursor.xquery.common.AbstractRunner;
 
-/**
- *
 
 public class NISTSuiteRunner extends AbstractRunner
 
 
 {
+/**
+ *
 
     public static Test suite()
         throws java.lang.Exception
@@ -100,5 +100,5 @@
         "testSuite/NIST/files/catalog.xml";
     TestSuiteDocument.TestSuite.TestGroup[] group;
 
+*/
 }
-*/
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org


Mime
View raw message