From 972b069addd68282d43028428b87ace236d8dc62 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Tue, 3 Dec 2002 14:40:50 +0000 Subject: [PATCH] Actually test the resolver stuff of xmlcatalog git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273605 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 4 + .../testcases/taskdefs/optional/xml/catalog | 2 + .../taskdefs/optional/xmlvalidate.xml | 27 +++- .../types/resolver/ApacheCatalogResolver.java | 2 + .../optional/XmlValidateCatalogTest.java | 125 ++++++++++++++++++ .../taskdefs/optional/XmlValidateTest.java | 27 ++-- 6 files changed, 170 insertions(+), 17 deletions(-) create mode 100644 src/etc/testcases/taskdefs/optional/xml/catalog create mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java diff --git a/build.xml b/build.xml index 37575bbd6..242c847fc 100644 --- a/build.xml +++ b/build.xml @@ -1530,6 +1530,10 @@ + + + diff --git a/src/etc/testcases/taskdefs/optional/xml/catalog b/src/etc/testcases/taskdefs/optional/xml/catalog new file mode 100644 index 000000000..1c9bddf21 --- /dev/null +++ b/src/etc/testcases/taskdefs/optional/xml/catalog @@ -0,0 +1,2 @@ +PUBLIC "-//stevo//DTD doc 1.0//EN" "doc.dtd" + diff --git a/src/etc/testcases/taskdefs/optional/xmlvalidate.xml b/src/etc/testcases/taskdefs/optional/xmlvalidate.xml index 53a583944..018022a76 100644 --- a/src/etc/testcases/taskdefs/optional/xmlvalidate.xml +++ b/src/etc/testcases/taskdefs/optional/xmlvalidate.xml @@ -38,8 +38,9 @@ - - + + + @@ -50,7 +51,7 @@ - + @@ -62,6 +63,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java b/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java index 94a499536..e5bd8e1d4 100644 --- a/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java +++ b/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java @@ -123,6 +123,8 @@ public class ApacheCatalogResolver extends CatalogResolver { System.getProperties().put("xml.catalog.className", ApacheCatalog.class.getName()); + CatalogManager.getStaticManager().setUseStaticCatalog(false); + // debug // System.setProperty("xml.catalog.verbosity", "4"); } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java new file mode 100644 index 000000000..914b718f0 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java @@ -0,0 +1,125 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Ant", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.tools.ant.taskdefs.optional; + +import java.io.*; +import java.util.Properties; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileTest; + +/** + * Tests the XMLValidate optional task with nested external catalogs. + * + * @see XmlValidateTest + * @author steve loughran + * @author Jeff Turner + * @since Ant 1.6 + */ +public class XmlValidateCatalogTest extends BuildFileTest { + + /** + * where tasks run + */ + private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; + + + /** + * Constructor + * + * @param name testname + */ + public XmlValidateCatalogTest(String name) { + super(name); + } + + + /** + * The JUnit setup method + */ + public void setUp() { + configureProject(TASKDEFS_DIR + "xmlvalidate.xml"); + } + + + /** + * The teardown method for JUnit + */ + public void tearDown() { + + } + + /** + * catalogfiles fileset should be ignored + * if resolver.jar is not present, but will + * be used if it is. either way, test should + * work b/c we have a nested dtd with the same + * entity + */ + public void testXmlCatalogFiles() { + executeTarget("xmlcatalogfiles"); + } + + /** + * Test nested catalogpath. + * It should be ignored if resolver.jar is not + * present, but will be used if it is. either + * way, test should work b/c we have a nested + * dtd with the same entity + */ + public void testXmlCatalogPath() { + executeTarget("xmlcatalogpath"); + } + +} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java index 6a7ddaf2b..786f7a254 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java @@ -60,9 +60,13 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileTest; /** - * Tests the XmlValidateTest task. + * Tests the XMLValidate optional task, by running targets in the test script + * src/etc/testcases/taskdefs/optional/xmlvalidate.xml + *

* + * @see XmlValidateCatalogTest * @author steve loughran + * @author Jeff Turner * @since Ant 1.5 */ public class XmlValidateTest extends BuildFileTest { @@ -100,7 +104,7 @@ public class XmlValidateTest extends BuildFileTest { /** - * A unit test for JUnit + * Basic inline 'dtd' element test. */ public void testValidate() throws Exception { executeTarget("testValidate"); @@ -108,7 +112,7 @@ public class XmlValidateTest extends BuildFileTest { /** - * A unit test for JUnit + * Test indirect validation. */ public void testDeepValidate() throws Exception { executeTarget("testDeepValidate"); @@ -122,25 +126,20 @@ public class XmlValidateTest extends BuildFileTest { } /** - * catalogfiles fileset should be ignored - * if resolver.jar is not present, but will - * be used if it is. either way, test should - * work b/c we have a nested dtd with the same - * entity + * Test that the nested dtd element is used when resolver.jar is not + * present. This test should pass either way. */ public void testXmlCatalogFiles() { - executeTarget("xmlcatalogfiles"); + executeTarget("xmlcatalogfiles-override"); } /** * Test nested catalogpath. - * It should be ignored if resolver.jar is not - * present, but will be used if it is. either - * way, test should work b/c we have a nested - * dtd with the same entity + * Test that the nested dtd element is used when resolver.jar is not + * present. This test should pass either way. */ public void testXmlCatalogPath() { - executeTarget("xmlcatalogpath"); + executeTarget("xmlcatalogpath-override"); } /**