ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John E. Conlon" <jcon...@verticon.com>
Subject XmlCatalog Delegated Resolver Bug?
Date Thu, 20 Nov 2003 03:51:59 GMT
I have been working with external XMLCatalog files and I believe I have
found a bug. 

It appears that XMLCatalog in Ant 1.6 beta1, 1.6 beta2 and the latest
CVS appear to have the same problem when resolving delegated URIs in
external XMLCatalogs files. 

URI resolution will only return a correct result on the first resolution
attempt, subsequent attempts to resolve the same uri return a malformed
uri.

To reproduce the problem one needs two external XMLcatalog files with a
URI delegation set up between them.

The following JUnit test shows the problem...


  /**
   * Tests URI resolution using external XMLCatalog files using 
   * delegation.
   *
   * Test will model a xmlCatalog datatype configured like:
   *
   * <xmlcatalog >
   *   <catalogpath>
   *      <pathelement   
   *        location="/home/projects/java/styler/xcatalog.xml"/>
   *   </catalogpath>
   * </xmlcatalog>
   *
   * The xcatalog file maps a sets of uris to local files and to 
   * delegated 
   * xmlcatalogs.
   * <!--delegate all verticon xml resources to main xml resolver -->
         <delegateURI uriStartString = "http://www.verticon.com/xml"
             catalog = "/home/projects/xml/xcatalog.xml"/>
   *
   * <!-- A local xsl that includes a remote xcatalog based resource-->
         <uri name = 
   * "http://www.verticon.com/styler/localWithIncludes.xsl"
             uri = "localWithIncludes.xsl"/>
   *
   * @bug The second resolution attempt to a delegated uri will return
   *      erroneous results.
   *      The first resolution attempt to the same uri will return 
   *      correct results.
   *      Multiple resolutions of a local uri will return correct 
   *      results.
   *
   * [junit] Testcase: testURIDelegatedResolver took 0.155 sec
   * [junit]     FAILED
   * [junit] resolve() second delegated equality assertion failed! 
   *         expected:<......> but was:<...//...>
   * [junit] junit.framework.ComparisonFailure: resolve() second 
   * delegated 
   *         equality assertion failed! expected:<......> but 
   *  was:<...//...>
   */
  public void testURIDelegatedResolver() {
    String LOCAL_URI =
        "http://www.verticon.com/styler/localWithIncludes.xsl";
    String LOCAL_URI_EXPECTED =
        "file:/home/projects/java/styler/localWithIncludes.xsl";

    String DELEGATED_URI =
        "http://www.verticon.com/xml/xsl/copy.xsl";
    String DELEGATED_URI_EXPECTED =
        "file:/home/projects/xml/vi-xsl/copy.xsl";

    String DELEGATED_URI_2 =
        "http://www.verticon.com/saxtext/quoteComma/input.txt";

    Path path = catalog.createCatalogPath();
    path.createPathElement().setLocation(new File(
        "/home/projects/java/styler/xcatalog.xml"));

    //Resolve a local uri
    try {
      Source result = catalog.resolve(LOCAL_URI, null);
      assertNotNull(result);
      assertEquals("resolve() first local equality assertion failed!",
                   LOCAL_URI_EXPECTED,
                   result.getSystemId());
    }
    catch (Exception e) {
      fail("resolve() first pass failed!" + e.toString());
    }
    //Resolve the same uri a second time
    try {
      Source result = catalog.resolve(LOCAL_URI, null);
      assertNotNull(result);
      assertEquals("resolve() second local equality assertion failed!",
                   LOCAL_URI_EXPECTED,
                   result.getSystemId());
    }
    catch (Exception e) {
      fail("resolve() second pass failed!" + e.toString());
    }

    //Resolve a delegated uri
    try {
      Source result = catalog.resolve(DELEGATED_URI, null);
      assertNotNull(result);
      assertEquals(
         "resolve() first delegated equality assertion failed!",
                   DELEGATED_URI_EXPECTED,
                   result.getSystemId());
    }
    catch (Exception e) {
      fail("resolve() first pass failed!" + e.toString());
    }
    //Resolve the same uri a second time
    try {
      Source result = catalog.resolve(DELEGATED_URI, null);
      assertNotNull(result);
      assertEquals(
           "resolve() second delegated equality assertion failed!",
                   DELEGATED_URI_EXPECTED,
                   result.getSystemId());
    }
    catch (Exception e) {
      fail("resolve() second pass failed!" + e.toString());
    }

  }





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message