1 2 Previous Next 20 Replies Latest reply on Aug 30, 2008 5:39 AM by mstruk Go to original post
      • 15. Re: JBoss with spaces in the directory name
        dimitris

        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?

        • 16. Re: JBoss with spaces in the directory name
          dimitris

          I've also deployed a 2.2.8-SNAPSHOT, if you want to test it.

          • 17. Re: JBoss with spaces in the directory name

             

            "dimitris@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 your 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
            


            • 18. Re: JBoss with spaces in the directory name

              So I guess the correct fix to the test is

              -new File("/path with space/tst.xml").getCanonicalFile().toURL()
              +new File("/path with space/tst.xml").getCanonicalFile().toURI().toURL();
              


              • 19. Re: JBoss with spaces in the directory name
                dimitris

                So the spaces need to be encoded in every case - thanks Adrian.

                • 20. Re: JBoss with spaces in the directory name
                  mstruk

                  The spaces issue looks fixed now.

                  I'm still seeing some other propertyeditors test failures when building jboss-common-core:

                  -------------------------------------------------------------------------------
                  Test set: org.jboss.test.util.test.propertyeditor.PropertyEditorsUnitTestCase
                  -------------------------------------------------------------------------------
                  Tests run: 5, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.49 sec <<< FAILURE!
                  testJBossEditors(org.jboss.test.util.test.propertyeditor.PropertyEditorsUnitTestCase) Time elapsed: 0.318 sec <<< ERROR!
                  org.jboss.util.NestedRuntimeException: Unparseable date: "Tue Jan 4 23:38:21 PST 2005"; - nested throwable: (java.text.ParseException: Unparseable date: "Tue Jan 4 23:38:21 PST 2005")
                   at org.jboss.util.propertyeditor.DateEditor.setAsText(DateEditor.java:147)
                   at org.jboss.test.util.test.propertyeditor.PropertyEditorsUnitTestCase.doTests(PropertyEditorsUnitTestCase.java:456)
                   at org.jboss.test.util.test.propertyeditor.PropertyEditorsUnitTestCase.testJBossEditors(PropertyEditorsUnitTestCase.java:356)
                  ...
                  ...
                  
                  Caused by: java.text.ParseException: Unparseable date: "Tue Jan 4 23:38:21 PST 2005"
                   at java.text.DateFormat.parse(DateFormat.java:337)
                   at org.jboss.util.propertyeditor.DateEditor.setAsText(DateEditor.java:131)
                   ... 25 more
                  
                  testDateEditor(org.jboss.test.util.test.propertyeditor.PropertyEditorsUnitTestCase) Time elapsed: 0.02 sec <<< ERROR!
                  java.text.ParseException: Unparseable date: "Fri, 25 Jun 1971 00:30:00 +0200"
                   at java.text.DateFormat.parse(DateFormat.java:337)
                   at org.jboss.test.util.test.propertyeditor.PropertyEditorsUnitTestCase.testDateEditor(PropertyEditorsUnitTestCase.java:373)
                  
                  



                  These look like having to do with default locale expectations.

                  - marko

                  1 2 Previous Next