You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2002/04/11 10:07:25 UTC

cvs commit: xml-batik/test-resources/org/apache/batik/test/svg error.svg errorAndEntries.svg invalidTestResultElementsNumber.svg missingOrEmptyErrorCode.svg processingError.svg success.svg unexpectedResultValue.svg

vhardy      02/04/11 01:07:25

  Modified:    test-resources/org/apache/batik/test regard.xml
                        unitTesting.xml
  Added:       test-sources/org/apache/batik/css/dom
                        EcmaScriptCSSDOMTest.java
               test-sources/org/apache/batik/test/svg
                        SelfContainedSVGOnLoadTest.java
                        SelfContainedSVGOnLoadTestValidator.java
               test-resources/org/apache/batik/css/dom rgbTest.svg
                        unitTesting.xml
               test-resources/org/apache/batik/test/svg error.svg
                        errorAndEntries.svg
                        invalidTestResultElementsNumber.svg
                        missingOrEmptyErrorCode.svg processingError.svg
                        success.svg unexpectedResultValue.svg
  Log:
  New test which allows tests, written in ECMAScript, to be integrated in our test infrastructure. Tests need to run in response to the document's 'onload' event and report their result in a <testResult> element (and children <errorDescriptionEntry>) metadata. That metadata should be in the name space 'http://xml.apache.org/batik/test' to be usable by the infrastructure. See test-resources/org/apache/batik/css/dom/rgbTest.svg for an example (and related test-resources/org/apache/batik/css/dom/unitTesting.xml file)
  
  Revision  Changes    Path
  1.1                  xml-batik/test-sources/org/apache/batik/css/dom/EcmaScriptCSSDOMTest.java
  
  Index: EcmaScriptCSSDOMTest.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css.dom;
  
  import org.apache.batik.test.svg.SelfContainedSVGOnLoadTest;
  
  /**
   * Helper class to simplify writing the unitTesting.xml file for 
   * CSS DOM Tests.
   *
   * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
   * @version $Id: EcmaScriptCSSDOMTest.java,v 1.1 2002/04/11 08:07:24 vhardy Exp $
   */
  
  public class EcmaScriptCSSDOMTest extends SelfContainedSVGOnLoadTest {
      public void setId(String id){
          super.setId(id);
          svgURL = resolveURL("test-resources/org/apache/batik/css/dom/" + id + ".svg");
      }
  }
  
  
  
  1.1                  xml-batik/test-sources/org/apache/batik/test/svg/SelfContainedSVGOnLoadTest.java
  
  Index: SelfContainedSVGOnLoadTest.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.test.svg;
  
  import java.io.File;
  import java.io.IOException;
  
  import java.net.URL;
  import java.net.MalformedURLException;
  
  import org.apache.batik.bridge.BaseScriptingEnvironment;
  import org.apache.batik.bridge.BridgeContext;
  import org.apache.batik.bridge.BridgeException;
  
  import org.apache.batik.bridge.GVTBuilder;
  import org.apache.batik.bridge.UserAgent;
  import org.apache.batik.bridge.UserAgentAdapter;
  
  import org.apache.batik.test.AbstractTest;
  import org.apache.batik.test.DefaultTestReport;
  import org.apache.batik.test.TestReport;
  
  import org.apache.batik.util.XMLResourceDescriptor;
  
  import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
  
  import org.w3c.dom.Attr;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  import org.w3c.dom.NamedNodeMap;
  
  /**
   * This test takes an SVG file as an input. It processes the input SVG
   * (meaning it turns it into a GVT tree) and then dispatches the 'onload'
   * event.
   * 
   * The SVG input file should contain script that will position the 
   * result of the test in the DOM using the following namespace: <br />
   * xmlns:test="http://xml.apache.org/batik/test" <br />
   * 
   * The result should be set in the <code>result</code> attribute of the
   * &lt;testResult&gt; element by the script embeded in the input SVG
   * test file. <br />
   * 
   * Sample input SVG file:<br /><code>
   * &lt;svg ... onload="runTest(evt)" xmlns:test="http://xml.apache.org/batik/test" &gt;
   *   &lt;script type="text/ecmascript"&gt;
   *   function runTest(evt) {
   *      ...; // do some test
   *      var rootSvg = document.getDocumentElement();
   *      var result = document.createElementNS("http://xml.apache.org/batik/test",
   *                                            "testResult");
   *      result.setAttributeNS(null, "result", "failed");
   *      result.setAttributeNS(null, "errorCode", "org.apache.batik.css.dom.wrong.computed.value");
   *      rootSvg.appendChild(result);
   *   }
   * &lt;/script&gt;
   * &lt;/svg&gt;</code>
   *
   * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
   * @version $Id: SelfContainedSVGOnLoadTest.java,v 1.1 2002/04/11 08:07:24 vhardy Exp $
   */
  public class SelfContainedSVGOnLoadTest extends AbstractTest {
      /**
       * Error when the input file cannot be loaded into a
       * Document object
       * {0} = IOException message
       */
      public static final String ERROR_CANNOT_LOAD_SVG_DOCUMENT
          = "SelfContainedSVGOnLoadTest.error.cannot.load.svg.document";
  
      /**
       * Error while building the GVT tree or dispatching the 
       * 'onload' event.
       */
      public static final String ERROR_WHILE_PROCESSING_SVG_DOCUMENT
          = "SelfContainedSVGOnLoadTest.error.while.processing.svg.document";
  
      /**
       * There is either 0 or more than one <testResult> elements in
       * the document after dispatching the onload event.
       */
      public static final String ERROR_UNEXPECTED_NUMBER_OF_TEST_RESULT_ELEMENTS
          = "SelfContainedSVGOnLoadTest.error.unexpected.number.of.test.result.elements";
  
      /**
       * The 'result' attribute value is neither 'passed' nor 'failed'
       */
      public static final String ERROR_UNEXPECTED_RESULT_VALUE
          = "SelfContainedSVGOnLoadTest.error.unexpected.result.value";
  
      /**
       * The result was 'failed' but there was no 'errorCode' attribute or
       * it was the empty string
       */
      public static final String ERROR_MISSING_OR_EMPTY_ERROR_CODE_ON_FAILED_TEST
          = "SelfContainedSVGOnLoadTest.error.missing.or.empty.error.code.on.failed.test";
  
      /**
       * Entry describing the error
       */
      public static final String ENTRY_KEY_ERROR_DESCRIPTION 
          = "SelfContainedSVGOnLoadTest.entry.key.error.description";
  
      /**
       * Entry describing the number of testResult elements found in the 
       * document after dispatching onload.
       */
      public static final String ENTRY_KEY_NUMBER_OF_TEST_RESULT_ELEMENTS
          = "SelfContainedSVGOnLoadTest.entry.key.number.of.test.result.elements";
  
      /**
       * Entry describing the result value (different from 'passed' or 'failed'
       * found in the 'result' attribute.
       */
      public static final String ENTRY_KEY_RESULT_VALUE
          = "SelfContainedSVGOnLoadTest.entry.key.result.value";
  
      /**
       * Test Namespace
       */
      public static final String testNS = "http://xml.apache.org/batik/test";
  
      /**
       * Test Constants
       */
      public static final String TAG_TEST_RESULT = "testResult";
      public static final String TAG_ERROR_DESCRIPTION_ENTRY = "errorDescriptionEntry";
      public static final String ATTRIBUTE_RESULT = "result";
      public static final String ATTRIBUTE_KEY = "id";
      public static final String ATTRIBUTE_VALUE = "value";
      public static final String TEST_RESULT_PASSED = "passed";
      public static final String TEST_RESULT_FAILED = "failed";
  
      /**
       * The URL for the input SVG document to be tested
       */
      protected String svgURL;
  
      /**
       * @param svgURL the URL string for the SVG document being tested
       */
      public SelfContainedSVGOnLoadTest(String svgURL){
          this.svgURL = resolveURL(svgURL);
      }
  
      /**
       * Default constructor
       */
      protected SelfContainedSVGOnLoadTest(){
      }
  
      /**
       * Resolves the input string as follows.
       * + First, the string is interpreted as a file description.
       *   If the file exists, then the file name is turned into
       *   a URL.
       * + Otherwise, the string is supposed to be a URL. If it
       *   is an invalid URL, an IllegalArgumentException is thrown.
       */
      protected String resolveURL(String url){
          // Is url a file?
          File f = (new File(url)).getAbsoluteFile();
          if(f.getParentFile().exists()){
              try{
                  return f.toURL().toString();
              }catch(MalformedURLException e){
                  throw new IllegalArgumentException();
              }
          }
          
          // url is not a file. It must be a regular URL...
          try{
              return (new URL(url)).toString();
          }catch(MalformedURLException e){
              throw new IllegalArgumentException(url);
          }
      }
  
  
      /**
       * Run this test and produce a report.
       * The test goes through the following steps: <ul>
       * <li>load the input SVG into a Document</li>
       * <li>build the GVT tree corresponding to the 
       *     Document and dispatch the 'onload' event</li>
       * <li>looks for one and only one &lt;testResult&gt; element in
       *     the Document. This is used to build the returned 
       *     TestReport</li>
       * </ul>
       *
       */
      public TestReport runImpl() throws Exception{
          DefaultTestReport report 
              = new DefaultTestReport(this);
  
          //
          // First step: 
          //
          // Load the input SVG into a Document object
          //
          String parserClassName = XMLResourceDescriptor.getXMLParserClassName();
          SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parserClassName);
          Document doc = null;
  
          try {
              doc = f.createDocument(svgURL);
          } catch(IOException e){
              report.setErrorCode(ERROR_CANNOT_LOAD_SVG_DOCUMENT);
              report.addDescriptionEntry(ENTRY_KEY_ERROR_DESCRIPTION,
                                         e.getMessage());
              report.setPassed(false);
              return report;
          } catch(Exception e){
              report.setErrorCode(ERROR_CANNOT_LOAD_SVG_DOCUMENT);
              report.addDescriptionEntry(ENTRY_KEY_ERROR_DESCRIPTION,
                                         e.getMessage());
              report.setPassed(false);
              return report;
          }
  
          //
          // Second step:
          // 
          // Now that the SVG file has been loaded, build
          // a GVT Tree from it
          //
          UserAgent userAgent = new UserAgentAdapter();
          GVTBuilder builder = new GVTBuilder();
          BridgeContext ctx = new BridgeContext(userAgent);
          ctx.setDynamic(true);
  
          try {
              builder.build(ctx, doc);
              BaseScriptingEnvironment scriptEnvironment 
                  = new BaseScriptingEnvironment(ctx);
              scriptEnvironment.loadScripts();
              scriptEnvironment.dispatchSVGLoadEvent();
          } catch (BridgeException e){
              report.setErrorCode(ERROR_WHILE_PROCESSING_SVG_DOCUMENT);
              report.addDescriptionEntry(ENTRY_KEY_ERROR_DESCRIPTION,
                                         e.getMessage());
              report.setPassed(false);
              return report;
          } catch(Exception e){
              report.setErrorCode(ERROR_WHILE_PROCESSING_SVG_DOCUMENT);
              report.addDescriptionEntry(ENTRY_KEY_ERROR_DESCRIPTION,
                                         e.getMessage());
              report.setPassed(false);
              return report;
          }
  
          //
          // Final step:
          //
          // Look for one and only one <testResult> element
          //
          NodeList testResultList = doc.getElementsByTagNameNS(testNS,
                                                               TAG_TEST_RESULT);
  
          // Check that there is one and only one testResult element
          if(testResultList.getLength() != 1){
              report.setErrorCode(ERROR_UNEXPECTED_NUMBER_OF_TEST_RESULT_ELEMENTS);
              report.addDescriptionEntry(ENTRY_KEY_NUMBER_OF_TEST_RESULT_ELEMENTS,
                                    "" + testResultList.getLength());
              report.setPassed(false);
              return report;
          }
  
          Element testResult = (Element)testResultList.item(0);
          
          // Now, get the result attribute. Whould be either "passed" or "failed"
          String result = testResult.getAttributeNS(null, ATTRIBUTE_RESULT);
          boolean passed = true;
          if(TEST_RESULT_PASSED.equals(result)){
              // OK
          } else if (TEST_RESULT_FAILED.equals(result)){
              passed = false;
          } else {
              report.setErrorCode(ERROR_UNEXPECTED_RESULT_VALUE);
              report.addDescriptionEntry(ENTRY_KEY_RESULT_VALUE, result);
              report.setPassed(false);
              return report;
          }
  
          // If the test failed, then there should be an error code
          if( !passed ){
              String errorCode = testResult.getAttributeNS(null, "errorCode");
              if("".equals(errorCode)){
                  report.setErrorCode(ERROR_MISSING_OR_EMPTY_ERROR_CODE_ON_FAILED_TEST);
                  report.setPassed(false);
                  return report;
              }
  
              // We got an error code, set it on the report object
              report.setErrorCode(errorCode);
  
              // Now, add descriptions from children <errorDescriptionEntry> elements
              NodeList desc = testResult.getElementsByTagNameNS(testNS,
                                                                TAG_ERROR_DESCRIPTION_ENTRY);
              int nDesc = desc.getLength();
              for (int i=0; i<nDesc; i++){
                  Element entry = (Element)desc.item(i);
                  String key = entry.getAttributeNS(null, ATTRIBUTE_KEY);
                  String value = entry.getAttributeNS(null, ATTRIBUTE_VALUE);
                  report.addDescriptionEntry(key, value);
              }
              report.setPassed(false);
              return report;
          }
  
          return report;
      }
  
  }
  
  
  
  
  1.1                  xml-batik/test-sources/org/apache/batik/test/svg/SelfContainedSVGOnLoadTestValidator.java
  
  Index: SelfContainedSVGOnLoadTestValidator.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.batik.test.svg;
  
  import java.util.Vector;
  
  import org.apache.batik.test.TestReport;
  
  import org.apache.batik.test.AbstractTest;
  import org.apache.batik.test.DefaultTestSuite;
  
  /**
   * This test validates the operation of SelfContainedSVGOnLoadTest.
   * It is a test agregation which points to several tests which 
   * correspond to expected error conditions. The test simply 
   * validates that the expected error conditions are properly 
   * detected and reported.
   *
   * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
   * @version $Id: SelfContainedSVGOnLoadTestValidator.java,v 1.1 2002/04/11 08:07:24 vhardy Exp $
   */
  public class SelfContainedSVGOnLoadTestValidator extends DefaultTestSuite {
      /**
       * Error codes
       */
      public static final String ERROR_UNEXPECTED_TEST_RESULT =
          "SelfContainedSVGOnLoadTestValidator.error.unexpected.test.result";
  
      public static final String ERROR_UNEXPECTED_ERROR_CODE =
          "SelfContainedSVGOnLoadTestValidator.error.unexpected.error.code";
  
      public static final String ERROR_UNEXPECTED_NUMBER_OF_DESCRIPTION_ENTRIES
          = "SelfContainedSVGOnLoadTestValidator.error.unexpected.number.of.description.entries";
  
      public static final String ERROR_UNEXPECTED_TEST_FAILURE
          = "SelfContainedSVGOnLoadTestValidator.error.unexpected.test.failure";
  
      public static final String ERROR_UNEXPECTED_DESCRIPTION_ENTRY
          = "SelfContainedSVGOnLoadTestValidator.error.unexpected.description.entry";
  
      public static final String ENTRY_ERROR_CODE = 
          "SelfContainedSVGOnLoadTestValidator.entry.error.code";
  
      public static final String ENTRY_EXPECTED_ERROR_CODE = 
          "SelfContainedSVGOnLoadTestValidator.entry.expected.error.code";
  
      public static final String ENTRY_NUMBER_OF_DESCRIPTION = 
          "SelfContainedSVGOnLoadTestValidator.entry.number.of.description";
  
      public static final String ENTRY_EXPECTED_NUMBER_OF_DESCRIPTION = 
          "SelfContainedSVGOnLoadTestValidator.entry.expected.number.of.description";
  
      public static final String ENTRY_KEY = 
          "SelfContainedSVGOnLoadTestValidator.entry.key";
  
      public static final String ENTRY_EXPECTED_KEY = 
          "SelfContainedSVGOnLoadTestValidator.entry.expected.key";
  
      
      /**
       * URLs for children tests
       */
      public static final String invalidURL 
          = "invalidURL";
      public static final String processingErrorURL 
          = "test-resources/org/apache/batik/test/svg/processingError.svg";
      public static final String invalidTestResultElementsNumberURL 
          = "test-resources/org/apache/batik/test/svg/invalidTestResultElementsNumber.svg";
      public static final String unexpectedResultValueURL 
          = "test-resources/org/apache/batik/test/svg/unexpectedResultValue.svg";
      public static final String missingOrEmptyErrorCodeURL
          = "test-resources/org/apache/batik/test/svg/missingOrEmptyErrorCode.svg";
      public static final String errorURL 
          = "test-resources/org/apache/batik/test/svg/error.svg";
      public static final String errorAndEntriesURL 
          = "test-resources/org/apache/batik/test/svg/errorAndEntries.svg";
      public static final String successURL 
          = "test-resources/org/apache/batik/test/svg/success.svg";
  
      
      public SelfContainedSVGOnLoadTestValidator(){
          addTest(new CannotLoadSVGDocument());
          addTest(new ProcessingError());
          addTest(new InvalidTestResultElementsNumber());
          addTest(new UnexpectedResultValue());
          addTest(new MissingOrEmptyErrorCode());
          addTest(new ReportError());
          addTest(new ReportSuccess());
          addTest(new ReportErrorAndEntries());
      }
  
      static class ReportErrorAndEntries extends DefaultErrorTest {
          public ReportErrorAndEntries() {
              super(errorAndEntriesURL,
                    "can.you.read.this.error.code",
                    new String[] { "can.you.read.this.first.entry",
                                   "can.you.read.this.second.entry" });
          }
      }
  
      static class ReportError extends DefaultErrorTest {
          public ReportError(){
              super(errorURL,
                     "can.you.read.this.error.code",
                     null);
          }
      }
  
      static class ReportSuccess extends AbstractTest {
          public TestReport rumImpl() throws Exception {
              SelfContainedSVGOnLoadTest t = new SelfContainedSVGOnLoadTest(successURL);
              TestReport tr = t.run();
  
              if (!tr.hasPassed()) {
                  return reportError(ERROR_UNEXPECTED_TEST_FAILURE);
              }
  
              return reportSuccess();
          }
      }
      
      static class MissingOrEmptyErrorCode extends DefaultErrorTest {
          public MissingOrEmptyErrorCode(){
              super(missingOrEmptyErrorCodeURL,
                    SelfContainedSVGOnLoadTest.ERROR_MISSING_OR_EMPTY_ERROR_CODE_ON_FAILED_TEST,
                    null);
          }
      }
  
      static class UnexpectedResultValue extends DefaultErrorTest{
          public UnexpectedResultValue(){
              super(unexpectedResultValueURL,
                    SelfContainedSVGOnLoadTest.ERROR_UNEXPECTED_RESULT_VALUE,
                    new String[]{SelfContainedSVGOnLoadTest.ENTRY_KEY_RESULT_VALUE});
          }
      }
  
  
      static class InvalidTestResultElementsNumber extends DefaultErrorTest{
          public InvalidTestResultElementsNumber(){
              super(invalidTestResultElementsNumberURL,
                    SelfContainedSVGOnLoadTest.ERROR_UNEXPECTED_NUMBER_OF_TEST_RESULT_ELEMENTS,
                    new String[]{SelfContainedSVGOnLoadTest.ENTRY_KEY_NUMBER_OF_TEST_RESULT_ELEMENTS});
          }
      }
  
      static class ProcessingError extends DefaultErrorTest{
          public ProcessingError(){
              super(processingErrorURL,
                    SelfContainedSVGOnLoadTest.ERROR_WHILE_PROCESSING_SVG_DOCUMENT,
                    new String[]{SelfContainedSVGOnLoadTest.ENTRY_KEY_ERROR_DESCRIPTION});
          }
      }
  
      static class CannotLoadSVGDocument extends DefaultErrorTest {
          public CannotLoadSVGDocument(){
              super(invalidURL,
                    SelfContainedSVGOnLoadTest.ERROR_CANNOT_LOAD_SVG_DOCUMENT,
                    new String[] {SelfContainedSVGOnLoadTest.ENTRY_KEY_ERROR_DESCRIPTION});
          }
      }
      
      static class DefaultErrorTest extends AbstractTest{
          String svgURL;
          String expectedErrorCode;
          String[] expectedEntryCodes;
          
          public DefaultErrorTest(String svgURL,
                                  String expectedErrorCode,
                                  String[] expectedEntryCodes
                                  ){
              this.svgURL = svgURL;
              this.expectedErrorCode = expectedErrorCode;
              this.expectedEntryCodes = expectedEntryCodes;
          }
          
          public TestReport runImpl() throws Exception {
              SelfContainedSVGOnLoadTest t 
                  = new SelfContainedSVGOnLoadTest(svgURL);
              TestReport tr = t.run();
              
              if(tr.hasPassed()){
                  return reportError(ERROR_UNEXPECTED_TEST_RESULT);
              }
              
              if(tr.getErrorCode() != expectedErrorCode){
                  TestReport r = reportError(ERROR_UNEXPECTED_ERROR_CODE);
                  r.addDescriptionEntry(ENTRY_ERROR_CODE, tr.getErrorCode());
                  r.addDescriptionEntry(ENTRY_EXPECTED_ERROR_CODE, 
                                         expectedErrorCode);
                  return r;
              }
              
              // Check that there is a description entry
              TestReport.Entry[] desc = tr.getDescription();
              int nDesc = 0, enDesc = 0;
              if (desc != null){
                  nDesc = desc.length;
              }
              if (expectedEntryCodes != null){
                  enDesc = expectedEntryCodes.length;
              }
              
              if (nDesc != enDesc){
                  TestReport r = reportError(ERROR_UNEXPECTED_NUMBER_OF_DESCRIPTION_ENTRIES);
                  
                  r.addDescriptionEntry(ENTRY_NUMBER_OF_DESCRIPTION,
                                        "" + nDesc);
                  r.addDescriptionEntry(ENTRY_EXPECTED_NUMBER_OF_DESCRIPTION,
                                        "" + enDesc);
                  return r;
              }
              
              if (nDesc > 0){
                  Vector veDesc = new Vector();
                  for(int i=0; i<nDesc; i++){
                      veDesc.add(expectedEntryCodes[i]);
                  }
  
                  for(int i=0; i<nDesc; i++){
                      String key = desc[i].getKey();
                      if (key == null || !veDesc.contains(key)){
                          TestReport r = reportError(ERROR_UNEXPECTED_DESCRIPTION_ENTRY);
                          if (key != null){
                              r.addDescriptionEntry(ENTRY_KEY, key);
                              r.addDescriptionEntry(ENTRY_EXPECTED_KEY, t.ENTRY_KEY_NUMBER_OF_TEST_RESULT_ELEMENTS);
                          }
                          return r;
                      }
                  }
              }
              
              return reportSuccess();
          }
      }
      
  }
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/css/dom/rgbTest.svg
  
  Index: rgbTest.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This test checks that the various RGB values read from the SVGColor       -->
  <!-- interface return accurate values.                                         -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @author shillion@ilog.fr                                                  -->
  <!-- @version $Id: rgbTest.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
    <test:testResult id="testResult" />
  
    <script type="text/ecmascript"><![CDATA[
     var testNS = "http://xml.apache.org/batik/test";
  
     function runTest() {
       var result = document.getElementById("testResult");
  
       var elt = document.getElementById("targetElement");
       result.setAttributeNS(null, "result", "failed");
  
       if (elt == null){
          result.setAttributeNS(null, "errorCode", "cannot.find.test.element");
          var entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "missing.element.id");
          entry.setAttributeNS(null, "value", "targetElement");
          result.appendChild(entry);
          return;
       }
  
       var decl = elt.getStyle();
  
       if (decl == null){
          result.setAttributeNS(null, "errorCode", "getStyle() returned null");
          return;
       }
  
       var val = decl.getPropertyCSSValue("fill");
  
       if ( val == null ){
          result.setAttributeNS(null, "errorCode", "CSSStyleDeclaration.getPropertyCSSValue returned null");
          return;
       }
  
       if (val.red != 1){
          result.setAttributeNS(null, "errorCode", "invalid red component");
          var entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "expected.red");
          entry.setAttributeNS(null, "value", "1");
          result.appendChild(entry);
          entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "found.red");
          entry.setAttributeNS(null, "value", "" + val.red);
          result.appendChild(entry);
          return;
       }
  
       if (val.green != 1){
          result.setAttributeNS(null, "errorCode", "invalid green component");
          var entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "expected.green");
          entry.setAttributeNS(null, "value", "1");
          result.appendChild(entry);
          entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "found.green");
          entry.setAttributeNS(null, "value", "" + val.green);
          result.appendChild(entry);
          return;
       }
  
       if (val.blue != 1){
          result.setAttributeNS(null, "errorCode", "invalid blue component");
          var entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "expected.blue");
          entry.setAttributeNS(null, "value", "1");
          result.appendChild(entry);
          entry = document.createElementNS(testNS, "errorDescriptionEntry");
          entry.setAttributeNS(null, "id", "found.blue");
          entry.setAttributeNS(null, "value", "" + val.blue);
          result.appendChild(entry);
          return;
       }
  
      result.setAttributeNS(null, "result", "passed");
     }
    ]]></script>
  
    <g fill="blue">
      <rect x="10%" y="10%" width="80%" height="80%"
            style="opacity:0.5; fill: rgb(1,2,3)" id="targetElement" onclick="f()"/>
    </g>
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/css/dom/unitTesting.xml
  
  Index: unitTesting.xml
  ===================================================================
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- @author vincent.hardy@eng.sun.com                                         -->
  <!-- @version $Id: unitTesting.xml,v 1.1 2002/04/11 08:07:24 vhardy Exp $   -->
  <!-- ========================================================================= -->
  <testSuite id="css.dom.unitTesting" name="CSS DOM - Unit Testing"
      class="org.apache.batik.css.dom.EcmaScriptCSSDOMTest">
  
      <testGroup id="basic" name="Basic CSS DOM Testing">
          <test id="rgbTest" />
      </testGroup>
  
  </testSuite>
  
  
  1.23      +2 -1      xml-batik/test-resources/org/apache/batik/test/regard.xml
  
  Index: regard.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/regard.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- regard.xml	19 Mar 2002 15:39:46 -0000	1.22
  +++ regard.xml	11 Apr 2002 08:07:24 -0000	1.23
  @@ -11,7 +11,7 @@
   <!-- regression testing.                                                       -->
   <!--                                                                           -->
   <!-- @author vincent.hardy@eng.sun.com                                         -->
  -<!-- @version $Id: regard.xml,v 1.22 2002/03/19 15:39:46 tkormann Exp $  -->
  +<!-- @version $Id: regard.xml,v 1.23 2002/04/11 08:07:24 vhardy Exp $  -->
   <!-- ========================================================================= -->
   <testRun id="regard" name="Batik Standard Regression Test Run">
       <testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" > 
  @@ -54,6 +54,7 @@
       <testSuite href="file:test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml" />
       <testSuite href="file:test-resources/org/apache/batik/ext/awt/geom/unitTesting.xml" /> 
       <testSuite href="file:test-resources/org/apache/batik/util/unitTesting.xml" />
  +    <testSuite href="file:test-resources/org/apache/batik/css/dom/unitTesting.xml" /> 
       <testSuite href="file:test-resources/org/apache/batik/dom/unitTesting.xml" /> 
       <testSuite href="file:test-resources/org/apache/batik/gvt/unitTesting.xml" /> 
       <testSuite href="file:test-resources/org/apache/batik/parser/unitTesting.xml" /> 
  
  
  
  1.6       +6 -1      xml-batik/test-resources/org/apache/batik/test/unitTesting.xml
  
  Index: unitTesting.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/unitTesting.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- unitTesting.xml	16 Oct 2001 10:39:08 -0000	1.5
  +++ unitTesting.xml	11 Apr 2002 08:07:24 -0000	1.6
  @@ -8,7 +8,7 @@
   
   <!-- ========================================================================= -->
   <!-- @author vincent.hardy@eng.sun.com                                         -->
  -<!-- @version $Id: unitTesting.xml,v 1.5 2001/10/16 10:39:08 vhardy Exp $ -->
  +<!-- @version $Id: unitTesting.xml,v 1.6 2002/04/11 08:07:24 vhardy Exp $ -->
   <!-- ========================================================================= -->
   <testSuite id="test.unitTesting" name="Test Module - Unit Testing">
       <!-- ========================================================================== -->
  @@ -20,6 +20,11 @@
       <!-- Validates that the SVGRenderingAccuracyTest class is operating as expected -->
       <!-- ========================================================================== -->
       <test id="svgRenderingAccuracyTestValidator" class="org.apache.batik.test.svg.SVGRenderingAccuracyTestValidator" />
  +
  +    <!-- ============================================================================ -->
  +    <!-- Validates that the SelfContainedSVGOnLoadTest class is operating as expected -->
  +    <!-- ============================================================================ -->
  +    <test id="selfContainedSVGOnLoadTestValidator" class="org.apache.batik.test.svg.SelfContainedSVGOnLoadTestValidator" />
   
       <!-- ========================================================================== -->
       <!-- Validates that the SVGAccuracyTest class is operating as expected          -->
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/error.svg
  
  Index: error.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of a self contained test which reports a failure.                -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: error.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
      <test:testResult id="testResult" result="passed" />
  
      <script type="text/ecmascript"><![CDATA[
      var testNS = "http://xml.apache.org/batik/test";
  
      function runTest(evt){
          var tr = document.getElementById("testResult");
          tr.setAttributeNS(null, "result", "failed");
          tr.setAttributeNS(null, "errorCode", "can.you.read.this.error.code");
      }
  
      ]]></script>
  
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/errorAndEntries.svg
  
  Index: errorAndEntries.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of a self contained test which reports a failure and entries to  -->
  <!-- describe the failure.                                                     -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: errorAndEntries.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
      <test:testResult id="testResult" result="passed" >
          <test:errorDescriptionEntry id="can.you.read.this.first.entry" value="dummy" />
          <test:errorDescriptionEntry id="can.you.read.this.second.entry" value="dummy" />
      </test:testResult>
  
      <script type="text/ecmascript"><![CDATA[
      var testNS = "http://xml.apache.org/batik/test";
  
      function runTest(evt){
          var tr = document.getElementById("testResult");
          tr.setAttributeNS(null, "result", "failed");
          tr.setAttributeNS(null, "errorCode", "can.you.read.this.error.code");
  
          /*var entryA = document.createElementNS(testNS, "errorDescriptionEntry");
          entryA.setAttributeNS(null, "key", "can.you.read.this.first.entry");
          var.entryB = document.createElementNS(testNS, "errorDescriptionEntry");
          entryB.setAttributeNS(null, "key", "can.you.read.this.second.entry");
  
          tr.appendChild(entryA);
          tr.appendChild(entryB);*/
  
      }
  
      ]]></script>
  
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/invalidTestResultElementsNumber.svg
  
  Index: invalidTestResultElementsNumber.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of too many or too few &lt;testResult&gt; elements.              -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: invalidTestResultElementsNumber.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
      <script type="text/ecmascript"><![CDATA[
      var testNS = "http://xml.apache.org/batik/test";
  
      function runTest(evt){
          var trA = document.createElementNS(testNS, "testResult");
          var trB = document.createElementNS(testNS, "testResult");
          var root = document.getDocumentElement();
          root.appendChild(trA);
          root.appendChild(trB);
      }
  
      ]]></script>
  
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/missingOrEmptyErrorCode.svg
  
  Index: missingOrEmptyErrorCode.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of missing errorCode value when the 'result' attribute in the    -->
  <!-- 'testResult' element is set to 'failed'.                                  -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: missingOrEmptyErrorCode.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
      <script type="text/ecmascript"><![CDATA[
      var testNS = "http://xml.apache.org/batik/test";
  
      function runTest(evt){
          var tr = document.createElementNS(testNS, "testResult");
          tr.setAttributeNS(null, "result", "failed");
          var root = document.getDocumentElement();
          root.appendChild(tr);
      }
  
      ]]></script>
  
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/processingError.svg
  
  Index: processingError.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of processing error in SVG test cases. Here, the fill value on   -->
  <!-- the rectangle should cause the test to fail.                              -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: processingError.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
      width="450" height="500" viewBox="0 0 450 500">
  
      <script type="text/ecmascript"><![CDATA[
      ]]></script>
  
      <rect fill="thisIsAnIncorrectFillValueThatWillCauseAProcessingError" />
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/success.svg
  
  Index: success.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of a successful self contained test.                             -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: success.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
      <script type="text/ecmascript"><![CDATA[
      var testNS = "http://xml.apache.org/batik/test";
  
      function runTest(evt){
          var tr = document.createElementNS(testNS, "testResult");
          tr.setAttributeNS(null, "result", "passed");
          var root = document.getDocumentElement();
          root.appendChild(tr);
      }
  
      ]]></script>
  
  </svg>
  
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/test/svg/unexpectedResultValue.svg
  
  Index: unexpectedResultValue.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- This file is used by SelfContainedSVGOnLoadTestValidator to validate      -->
  <!-- handling of an unexpected 'result' attribute value in the 'testResult'    -->
  <!-- element.                                                                  -->
  <!--                                                                           -->
  <!-- @author vincent.hardy@sun.com                                             -->
  <!-- @version $Id: unexpectedResultValue.svg,v 1.1 2002/04/11 08:07:24 vhardy Exp $            -->
  <!-- ========================================================================= -->
  
  <svg xmlns="http://www.w3.org/2000/svg" 
       xmlns:xlink="http://www.w3.org/1999/xlink" 
       xmlns:test="http://xml.apache.org/batik/test"
       width="450" height="500" viewBox="0 0 450 500"
       onload="runTest(evt)">
  
      <script type="text/ecmascript"><![CDATA[
      var testNS = "http://xml.apache.org/batik/test";
  
      function runTest(evt){
          var tr = document.createElementNS(testNS, "testResult");
          tr.setAttributeNS(null, "result", "invalidResultValue");
          var root = document.getDocumentElement();
          root.appendChild(tr);
      }
  
      ]]></script>
  
  </svg>
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org