Example #1
0
 @Test
 public void testAddMultipleUrlsToClasspath() throws Exception {
   String separator = System.getProperty("path.separator");
   String paths = "/blah/blah" + separator + "C" + otherSeperator(separator) + "\\foo\\bar";
   FileUtil.addItemsToClasspath(paths);
   URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
   String classpath = classpathAsString(classLoader);
   assertSubString("/blah/blah", classpath);
   assertMatches("[C" + otherSeperator(separator) + "?foo?bar]", classpath);
 }
Example #2
0
  @Test
  public void testAddUrlToClasspath() throws Exception {
    ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
    assertTrue(systemClassLoader instanceof URLClassLoader);
    URLClassLoader classLoader = (URLClassLoader) systemClassLoader;

    URL sampleUrl = new File("src").toURI().toURL();

    String classpath = classpathAsString(classLoader);
    assertNotSubString(sampleUrl.toString(), classpath);

    FileUtil.addUrlToClasspath(sampleUrl);
    classpath = classpathAsString(classLoader);
    assertSubString(sampleUrl.toString(), classpath);
  }