xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject svn commit: r156970 - in xmlbeans/trunk/test/src/misc: common/JiraTestBase.java detailed/JiraRegression1_50Test.java detailed/JiraRegression50_100Test.java
Date Thu, 10 Mar 2005 17:59:48 GMT
Author: cezar
Date: Thu Mar 10 09:59:46 2005
New Revision: 156970

URL: http://svn.apache.org/viewcvs?view=rev&rev=156970
Log:
Contributed by Jacob Danner. Moved some internal thread classes to their respective test classes.

Modified:
    xmlbeans/trunk/test/src/misc/common/JiraTestBase.java
    xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java
    xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java

Modified: xmlbeans/trunk/test/src/misc/common/JiraTestBase.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/common/JiraTestBase.java?view=diff&r1=156969&r2=156970
==============================================================================
--- xmlbeans/trunk/test/src/misc/common/JiraTestBase.java (original)
+++ xmlbeans/trunk/test/src/misc/common/JiraTestBase.java Thu Mar 10 09:59:46 2005
@@ -201,174 +201,7 @@
 
         return XmlBeans.loadXsd(schemaDocs);
     }
-
-    /**
-     * For Testing jira issue 46
-     */
-    public static class RegexThread extends TestThread
-    {
-        private xmlbeans46.UsPhoneNumberDocument phone;
-        Random rand;
-
-        public RegexThread()
-        {
-            super();
-            phone = xmlbeans46.UsPhoneNumberDocument.Factory.newInstance();
-            rand = new Random();
-        }
-
-        /**
-         * Validates a type that uses the following pattern
-         * <xs:restriction base="xs:string">
-         * <xs:pattern value="\d{3}\-\d{3}\-\d{4}"/>
-         * </xs:restriction>
-         */
-        public void run()
-        {
-            try {
-
-                for (int i = 0; i < 9; i++) {
-                    int pre = rand.nextInt(999);
-                    int mid = rand.nextInt(999);
-                    int post = rand.nextInt(9999);
-                    String testVal = ((pre > 100) ? String.valueOf(pre) : "128") + "-"
+
-                            ((mid > 100) ? String.valueOf(mid) : "256") + "-" +
-                            ((post > 1000) ? String.valueOf(post) : "1024");
-
-                    String xmlData = "<xb:usPhoneNumber xmlns:xb=\"http://xmlbeans_46\">"
+
-                            testVal +
-                            "</xb:usPhoneNumber>";
-                    //cannot repro using this method
-                    //phone.setUsPhoneNumber(testVal);
-                    //if (!phone.validate(xm)) {
-                    //    _throwable = new Throwable("Multi Threaded Regular " +
-                    //            "Expression did not validate - " + testVal);
-                    //    if (errors != null && errors.size() > 0)
-                    //        System.err.println("ERROR: " + errors);
-                    //}
-
-                    boolean validated = parseAndValidate(xmlData);
-                    if (!validated) {
-                        System.out.println("Not Valid!!!");
-                    }
-                    System.out.println("Validated " + testVal + " successfully ");
-                }
-                _result = true;
-
-            } catch (Throwable t) {
-                _throwable = t;
-                t.printStackTrace();
-            }
-        }
-
-        private boolean parseAndValidate(String val) throws XmlException
-        {
-            xmlbeans46.UsPhoneNumberDocument xml = xmlbeans46.UsPhoneNumberDocument.Factory.parse(val);
-            return validate(xml);
-        }
-
-        private boolean validate(xmlbeans46.UsPhoneNumberDocument rdd)
-        {
-            Collection errors = new ArrayList();
-            XmlOptions validateOptions = new XmlOptions();
-            validateOptions.setErrorListener(errors);
-            boolean valid = rdd.validate(validateOptions);
-            if (!valid) {
-                for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
-                    XmlError xmlError = (XmlError) iterator.next();
-                    System.out.println("XML Error - " + xmlError.getMessage() + " at\n" +
xmlError.getCursorLocation().xmlText());
-                }
-
-            }
-            return valid;
-        }
-    }
-
-
-    /**
-     * For Testing jira issue 84
-     */
-    public static class XPathThread extends TestThread
-    {
-        public XPathThread()
-        {
-            super();
-        }
-
-        public void run()
-        {
-
-            try {
-                for (int i = 0; i < ITERATION_COUNT; i++) {
-                    switch (i % 2) {
-                        case 0:
-                            runStatusXPath();
-                            break;
-                        case 1:
-                            runDocXPath();
-                            break;
-                        default:
-                            System.out.println("Val: " + i);
-                            break;
-                    }
-
-                }
-                _result = true;
-
-            } catch (Throwable t) {
-                _throwable = t;
-                t.printStackTrace();
-            }
-        }
-
-        public void runStatusXPath()
-        {
-            try {
-                System.out.println("Testing Status");
-                String statusDoc = "<statusreport xmlns=\"http://openuri.org/enumtest\">\n"
+
-                        "  <status name=\"first\" target=\"all\">all</status>\n"
+
-                        "  <status name=\"second\" target=\"all\">few</status>\n"
+
-                        "  <status name=\"third\" target=\"none\">most</status>\n"
+
-                        "  <status name=\"first\" target=\"none\">none</status>\n"
+
-                        "</statusreport>";
-                XmlObject path = XmlObject.Factory.parse(statusDoc, xm);
-                XmlObject[] resSet = path.selectPath("//*:status");
-                Assert.assertTrue(resSet.length + "", resSet.length == 4);
-                resSet = path.selectPath("//*:status[@name='first']");
-                Assert.assertTrue(resSet.length == 2);
-
-            } catch (Throwable t) {
-                _throwable = t;
-                t.printStackTrace();
-            }
-        }
-
-        public void runDocXPath()
-        {
-            try {
-                System.out.println("Testing Doc");
-                String docDoc = "<?xml version=\"1.0\"?>\n" +
-                        "<doc xmlns:ext=\"http://somebody.elses.extension\">\n" +
-                        "  <a test=\"test\" />\n" +
-                        "  <b attr1=\"a1\" attr2=\"a2\"   \n" +
-                        "  xmlns:java=\"http://xml.apache.org/xslt/java\">\n" +
-                        "    <a>\n" +
-                        "    </a> \n" +
-                        "  </b>\n" +
-                        "</doc><!-- -->  ";
-                XmlObject path = XmlObject.Factory.parse(docDoc, xm);
-                XmlObject[] resSet = path.selectPath("//a");
-                Assert.assertTrue(resSet.length == 2);
-                resSet = path.selectPath("//b[@attr2]");
-                Assert.assertTrue(resSet.length == 1);
-
-            } catch (Throwable t) {
-                _throwable = t;
-                t.printStackTrace();
-            }
-        }
-    }
-
+    
     public static abstract class TestThread extends Thread
     {
         protected Throwable _throwable;

Modified: xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java?view=diff&r1=156969&r2=156970
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java (original)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java Thu Mar 10 09:59:46
2005
@@ -17,10 +17,7 @@
 import misc.common.JiraTestBase;
 
 import java.io.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Collections;
+import java.util.*;
 
 import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.tool.SchemaCompiler;
@@ -493,6 +490,90 @@
             Assert.fail("test_jira_xmlbeans49() : Errors found when executing scomp");
         }
     }
