[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: JBoss with spaces in the directory name

adrian@jboss.org do-not-reply at jboss.com
Tue Aug 26 11:30:08 EDT 2008


"dimitris at jboss.org" wrote : I want to create a new jboss-common-core release and saw the failing PropertyEditorsUnitTestCase so I changed it to agree with the changes in JBCOMMON-60 and make it pass.
  | 
  | Can you guys check this is really how this is expected to behave?

I don't think you're patch is very good since you're basically
testing it against itself :-)
i.e. both the property editor and the test use Strings.toURx()


  | -         {new URL("http://www.jboss.org"), new File("/path with space/tst.xml").getCanonicalFile().toURL()},
  | -         {new URI("http://www.jboss.org"), new File("/path with space/tst.xml").getCanonicalFile().toURI()}, 
  | +         {new URL("http://www.jboss.org"), Strings.toURL("file:/path with space/tst.xml")},
  | +         {new URI("http://www.jboss.org"), Strings.toURI("file:/path with space/tst.xml")},
  |           {new String("JBoss, Home of Professional Open Source")},
  | 

The fix in JBCOMMON-60 was to make sure Strings.toURx() encoded the string
File.toURI() does, but File.toURL() does not.
http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#toURL()

This little test program shows how it should work:


  | import java.io.File;
  | import java.net.URI;
  | import java.net.URL;
  | 
  | public class test
  | {
  |    public static void main(String[] args) throws Exception
  |    {
  |       File file = new File("/path with space/tst.xml");
  |       URL url = file.getCanonicalFile().toURL();
  |       URI uri = file.getCanonicalFile().toURI();
  |       URL urlFromUri = uri.toURL();
  |       
  |       System.out.println("url        = " + url + " WRONG!");
  |       System.out.println("uri        = " + uri + " CORRECT");
  |       System.out.println("urlfromURI = " + urlFromUri + " ALSO CORRECT");
  |    }
  | }
  | 
  | url        = file:/path with space/tst.xml WRONG!
  | uri        = file:/path%20with%20space/tst.xml CORRECT
  | urlfromURI = file:/path%20with%20space/tst.xml ALSO CORRECT
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4172632#4172632

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4172632



More information about the jboss-dev-forums mailing list