@Test
public void testExpandUserHomeOnUnix() {

    SystemProvider save = UtilTest.setSystem(new SystemProviderForTest(
            new Properties() {{
                setProperty("user.home", "/home/john");
            }},  new HashMap<String, String>()
    ));
    try {
        assertEquals("/home/john", Util.expandUserHome("~"));
        assertEquals("/home/john/foo/bar/", Util.expandUserHome("~/foo/bar/"));
        assertEquals("file:/home/john/foo/bar/", Util.expandUserHome("file:~/foo/bar/"));
        assertEquals("jar:file:/home/john/foo/bar/", Util.expandUserHome("jar:file:~/foo/bar/"));
        assertEquals("/home/john\\foo\\bar\\", Util.expandUserHome("~\\foo\\bar\\"));
        assertEquals("file:/home/john\\foo\\bar\\", Util.expandUserHome("file:~\\foo\\bar\\"));
        assertEquals("jar:file:/home/john\\foo\\bar\\", Util.expandUserHome("jar:file:~\\foo\\bar\\"));
    } finally {
        UtilTest.setSystem(save);
    }
}