svn commit: r572276 - in /ofbiz/trunk/framework/testtools: dtd/test-suite.xsd src/org/ofbiz/testtools/EntityXmlAssertTest.java src/org/ofbiz/testtools/ModelTestSuite.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r572276 - in /ofbiz/trunk/framework/testtools: dtd/test-suite.xsd src/org/ofbiz/testtools/EntityXmlAssertTest.java src/org/ofbiz/testtools/ModelTestSuite.java

jonesde
Author: jonesde
Date: Mon Sep  3 03:41:28 2007
New Revision: 572276

URL: http://svn.apache.org/viewvc?rev=572276&view=rev
Log:
Changed entity-xml-assert to entity-xml with an action element to specify either assert or load; note that parsing code still supports old entity-xml-assert

Modified:
    ofbiz/trunk/framework/testtools/dtd/test-suite.xsd
    ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/EntityXmlAssertTest.java
    ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java

Modified: ofbiz/trunk/framework/testtools/dtd/test-suite.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/dtd/test-suite.xsd?rev=572276&r1=572275&r2=572276&view=diff
==============================================================================
--- ofbiz/trunk/framework/testtools/dtd/test-suite.xsd (original)
+++ ofbiz/trunk/framework/testtools/dtd/test-suite.xsd Mon Sep  3 03:41:28 2007
@@ -89,13 +89,21 @@
         <xs:attribute type="xs:string" name="name" use="required"/>
     </xs:attributeGroup>
     
-    <xs:element name="entity-xml-assert" substitutionGroup="TestCaseTypes">
+    <xs:element name="entity-xml" substitutionGroup="TestCaseTypes">
         <xs:complexType>
-            <xs:attributeGroup ref="attlist.entity-xml-assert"/>
+            <xs:attributeGroup ref="attlist.entity-xml"/>
         </xs:complexType>
     </xs:element>
-    <xs:attributeGroup name="attlist.entity-xml-assert">
+    <xs:attributeGroup name="attlist.entity-xml">
         <xs:attribute type="xs:string" name="entity-xml-url" use="required"/>
+        <xs:attribute name="action" use="optional" default="assert">
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="assert"/>
+                    <xs:enumeration value="load"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     
     <xs:element name="jython-test" substitutionGroup="TestCaseTypes">

Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/EntityXmlAssertTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/EntityXmlAssertTest.java?rev=572276&r1=572275&r2=572276&view=diff
==============================================================================
--- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/EntityXmlAssertTest.java (original)
+++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/EntityXmlAssertTest.java Mon Sep  3 03:41:28 2007
@@ -24,6 +24,7 @@
 import org.w3c.dom.Element;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.util.EntityDataAssert;
+import org.ofbiz.entity.util.EntitySaxReader;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.location.FlexibleLocation;
@@ -38,6 +39,7 @@
     public static final String module = ServiceTest.class.getName();
 
     protected String entityXmlUrlString;
+    protected String action;
 
     /**
      * @param modelTestSuite
@@ -45,6 +47,8 @@
     public EntityXmlAssertTest(String caseName, ModelTestSuite modelTestSuite, Element mainElement) {
         super(caseName, modelTestSuite);
         this.entityXmlUrlString = mainElement.getAttribute("entity-xml-url");
+        this.action = mainElement.getAttribute("action");
+        if (UtilValidate.isEmpty(this.action)) this.action = "assert";
     }
 
     public int countTestCases() {
@@ -61,13 +65,21 @@
 
     public void run(TestResult result) {
         result.startTest(this);
-
+        
         try {
             URL entityXmlURL = FlexibleLocation.resolveLocation(entityXmlUrlString);
             GenericDelegator delegator = modelTestSuite.getDelegator();
             List errorMessages = new ArrayList();
 
-            EntityDataAssert.assertData(entityXmlURL, delegator, errorMessages);
+            if ("assert".equals(this.action)) {
+                EntityDataAssert.assertData(entityXmlURL, delegator, errorMessages);
+            } else if ("load".equals(this.action)) {
+                EntitySaxReader reader = new EntitySaxReader(delegator);
+                long numberRead = reader.parse(entityXmlURL);
+            } else {
+                // uh oh, bad value
+                result.addFailure(this, new AssertionFailedError("Bad value [" + this.action + "] for action attribute of entity-xml element"));
+            }
 
             if (UtilValidate.isNotEmpty(errorMessages)) {
                 Iterator failureIterator = errorMessages.iterator();

Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java?rev=572276&r1=572275&r2=572276&view=diff
==============================================================================
--- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java (original)
+++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java Mon Sep  3 03:41:28 2007
@@ -96,7 +96,10 @@
                     this.testList.add(new ServiceTest(caseName, this, childElement));
                 } else if ("simple-method-test".equals(nodeName)) {
                     this.testList.add(new SimpleMethodTest(caseName, this, childElement));
+                } else if ("entity-xml".equals(nodeName)) {
+                    this.testList.add(new EntityXmlAssertTest(caseName, this, childElement));
                 } else if ("entity-xml-assert".equals(nodeName)) {
+                    // this is the old, deprecated name for the element, changed because it now does assert or load
                     this.testList.add(new EntityXmlAssertTest(caseName, this, childElement));
                 } else if ("jython-test".equals(nodeName)) {
                     this.testList.add(new JythonTest(caseName, this, childElement));