@ -21,6 +21,7 @@ import java.net.URL;
import org.junit.Test ;
import org.junit.Test ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertNull ;
import static org.junit.Assert.assertTrue ;
import static org.junit.Assert.assertTrue ;
/ * *
/ * *
@ -28,6 +29,19 @@ import static org.junit.Assert.assertTrue;
* /
* /
public class LaunchedURLClassLoaderTests {
public class LaunchedURLClassLoaderTests {
@Test
public void resolveResourceFromWindowsFilesystem ( ) throws Exception {
// This path is invalid - it should return null even on Windows.
// A regular URLClassLoader will deal with it gracefully.
assertNull ( getClass ( ) . getClassLoader ( ) . getResource (
"c:\\Users\\user\\bar.properties" ) ) ;
LaunchedURLClassLoader loader = new LaunchedURLClassLoader ( new URL [ ] { new URL (
"jar:file:src/test/resources/jars/app.jar!/" ) } , getClass ( )
. getClassLoader ( ) ) ;
// So we should too...
assertNull ( loader . getResource ( "c:\\Users\\user\\bar.properties" ) ) ;
}
@Test
@Test
public void resolveResourceFromArchive ( ) throws Exception {
public void resolveResourceFromArchive ( ) throws Exception {
LaunchedURLClassLoader loader = new LaunchedURLClassLoader ( new URL [ ] { new URL (
LaunchedURLClassLoader loader = new LaunchedURLClassLoader ( new URL [ ] { new URL (