You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/03/31 01:59:30 UTC

[GitHub] [netbeans] lbownik opened a new pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

lbownik opened a new pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902


   [improved tests for BaseUtilities.toFile & BaseUtitities.toURI](https://github.com/apache/netbeans/commit/6649d1f5fadff535595676e784eca06ac69e7e9d)
   
   split "testFileURI" method into multiple seperated methods
   added tests checking whether exception are thrown properly
   removed "testFieURI"
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840152235



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenUnixPath()
+            throws Exception {
+
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenWindowsPath()
+            throws Exception {
+
+        if (isWindows()) {
+            assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+        }
+    }

Review comment:
       thanks!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r839328422



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenUnixPath()
+            throws Exception {
+
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenWindowsPath()
+            throws Exception {
+
+        if (isWindows()) {
+            assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+        }
+    }

Review comment:
       I am not a big fan of splitting test cases on a per-OS basis. This would have the effect of getting green badges due to the no-op on half of the tests without having anything tested.
   
   However, looking at what is actually being tested here, I have to wonder if we could just test everything on all systems. There are no files created anyway, the utility is about paths and URIs. Lets try to remove `isWindows()`/`isUnix()` and check if everything works.
   
   If it doesn't and the os-checks were there for a reason, I would prefer that you revert to os independent test cases.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
lbownik commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840046828



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenUnixPath()
+            throws Exception {
+
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenWindowsPath()
+            throws Exception {
+
+        if (isWindows()) {
+            assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+        }
+    }

Review comment:
       me neither - but iexecuting toFile(new URI("file:/some/path")) under windows gives "d:\some\path" on my machine
   
   I have no idea how to work arround this right now - the original test had the same issue




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
lbownik commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840044650



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;

Review comment:
       my mistake - I realized it as well




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840181778



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,36 +112,104 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            //good
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+    }
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenFileURIWithIllegalCharacter()
+            throws Exception {
+
+        try {
+            toFile(new URI("file:/C:/some/?"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenCorrectURI()
+          throws Exception {
+
+        // unix
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+
+        //windows
+        assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+        assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+        assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+        assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toURI_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toURI(null);
+            fail();
+        } catch (final NullPointerException e) {
+            //good
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toURI_returnsURI_whenGivenCorrectPath()
+          throws Exception {
+
+        if (isUnix()) {
+            assertEquals(new URI("file:/some/path"), toURI(new File("/some/path")));
+            assertEquals(new URI("file:///some/path"), toURI(new File("/some/path")));
+            assertEquals(new URI("file:/some/path"), toURI(new File("/some/path/")));
+            assertEquals(new URI("file:/some/path%20%231"), toURI(new File("/some/path #1")));
+        }
+        if (isWindows()) {
+            assertEquals(new URI("file:/C:/some/path%20%231"), toURI(new File("C:\\some\\path #1")));
+            assertEquals(new URI("file:/C:/some/path"), toURI(new File("C:\\some\\path")));
+            assertEquals(new URI("file:///C:/some/path"), toURI(new File("C:\\some\\path")));
+            assertEquals(new URI("file:/C:/some/path"), toURI(new File("C:\\some\\path\\")));
+            assertEquals(new URI("file://server/share/path"), toURI(new File("\\\\server\\share\\path")));
+            assertEquals(new URI("file://server/share/path"), toURI(new File("\\\\server\\share\\path\\")));
+            assertEquals(new URI("file://server/share/path%20%231"), toURI(new File("\\\\server\\share\\path #1")));
         }
-        String s = BaseUtilities.toURI(getWorkDir()).toString();
-        assertTrue(s, s.endsWith("/"));
-        URI jar = BaseUtilities.toURI(new File(getWorkDir(), "some.jar"));
-        URI jarN = jar.resolve("some.jar");
-        assertEquals(jar, jarN);
-        URI jarR = new URI("jar:" + jar + "!/");
-        URI jarNR = new URI("jar:" + jarN + "!/");
-        assertEquals("#214131: equal even when wrapped", jarR, jarNR);

Review comment:
       this is a regression test for https://bz.apache.org/netbeans/show_bug.cgi?id=214131
   
   please don't remove it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840085757



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenUnixPath()
+            throws Exception {
+
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenWindowsPath()
+            throws Exception {
+
+        if (isWindows()) {
+            assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+            assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+            assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+        }
+    }

Review comment:
       I see - so there is a valid reason for the os checks. So lets merge the os - dependent cases into os - independent cases with an if branch in them like it was before to avoid green no-ops.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
lbownik commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840044769



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;

Review comment:
       my mistake




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r841003604



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,36 +112,104 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            //good
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+    }
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenFileURIWithIllegalCharacter()
+            throws Exception {
+
+        try {
+            toFile(new URI("file:/C:/some/?"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenCorrectURI()
+          throws Exception {
+
+        // unix
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+
+        //windows
+        assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+        assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+        assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+        assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toURI_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toURI(null);
+            fail();
+        } catch (final NullPointerException e) {
+            //good
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toURI_returnsURI_whenGivenCorrectPath()
+          throws Exception {
+
+        if (isUnix()) {
+            assertEquals(new URI("file:/some/path"), toURI(new File("/some/path")));
+            assertEquals(new URI("file:///some/path"), toURI(new File("/some/path")));
+            assertEquals(new URI("file:/some/path"), toURI(new File("/some/path/")));
+            assertEquals(new URI("file:/some/path%20%231"), toURI(new File("/some/path #1")));
+        }
+        if (isWindows()) {
+            assertEquals(new URI("file:/C:/some/path%20%231"), toURI(new File("C:\\some\\path #1")));
+            assertEquals(new URI("file:/C:/some/path"), toURI(new File("C:\\some\\path")));
+            assertEquals(new URI("file:///C:/some/path"), toURI(new File("C:\\some\\path")));
+            assertEquals(new URI("file:/C:/some/path"), toURI(new File("C:\\some\\path\\")));
+            assertEquals(new URI("file://server/share/path"), toURI(new File("\\\\server\\share\\path")));
+            assertEquals(new URI("file://server/share/path"), toURI(new File("\\\\server\\share\\path\\")));
+            assertEquals(new URI("file://server/share/path%20%231"), toURI(new File("\\\\server\\share\\path #1")));
         }
-        String s = BaseUtilities.toURI(getWorkDir()).toString();
-        assertTrue(s, s.endsWith("/"));
-        URI jar = BaseUtilities.toURI(new File(getWorkDir(), "some.jar"));
-        URI jarN = jar.resolve("some.jar");
-        assertEquals(jar, jarN);
-        URI jarR = new URI("jar:" + jar + "!/");
-        URI jarNR = new URI("jar:" + jarN + "!/");
-        assertEquals("#214131: equal even when wrapped", jarR, jarNR);

Review comment:
       awesome




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] vieiro commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
vieiro commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r839210516



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;

Review comment:
       And maybe this one too.

##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,31 +112,106 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            return;
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            return;

Review comment:
       I think we want to remove this "return" here, so tests proceeds with statements below.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a change in pull request #3902: improved tests for BaseUtilities.toFile & BaseUtitities.toURI

Posted by GitBox <gi...@apache.org>.
lbownik commented on a change in pull request #3902:
URL: https://github.com/apache/netbeans/pull/3902#discussion_r840991340



##########
File path: platform/openide.util/test/unit/src/org/openide/util/BaseUtilitiesTest.java
##########
@@ -111,36 +112,104 @@ public void testIsJavaIdentifier() throws Exception {
         assertFalse(BaseUtilities.isJavaIdentifier("some.thing"));
     }
 
-    public void testFileURI() throws Exception {
-        if (BaseUtilities.isWindows()) {
-            assertFileURI("C:\\some\\path #1", "file:/C:/some/path%20%231");
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:///C:/some/path")));
-            assertEquals(new File("C:\\some\\path"), BaseUtilities.toFile(new URI("file:/C:/some/path/")));
-            assertFileURI("\\\\server\\share\\path", "file://server/share/path");
-            assertEquals(new File("\\\\server\\share\\path"), BaseUtilities.toFile(new URI("file:////server/share/path")));
-            assertEquals(new File("\\\\server\\share\\path #1"), BaseUtilities.toFile(new URI("file:////server/share/path%20%231")));
-        } else {
-            assertFileURI("/some/path #1", "file:/some/path%20%231");
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:///some/path")));
-            assertEquals(new File("/some/path"), BaseUtilities.toFile(new URI("file:/some/path/")));
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toFile(null);
+            fail();
+        } catch (final NullPointerException e) {
+            //good
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenNonFileURI()
+            throws Exception {
+
+        try {
+            toFile(new URI("http://example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+        try {
+            toFile(new URI("mailto:person@example.com"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+        try {
+            toFile(new URI("isbn:12345"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+    }
+    //--------------------------------------------------------------------------
+    public void test_toFile_throwsIllegalArgument_whenGivenFileURIWithIllegalCharacter()
+            throws Exception {
+
+        try {
+            toFile(new URI("file:/C:/some/?"));
+            fail();
+        } catch (final IllegalArgumentException e) {
+            //good
+        }
+    }
+    
+    //--------------------------------------------------------------------------
+    public void test_toFile_returnsFile_whenGivenCorrectURI()
+          throws Exception {
+
+        // unix
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:///some/path")));
+        assertEquals(new File("/some/path"), toFile(new URI("file:/some/path/")));
+        assertEquals(new File("/some/path #1"), toFile(new URI("file:/some/path%20%231")));
+
+        //windows
+        assertEquals(new File("C:\\some\\path #1"), toFile(new URI("file:/C:/some/path%20%231")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:///C:/some/path")));
+        assertEquals(new File("C:\\some\\path"), toFile(new URI("file:/C:/some/path/")));
+        assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file://server/share/path")));
+        assertEquals(new File("\\\\server\\share\\path"), toFile(new URI("file:////server/share/path")));
+        assertEquals(new File("\\\\server\\share\\path #1"), toFile(new URI("file:////server/share/path%20%231")));
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toURI_throwsNullPonter_whenArgumentIsNull()
+            throws Exception {
+
+        try {
+            toURI(null);
+            fail();
+        } catch (final NullPointerException e) {
+            //good
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    public void test_toURI_returnsURI_whenGivenCorrectPath()
+          throws Exception {
+
+        if (isUnix()) {
+            assertEquals(new URI("file:/some/path"), toURI(new File("/some/path")));
+            assertEquals(new URI("file:///some/path"), toURI(new File("/some/path")));
+            assertEquals(new URI("file:/some/path"), toURI(new File("/some/path/")));
+            assertEquals(new URI("file:/some/path%20%231"), toURI(new File("/some/path #1")));
+        }
+        if (isWindows()) {
+            assertEquals(new URI("file:/C:/some/path%20%231"), toURI(new File("C:\\some\\path #1")));
+            assertEquals(new URI("file:/C:/some/path"), toURI(new File("C:\\some\\path")));
+            assertEquals(new URI("file:///C:/some/path"), toURI(new File("C:\\some\\path")));
+            assertEquals(new URI("file:/C:/some/path"), toURI(new File("C:\\some\\path\\")));
+            assertEquals(new URI("file://server/share/path"), toURI(new File("\\\\server\\share\\path")));
+            assertEquals(new URI("file://server/share/path"), toURI(new File("\\\\server\\share\\path\\")));
+            assertEquals(new URI("file://server/share/path%20%231"), toURI(new File("\\\\server\\share\\path #1")));
         }
-        String s = BaseUtilities.toURI(getWorkDir()).toString();
-        assertTrue(s, s.endsWith("/"));
-        URI jar = BaseUtilities.toURI(new File(getWorkDir(), "some.jar"));
-        URI jarN = jar.resolve("some.jar");
-        assertEquals(jar, jarN);
-        URI jarR = new URI("jar:" + jar + "!/");
-        URI jarNR = new URI("jar:" + jarN + "!/");
-        assertEquals("#214131: equal even when wrapped", jarR, jarNR);

Review comment:
       I created seperate test for it 
   test_toURI_producesURI_wchichResolvesAndWrapsProperly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists