antoine 2003/12/09 07:36:53 Modified: . Tag: ANT_16_BRANCH WHATSNEW src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH XMLCatalog.java src/testcases/org/apache/tools/ant/types Tag: ANT_16_BRANCH XMLCatalogTest.java Log: Merge from HEAD PR: 20965 PR: 23913 Revision Changes Path No revision No revision 1.503.2.19 +14 -2 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.18 retrieving revision 1.503.2.19 diff -u -r1.503.2.18 -r1.503.2.19 --- WHATSNEW 8 Dec 2003 02:25:42 -0000 1.503.2.18 +++ WHATSNEW 9 Dec 2003 15:36:52 -0000 1.503.2.19 @@ -1,12 +1,24 @@ -Changes from Ant 1.6.B3 to CVS -===================================== +Changes from Ant 1.6.B3 to Ant 1.6 +================================== Changes that could break older environments: -------------------------------------------- + * Attempts to read input in <java> and <exec> tasks will now receive an EOF rather than blocking. If you run such a process and rely on it blocking, as it would do in Ant 1.5, you may have problem. +Fixed bugs: +----------- + +* <xmlcatalog>s only worked when defined inside of tasks. Bugzilla + Report 20965. + +* <xmlcatalog> Wrong file location to URL conversion in XMLCatalog. + Bugzilla Report 23913. + +Other changes: +-------------- Changes from Ant 1.6.B2 to Ant 1.6.B3 ===================================== No revision No revision 1.32.2.2 +18 -3 ant/src/main/org/apache/tools/ant/types/XMLCatalog.java Index: XMLCatalog.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v retrieving revision 1.32.2.1 retrieving revision 1.32.2.2 diff -u -r1.32.2.1 -r1.32.2.2 --- XMLCatalog.java 23 Sep 2003 15:03:36 -0000 1.32.2.1 +++ XMLCatalog.java 9 Dec 2003 15:36:53 -0000 1.32.2.2 @@ -156,7 +156,6 @@ * @author Erik Hatcher * @author <a href="mailto:[EMAIL PROTECTED]">Craeg Strong</a> * @author Jeff Turner - * @version $Id$ */ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, URIResolver { @@ -678,6 +677,8 @@ private InputSource filesystemLookup(ResourceLocation matchingEntry) { String uri = matchingEntry.getLocation(); + // the following line seems to be necessary on Windows under JDK 1.2 + uri = uri.replace(File.separatorChar, '/'); URL baseURL = null; // @@ -697,11 +698,25 @@ InputSource source = null; URL url = null; - try { url = new URL(baseURL, uri); } catch (MalformedURLException ex) { - // ignore + // this processing is useful under Windows when the location of the DTD has been given as an absolute path + // see Bugzilla Report 23913 + File testFile = new File(uri); + if (testFile.exists() && testFile.canRead()) { + log("uri : '" + + uri + "' matches a readable file", Project.MSG_DEBUG); + try { + url = fileUtils.getFileURL(testFile); + } catch (MalformedURLException ex1) { + throw new BuildException("could not find an URL for :" + testFile.getAbsolutePath()); + } + } else { + log("uri : '" + + uri + "' does not match a readable file", Project.MSG_DEBUG); + + } } if (url != null) { No revision No revision 1.4.2.3 +36 -14 ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java Index: XMLCatalogTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -r1.4.2.2 -r1.4.2.3 --- XMLCatalogTest.java 25 Sep 2003 07:44:27 -0000 1.4.2.2 +++ XMLCatalogTest.java 9 Dec 2003 15:36:53 -0000 1.4.2.3 @@ -76,8 +76,7 @@ /** * JUnit testcases for org.apache.tools.ant.types.XMLCatalog * - * @author <a href="mailto:[EMAIL PROTECTED]">Craeg Strong</a> - * @version $Id$ + * @author <a href="mailto:[EMAIL PROTECTED]">Craeg Strong</a> */ public class XMLCatalogTest extends TestCase { @@ -110,7 +109,7 @@ // logger.setOutputPrintStream(System.out); // logger.setErrorPrintStream(System.err); // project.addBuildListener(logger); - + catalog = newCatalog(); } @@ -118,10 +117,10 @@ project = null; catalog = null; } - + public void testEmptyCatalog() { try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", + InputSource result = catalog.resolveEntity("PUBLIC ID ONE", "i/dont/exist.dtd"); assertNull("Empty catalog should return null", result); } catch (Exception e) { @@ -136,9 +135,9 @@ // These shenanigans are necessary b/c Norm Walsh's resolver // has a different idea of how file URLs are created on windoze // ie file://c:/foo instead of file:///c:/foo - // + // String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile(); - assertTrue("Empty catalog should return input", + assertTrue("Empty catalog should return input", expected.endsWith(resultStr)); } catch (Exception e) { fail("resolve() failed!" + e.toString()); @@ -152,7 +151,7 @@ dtd.setLocation("i/dont/exist.dtd"); try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", + InputSource result = catalog.resolveEntity("PUBLIC ID ONE", "i/dont/exist.dtd"); assertNull("Nonexistent Catalog entry should not be returned", result); } catch (Exception e) { @@ -177,15 +176,15 @@ dtd.setLocation("i/dont/exist.dtd"); catalog.addDTD(dtd); project.addReference("catalog", catalog); - + try { catalog.setRefid(new Reference("dummyref")); fail("Can add reference to nonexistent XMLCatalog"); } catch (BuildException be) { - assertEquals("You must not specify more than one " + assertEquals("You must not specify more than one " + "attribute when using refid", be.getMessage()); } - + XMLCatalog catalog2 = newCatalog(); catalog2.setRefid(new Reference("catalog")); @@ -205,7 +204,7 @@ catalog.setRefid(new Reference("catalog")); try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", + InputSource result = catalog.resolveEntity("PUBLIC ID ONE", "i/dont/exist.dtd"); fail("Can make XMLCatalog a Reference to itself."); } catch (BuildException be) { @@ -228,7 +227,7 @@ catalog1.setRefid(new Reference("catalog2")); try { - InputSource result = catalog1.resolveEntity("PUBLIC ID ONE", + InputSource result = catalog1.resolveEntity("PUBLIC ID ONE", "i/dont/exist.dtd"); fail("Can make circular reference"); } catch (BuildException be) { @@ -238,6 +237,29 @@ fail("resolveEntity() failed!" + e.toString()); } } + // inspired by Bugzilla Report 23913 + // a problem used to happen under Windows when the location of the DTD was given as an absolute path + // possibly with a mixture of file separators + public void testAbsolutePath() { + ResourceLocation dtd = new ResourceLocation(); + dtd.setPublicId("-//stevo//DTD doc 1.0//EN"); + + String sysid = System.getProperty("user.dir") + File.separator + "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; + dtd.setLocation(sysid); + catalog.addDTD(dtd); + File dtdFile = project.resolveFile(sysid); + + try { + InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN", + "nap:chemical+brothers"); + assertNotNull(result); + assertEquals(toURLString(dtdFile), + result.getSystemId()); + } catch (Exception e) { + fail("resolveEntity() failed!" + e.toString()); + } + + } public void testSimpleEntry() { @@ -247,7 +269,7 @@ dtd.setLocation(sysid); catalog.addDTD(dtd); File dtdFile = project.resolveFile(sysid); - + try { InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN", "nap:chemical+brothers");
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]