You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2001/09/26 14:40:51 UTC

cvs commit: xml-batik/test-resources/org/apache/batik/util regBase64.xml regParsedURL.xml

deweese     01/09/26 05:40:51

  Modified:    sources/org/apache/batik/util ParsedURL.java
                        ParsedURLDefaultProtocolHandler.java
               test-resources/org/apache/batik/util regBase64.xml
                        regParsedURL.xml
  Log:
  1) Removed tests with duplicate names.
  2) ParsedURL now allows relative URL's with protocol.
  
  Revision  Changes    Path
  1.8       +1 -10     xml-batik/sources/org/apache/batik/util/ParsedURL.java
  
  Index: ParsedURL.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURL.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ParsedURL.java	2001/07/18 22:04:54	1.7
  +++ ParsedURL.java	2001/09/26 12:40:51	1.8
  @@ -439,7 +439,7 @@
               return null;
   
           // May have a protocol spec...
  -        String protocol = urlStr.substring(0, idx);
  +        String protocol = urlStr.substring(0, idx).toLowerCase();
           if (protocol.indexOf('/') != -1)
               // Got a slash in protocol probably means 
               // no protocol given.
  @@ -465,11 +465,6 @@
        * @param urlStr the sub URL string to parse.
        */
       public static ParsedURLData parseURL(String baseStr, String urlStr) {
  -        String protocol = getProtocol(urlStr);
  -        if (protocol != null)
  -            // Protocol given, ignore base...
  -            return parseURL(urlStr);
  -
           ParsedURL purl = new ParsedURL(baseStr);
           return parseURL(purl, urlStr);
       }
  @@ -482,10 +477,6 @@
        */
       public static ParsedURLData parseURL(ParsedURL baseURL, String urlStr) {
           String protocol = getProtocol(urlStr);
  -        if (protocol != null)
  -            // Protocol given, ignore base...
  -            return parseURL(urlStr);
  -
           ParsedURLProtocolHandler handler = getHandler(protocol);
           return handler.parseURL(baseURL, urlStr);        
       }
  
  
  
  1.2       +23 -4     xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java
  
  Index: ParsedURLDefaultProtocolHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParsedURLDefaultProtocolHandler.java	2001/05/03 22:11:05	1.1
  +++ ParsedURLDefaultProtocolHandler.java	2001/09/26 12:40:51	1.2
  @@ -78,7 +78,7 @@
           idx = urlStr.indexOf(':');
           if (idx != -1) {
               // May have a protocol spec...
  -            ret.protocol = urlStr.substring(pidx, idx);
  +            ret.protocol = urlStr.substring(pidx, idx).toLowerCase();
               if (ret.protocol.indexOf('/') == -1)
                   pidx = idx+1;
               else {
  @@ -163,9 +163,28 @@
        */
       public ParsedURLData parseURL(ParsedURL baseURL, String urlStr) {
           int idx = urlStr.indexOf(':');
  -        if (idx != -1)
  -            // Absolute URL ignore base...
  -            return parseURL(urlStr);
  +        if (idx != -1) {
  +            String protocol = urlStr.substring(0,idx).toLowerCase();
  +            
  +            if (!protocol.equals(baseURL.getProtocol()))
  +                // Different protocols, assume absolute URL ignore base...
  +                return parseURL(urlStr);
  +
  +            // Same protocols, if char after ':' is a '/' then it's
  +            // still absolute...
  +            idx++;
  +            if (idx == urlStr.length()) 
  +                // Just a Protocol???
  +                return parseURL(urlStr);
  +
  +            if (urlStr.charAt(idx) == '/')
  +                // Absolute URL...
  +                return parseURL(urlStr);
  +
  +            // Still relative just drop the protocol (we will pick it
  +            // back up from the baseURL later...).
  +            urlStr = urlStr.substring(idx);
  +        }
   
           if (urlStr.startsWith("/"))
               // Absolute path.
  
  
  
  1.2       +1 -6      xml-batik/test-resources/org/apache/batik/util/regBase64.xml
  
  Index: regBase64.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/util/regBase64.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- regBase64.xml	2001/07/05 16:54:33	1.1
  +++ regBase64.xml	2001/09/26 12:40:51	1.2
  @@ -8,7 +8,7 @@
   
   <!-- ====================================================================== -->
   <!-- @author deweese@apache.org                                             -->
  -<!-- @version $Id: regBase64.xml,v 1.1 2001/07/05 16:54:33 deweese Exp $     -->
  +<!-- @version $Id: regBase64.xml,v 1.2 2001/09/26 12:40:51 deweese Exp $     -->
   <!-- ====================================================================== -->
   
   <testSuite name="Base64 test Suite">
  @@ -114,11 +114,6 @@
           <arg class="java.lang.String" value="ENCODE" />
           <arg class="java.net.URL" value="file:test-references/org/apache/batik/util/medium" />
           <arg class="java.net.URL" value="file:test-references/org/apache/batik/util/medium.64" />
  -    </test>
  -    <test class="org.apache.batik.util.Base64Test">
  -        <arg class="java.lang.String" value="ENCODE" />
  -        <arg class="java.net.URL" value="file:test-references/org/apache/batik/util/medium" />
  -        <arg class="java.net.URL" value="file:test-references/org/apache/batik/util/medium.pc.64" />
       </test>
       <test class="org.apache.batik.util.Base64Test">
           <arg class="java.lang.String" value="DECODE" />
  
  
  
  1.2       +11 -3     xml-batik/test-resources/org/apache/batik/util/regParsedURL.xml
  
  Index: regParsedURL.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/util/regParsedURL.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- regParsedURL.xml	2001/07/05 16:54:33	1.1
  +++ regParsedURL.xml	2001/09/26 12:40:51	1.2
  @@ -8,7 +8,7 @@
   
   <!-- ====================================================================== -->
   <!-- @author deweese@apache.org                                             -->
  -<!-- @version $Id: regParsedURL.xml,v 1.1 2001/07/05 16:54:33 deweese Exp $     -->
  +<!-- @version $Id: regParsedURL.xml,v 1.2 2001/09/26 12:40:51 deweese Exp $     -->
   <!-- ====================================================================== -->
   
   <testSuite name="Parsed URL test Suite">
  @@ -31,8 +31,8 @@
           <arg class="java.lang.String" value="fooz:/home/deweese/.cshrc" />
       </test>
       <test class="org.apache.batik.util.ParsedURLTest">
  -        <arg class="java.lang.String" value="fooz:///home/deweese/.cshrc" />
  -        <arg class="java.lang.String" value="fooz:/home/deweese/.cshrc" />
  +        <arg class="java.lang.String" value="fazz:///home/deweese/.cshrc" />
  +        <arg class="java.lang.String" value="fazz:/home/deweese/.cshrc" />
       </test>
       <test class="org.apache.batik.util.ParsedURLTest">
           <arg class="java.lang.String" 
  @@ -55,5 +55,13 @@
                value="/xyz.svg#ijkl" />
           <arg class="java.lang.String" 
                value="fooz://www.com:1234/xyz.svg#ijkl" />
  +    </test>
  +    <test class="org.apache.batik.util.ParsedURLTest">
  +        <arg class="java.lang.String" 
  +             value="file:/home/deweese/test.txt" />
  +        <arg class="java.lang.String" 
  +             value="file:junk.html" />
  +        <arg class="java.lang.String" 
  +             value="file:/home/deweese/junk.html" />
       </test>
   </testSuite>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org