+
+    /**
+     * For Testing jira issue 46
+     */
+    public static class RegexThread extends TestThread
+    {
+        private xmlbeans46.UsPhoneNumberDocument phone;
+        Random rand;
+
+        public RegexThread()
+        {
+            super();
+            phone = xmlbeans46.UsPhoneNumberDocument.Factory.newInstance();
+            rand = new Random();
+        }
+
+        /**
+         * Validates a type that uses the following pattern
+         * <xs:restriction base="xs:string">
+         * <xs:pattern value="\d{3}\-\d{3}\-\d{4}"/>
+         * </xs:restriction>
+         */
+        public void run()
+        {
+            try {
+
+                for (int i = 0; i < 9; i++) {
+                    int pre = rand.nextInt(999);
+                    int mid = rand.nextInt(999);
+                    int post = rand.nextInt(9999);
+                    String testVal = ((pre > 100) ? String.valueOf(pre) : "128") + "-"
+
+                            ((mid > 100) ? String.valueOf(mid) : "256") + "-" +
+                            ((post > 1000) ? String.valueOf(post) : "1024");
+
+                    String xmlData = "<xb:usPhoneNumber xmlns:xb=\"http://xmlbeans_46\">"
+
+                            testVal +
+                            "</xb:usPhoneNumber>";
+                    //cannot repro using this method
+                    //phone.setUsPhoneNumber(testVal);
+                    //if (!phone.validate(xm)) {
+                    //    _throwable = new Throwable("Multi Threaded Regular " +
+                    //            "Expression did not validate - " + testVal);
+                    //    if (errors != null && errors.size() > 0)
+                    //        System.err.println("ERROR: " + errors);
+                    //}
+
+                    boolean validated = parseAndValidate(xmlData);
+                    if (!validated) {
+                        System.out.println("Not Valid!!!");
+                    }
+                    System.out.println("Validated " + testVal + " successfully ");
+                }
+                _result = true;
+
+            } catch (Throwable t) {
+                _throwable = t;
+                t.printStackTrace();
+            }
+        }
+
+        private boolean parseAndValidate(String val) throws XmlException
+        {
+            xmlbeans46.UsPhoneNumberDocument xml = xmlbeans46.UsPhoneNumberDocument.Factory.parse(val);
+            return validate(xml);
+        }
+
+        private boolean validate(xmlbeans46.UsPhoneNumberDocument rdd)
+        {
+            Collection errors = new ArrayList();
+            XmlOptions validateOptions = new XmlOptions();
+            validateOptions.setErrorListener(errors);
+            boolean valid = rdd.validate(validateOptions);
+            if (!valid) {
+                for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
+                    XmlError xmlError = (XmlError) iterator.next();
+                    System.out.println("XML Error - " + xmlError.getMessage() + " at\n" +
xmlError.getCursorLocation().xmlText());
+                }
+
+            }
+            return valid;
+        }
+    }
+
+
 
 
 

