You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2002/11/08 11:27:40 UTC
cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
bodewig 2002/11/08 02:27:40
Modified: . build.xml
src/main/org/apache/tools/ant/taskdefs/optional
XMLValidateTask.java
src/main/org/apache/tools/ant/types ResourceLocation.java
src/main/org/apache/tools/ant/types/resolver
ApacheCatalog.java ApacheCatalogResolver.java
src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
Removed: src/main/org/apache/tools/ant/types EntityLocation.java
Log:
Missing pieces from Craeg's patch.
Fix small backwards incompatibility introduced by last commit.
Revision Changes Path
1.332 +0 -1 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.331
retrieving revision 1.332
diff -u -r1.331 -r1.332
--- build.xml 5 Nov 2002 16:33:28 -0000 1.331
+++ build.xml 8 Nov 2002 10:27:39 -0000 1.332
@@ -292,7 +292,6 @@
<exclude name="**/GetTest.java" if="offline"/>
</patternset>
<patternset id="teststhatfail">
- <exclude name="${ant.package}/types/XMLCatalogTest.java"/>
</patternset>
<!--
1.29 +3 -3 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- XMLValidateTask.java 8 Nov 2002 09:53:21 -0000 1.28
+++ XMLValidateTask.java 8 Nov 2002 10:27:39 -0000 1.29
@@ -65,7 +65,7 @@
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.ResourceLocation;
+import org.apache.tools.ant.types.DTDLocation;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
@@ -248,8 +248,8 @@
* This stores the location of a DTD. The DTD is identified
* by its public Id.
*/
- public ResourceLocation createDTD() {
- ResourceLocation dtdLocation = new ResourceLocation();
+ public DTDLocation createDTD() {
+ DTDLocation dtdLocation = new DTDLocation();
xmlCatalog.addDTD(dtdLocation);
return dtdLocation;
}
1.3 +2 -1 jakarta-ant/src/main/org/apache/tools/ant/types/ResourceLocation.java
Index: ResourceLocation.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/ResourceLocation.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ResourceLocation.java 8 Nov 2002 09:53:21 -0000 1.2
+++ ResourceLocation.java 8 Nov 2002 10:27:39 -0000 1.3
@@ -75,6 +75,7 @@
* @author dIon Gillard
* @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a>
* @version $Id$
+ * @since Ant 1.6
*/
import java.net.URL;
1.3 +2 -1 jakarta-ant/src/main/org/apache/tools/ant/types/resolver/ApacheCatalog.java
Index: ApacheCatalog.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/resolver/ApacheCatalog.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApacheCatalog.java 8 Nov 2002 09:53:22 -0000 1.2
+++ ApacheCatalog.java 8 Nov 2002 10:27:39 -0000 1.3
@@ -75,6 +75,7 @@
* @see org.apache.tools.ant.types.XMLCatalog.CatalogResolver
* @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a>
* @version $Id$
+ * @since Ant 1.6
*/
public class ApacheCatalog extends Catalog {
1.3 +2 -1 jakarta-ant/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java
Index: ApacheCatalogResolver.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ApacheCatalogResolver.java 8 Nov 2002 09:53:22 -0000 1.2
+++ ApacheCatalogResolver.java 8 Nov 2002 10:27:39 -0000 1.3
@@ -96,6 +96,7 @@
* @see org.apache.xml.resolver.CatalogManager
* @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a>
* @version $Id$
+ * @since Ant 1.6
*/
public class ApacheCatalogResolver extends CatalogResolver {
1.3 +35 -21 jakarta-ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java
Index: XMLCatalogTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLCatalogTest.java 1 Jun 2002 12:26:43 -0000 1.2
+++ XMLCatalogTest.java 8 Nov 2002 10:27:40 -0000 1.3
@@ -57,18 +57,20 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.JAXPUtils;
import junit.framework.TestCase;
import java.io.File;
import java.net.MalformedURLException;
+import java.net.URL;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.TransformerException;
/**
@@ -81,7 +83,6 @@
private Project project;
private XMLCatalog catalog;
- private FileUtils fileUtils = FileUtils.newFileUtils();
private XMLCatalog newCatalog() {
XMLCatalog cat = new XMLCatalog();
@@ -90,7 +91,7 @@
}
private String toURLString(File file) throws MalformedURLException {
- return fileUtils.getFileURL(file).toString();
+ return JAXPUtils.getSystemId(file);
}
public XMLCatalogTest(String name) {
@@ -129,7 +130,16 @@
try {
Source result = catalog.resolve("i/dont/exist.dtd", null);
- assertNull("Empty catalog should return null", result);
+ 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",
+ expected.endsWith(resultStr));
} catch (Exception e) {
fail("resolve() failed!" + e.toString());
}
@@ -137,7 +147,7 @@
public void testNonExistentEntry() {
- DTDLocation dtd = new DTDLocation();
+ ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId("PUBLIC ID ONE");
dtd.setLocation("i/dont/exist.dtd");
@@ -151,7 +161,11 @@
try {
Source result = catalog.resolve("i/dont/exist.dtd", null);
- assertNull("Nonexistent Catalog entry should not be returned", result);
+ 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",
+ expected.endsWith(resultStr));
} catch (Exception e) {
fail("resolve() failed!" + e.toString());
}
@@ -166,7 +180,7 @@
be.getMessage());
}
- DTDLocation dtd = new DTDLocation();
+ ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId("PUBLIC ID ONE");
dtd.setLocation("i/dont/exist.dtd");
catalog.addDTD(dtd);
@@ -235,7 +249,7 @@
public void testSimpleEntry() {
- DTDLocation dtd = new DTDLocation();
+ ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId("-//stevo//DTD doc 1.0//EN");
String sysid = "src/etc/testcases/taskdefs/optional/xml/doc.dtd";
dtd.setLocation(sysid);
@@ -259,7 +273,7 @@
String sysid = "src/etc/testcases/taskdefs/optional/xml/doc.dtd";
// catalog2 --> catalog1 --> catalog
- DTDLocation dtd = new DTDLocation();
+ ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId(publicId);
dtd.setLocation(sysid);
catalog.addDTD(dtd);
@@ -268,7 +282,7 @@
String uri = "http://foo.com/bar/blah.xml";
String uriLoc = "src/etc/testcases/taskdefs/optional/xml/about.xml";
- DTDLocation entity = new DTDLocation();
+ ResourceLocation entity = new ResourceLocation();
entity.setPublicId(uri);
entity.setLocation(uriLoc);
catalog.addEntity(entity);
@@ -310,7 +324,7 @@
String publicId = "-//stevo//DTD doc 1.0//EN";
String dtdLoc = "src/etc/testcases/taskdefs/optional/xml/doc.dtd";
- DTDLocation dtd = new DTDLocation();
+ ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId(publicId);
dtd.setLocation(dtdLoc);
catalog.addDTD(dtd);
@@ -319,7 +333,7 @@
String uri = "http://foo.com/bar/blah.xml";
String uriLoc = "src/etc/testcases/taskdefs/optional/xml/about.xml";
- DTDLocation entity = new DTDLocation();
+ ResourceLocation entity = new ResourceLocation();
entity.setPublicId(uri);
entity.setLocation(uriLoc);
catalog.addEntity(entity);
@@ -355,12 +369,12 @@
String uriLoc = "etc/testcases/taskdefs/optional/xml/about.xml";
String base = null;
try {
- base = toURLString(project.getBaseDir()) + "src/";
+ base = toURLString(project.getBaseDir()) + "/src/";
} catch (MalformedURLException ex) {
fail (ex.toString());
}
- DTDLocation entity = new DTDLocation();
+ ResourceLocation entity = new ResourceLocation();
entity.setPublicId(uri);
entity.setLocation(uriLoc);
catalog.addEntity(entity);
@@ -383,7 +397,7 @@
String dtdLoc = "testcases/taskdefs/optional/xml/doc.dtd";
String path1 = project.getBaseDir().toString() + "/src/etc";
- DTDLocation dtd = new DTDLocation();
+ ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId(publicId);
dtd.setLocation(dtdLoc);
catalog.addDTD(dtd);
@@ -393,7 +407,7 @@
String uriLoc = "etc/testcases/taskdefs/optional/xml/about.xml";
String path2 = project.getBaseDir().toString() + "/src";
- DTDLocation entity = new DTDLocation();
+ ResourceLocation entity = new ResourceLocation();
entity.setPublicId(uri);
entity.setLocation(uriLoc);
catalog.addEntity(entity);
@@ -407,8 +421,8 @@
InputSource result = catalog.resolveEntity(publicId,
"nap:chemical+brothers");
assertNotNull(result);
- assertEquals(toURLString(dtdFile),
- result.getSystemId());
+ String resultStr = new URL(result.getSystemId()).getFile();
+ assertTrue(toURLString(dtdFile).endsWith(resultStr));
} catch (Exception e) {
fail("resolveEntity() failed!" + e.toString());
}
@@ -416,8 +430,8 @@
try {
Source result = catalog.resolve(uri, null);
assertNotNull(result);
- assertEquals(toURLString(xmlFile),
- result.getSystemId());
+ String resultStr = new URL(result.getSystemId()).getFile();
+ assertTrue(toURLString(xmlFile).endsWith(resultStr));
} catch (Exception e) {
fail("resolve() failed!" + e.toString());
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>