You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2009/02/04 05:06:10 UTC
svn commit: r740595 -
/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
Author: bodewig
Date: Wed Feb 4 04:06:09 2009
New Revision: 740595
URL: http://svn.apache.org/viewvc?rev=740595&view=rev
Log:
fix XMLCatalogTest on Java6
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java?rev=740595&r1=740594&r2=740595&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java Wed Feb 4 04:06:09 2009
@@ -89,19 +89,33 @@
Source result = catalog.resolve("i/dont/exist.dtd", null);
String expected = toURLString(new File(project.getBaseDir() +
"/i/dont/exist.dtd"));
- //
- // 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",
+ String resultStr =
+ fileURLPartWithoutLeadingSlashes((SAXSource)result);
+ assertTrue("Empty catalog should return input with a system ID like "
+ + expected + " but was " + resultStr,
expected.endsWith(resultStr));
} catch (Exception e) {
fail("resolve() failed!" + e.toString());
}
}
+ private static String fileURLPartWithoutLeadingSlashes(SAXSource result)
+ throws MalformedURLException {
+ //
+ // 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(result.getInputSource().getSystemId()).getFile();
+ // on Sun's Java6 this returns an unexpected number of four
+ // leading slashes, at least on Linux - strip all of them
+ while (resultStr.startsWith("/")) {
+ resultStr = resultStr.substring(1);
+ }
+ return resultStr;
+ }
+
public void testNonExistentEntry() {
ResourceLocation dtd = new ResourceLocation();
@@ -120,8 +134,10 @@
Source result = catalog.resolve("i/dont/exist.dtd", null);
String expected = toURLString(new File(project.getBaseDir().toURL() +
"/i/dont/exist.dtd"));
- String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile();
- assertTrue("Nonexistent Catalog entry return input",
+ String resultStr =
+ fileURLPartWithoutLeadingSlashes((SAXSource)result);
+ assertTrue("Nonexistent Catalog entry return input with a system ID like "
+ + expected + " but was " + resultStr,
expected.endsWith(resultStr));
} catch (Exception e) {
fail("resolve() failed!" + e.toString());