Modified: xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java?view=diff&r1=156969&r2=156970
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java (original)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java Thu Mar 10 09:59:46
2005
@@ -727,6 +727,92 @@
 
 
 
+    /**
+     * For Testing jira issue 84
+     */
+    public static class XPathThread extends TestThread
+    {
+        public XPathThread()
+        {
+            super();
+        }
+
+        public void run()
+        {
+
+            try {
+                for (int i = 0; i < ITERATION_COUNT; i++) {
+                    switch (i % 2) {
+                        case 0:
+                            runStatusXPath();
+                            break;
+                        case 1:
+                            runDocXPath();
+                            break;
+                        default:
+                            System.out.println("Val: " + i);
+                            break;
+                    }
+
+                }
+                _result = true;
+
+            } catch (Throwable t) {
+                _throwable = t;
+                t.printStackTrace();
+            }
+        }
+
+        public void runStatusXPath()
+        {
+            try {
+                System.out.println("Testing Status");
+                String statusDoc = "<statusreport xmlns=\"http://openuri.org/enumtest\">\n"
+
+                        "  <status name=\"first\" target=\"all\">all</status>\n"
+
+                        "  <status name=\"second\" target=\"all\">few</status>\n"
+
+                        "  <status name=\"third\" target=\"none\">most</status>\n"
+
+                        "  <status name=\"first\" target=\"none\">none</status>\n"
+
+                        "</statusreport>";
+                XmlObject path = XmlObject.Factory.parse(statusDoc, xm);
+                XmlObject[] resSet = path.selectPath("//*:status");
+                Assert.assertTrue(resSet.length + "", resSet.length == 4);
+                resSet = path.selectPath("//*:status[@name='first']");
+                Assert.assertTrue(resSet.length == 2);
+
+            } catch (Throwable t) {
+                _throwable = t;
+                t.printStackTrace();
+            }
+        }
+
+        public void runDocXPath()
+        {
+            try {
+                System.out.println("Testing Doc");
+                String docDoc = "<?xml version=\"1.0\"?>\n" +
+                        "<doc xmlns:ext=\"http://somebody.elses.extension\">\n" +
+                        "  <a test=\"test\" />\n" +
+                        "  <b attr1=\"a1\" attr2=\"a2\"   \n" +
+                        "  xmlns:java=\"http://xml.apache.org/xslt/java\">\n" +
+                        "    <a>\n" +
+                        "    </a> \n" +
+                        "  </b>\n" +
+                        "</doc><!-- -->  ";
+                XmlObject path = XmlObject.Factory.parse(docDoc, xm);
+                XmlObject[] resSet = path.selectPath("//a");
+                Assert.assertTrue(resSet.length == 2);
+                resSet = path.selectPath("//b[@attr2]");
+                Assert.assertTrue(resSet.length == 1);
+
+            } catch (Throwable t) {
+                _throwable = t;
+                t.printStackTrace();
+            }
+        }
+    }
+
+
+
 
 
 }



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


Mime
View raw message