ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional XmlValidateTest.java
Date Wed, 27 Nov 2002 16:38:58 GMT
bodewig     2002/11/27 08:38:57

  Modified:    .        WHATSNEW
               src/etc/testcases/taskdefs/optional xmlvalidate.xml
               src/main/org/apache/tools/ant/taskdefs/optional
                        XMLValidateTask.java
               src/testcases/org/apache/tools/ant/taskdefs/optional
                        XmlValidateTest.java
  Added:       src/etc/testcases/taskdefs/optional/xml iso-2022-jp.xml
                        utf-8.xml
  Log:
  <xmlvalidate> ignored the encoding declaration of files it should
  validate.
  
  PR: 11279
  
  Revision  Changes    Path
  1.328     +3 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.327
  retrieving revision 1.328
  diff -u -r1.327 -r1.328
  --- WHATSNEW	21 Nov 2002 22:16:56 -0000	1.327
  +++ WHATSNEW	27 Nov 2002 16:38:55 -0000	1.328
  @@ -60,6 +60,9 @@
   
   * <concat> could append newline characters between concatenated files.
   
  +* <xmlvalidate> ignored the specified encoding of the files to
  +  validate.
  +
   Other changes:
   --------------
   * The filesetmanifest attribute of <jar> has been reenabled.
  
  
  
  1.8       +8 -0      jakarta-ant/src/etc/testcases/taskdefs/optional/xmlvalidate.xml
  
  Index: xmlvalidate.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/optional/xmlvalidate.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- xmlvalidate.xml	5 Nov 2002 16:33:28 -0000	1.7
  +++ xmlvalidate.xml	27 Nov 2002 16:38:56 -0000	1.8
  @@ -73,4 +73,12 @@
       </xmlvalidate>
     </target>
       
  +  <target name="testIso2022Jp">
  +    <xmlvalidate warn="false" file="xml/iso-2022-jp.xml"/>
  +  </target>
  +
  +  <target name="testUtf8">
  +    <xmlvalidate warn="false" file="xml/utf-8.xml"/>
  +  </target>
  +
   </project>
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/optional/xml/iso-2022-jp.xml
  
  Index: iso-2022-jp.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-2022-jp"?>
  <!DOCTYPE test [
    <!ELEMENT test (#PCDATA)>
  ]>
  <test>
  ISO-2022-JP のファイル。
  </test>
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/optional/xml/utf-8.xml
  
  Index: utf-8.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE test [
    <!ELEMENT test (#PCDATA)>
  ]>
  <test>
  Libert, galit, fraternit!
  </test>
  
  
  
  1.30      +9 -8      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  
  Index: XMLValidateTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- XMLValidateTask.java	8 Nov 2002 10:27:39 -0000	1.29
  +++ XMLValidateTask.java	27 Nov 2002 16:38:56 -0000	1.30
  @@ -54,7 +54,7 @@
   package org.apache.tools.ant.taskdefs.optional;
   
   import java.io.File;
  -import java.io.FileReader;
  +import java.io.FileInputStream;
   import java.io.IOException;
   import java.net.MalformedURLException;
   import java.net.URL;
  @@ -70,6 +70,7 @@
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
   import org.apache.tools.ant.types.XMLCatalog;
  +import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.ant.util.JAXPUtils;
   import org.xml.sax.EntityResolver;
   import org.xml.sax.ErrorHandler;
  @@ -92,6 +93,11 @@
    */
   public class XMLValidateTask extends Task {
   
  +    /**
  +     * helper for path -> URI and URI -> path conversions.
  +     */
  +    private static FileUtils fu = FileUtils.newFileUtils();
  +
       protected static String INIT_FAILED_MSG =
           "Could not start xml validation: ";
   
  @@ -398,13 +404,8 @@
           try {
               log("Validating " + afile.getName() + "... ", Project.MSG_VERBOSE);
               errorHandler.init(afile);
  -            InputSource is = new InputSource(new FileReader(afile));
  -            String uri = "file:" + afile.getAbsolutePath().replace('\\', '/');
  -            for (int index = uri.indexOf('#'); index != -1;
  -                 index = uri.indexOf('#')) {
  -                uri = uri.substring(0, index) + "%23"
  -                    + uri.substring(index + 1);
  -            }
  +            InputSource is = new InputSource(new FileInputStream(afile));
  +            String uri = fu.toURI(afile.getAbsolutePath());
               is.setSystemId(uri);
               xmlReader.parse(is);
           } catch (SAXException ex) {
  
  
  
  1.7       +22 -0     jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
  
  Index: XmlValidateTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XmlValidateTest.java	5 Nov 2002 16:33:29 -0000	1.6
  +++ XmlValidateTest.java	27 Nov 2002 16:38:57 -0000	1.7
  @@ -179,4 +179,26 @@
               }
           }
       }
  +
  +    /**
  +     * iso-2022-jp.xml is valid but wouldn't get recognized on systems
  +     * with a different native encoding.
  +     *
  +     * Bug 11279
  +     */
  +    public void testIso2022Jp() {
  +        executeTarget("testIso2022Jp");
  +    }
  +
  +    /**
  +     * utf-8.xml is invalid as it contains non-UTF-8 characters, but
  +     * would pass on systems with a native iso-8859-1 (or similar)
  +     * encoding.
  +     *
  +     * Bug 11279
  +     */
  +    public void testUtf8() {
  +        expectBuildException("testUtf8", "invalid characters in file");
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message