FileDocCategorySizeDatePackage
AntClassLoaderTest.javaAPI DocApache Ant 1.703769Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant

AntClassLoaderTest

public class AntClassLoaderTest extends BuildFileTest
Test case for ant class loader

Fields Summary
private Project
p
Constructors Summary
public AntClassLoaderTest(String name)

        super(name);
    
Methods Summary
public voidsetUp()

        p = new Project();
        p.init();
        configureProject("src/etc/testcases/core/antclassloader.xml");
        getProject().executeTarget("setup");
    
public voidtearDown()

        getProject().executeTarget("cleanup");
    
public voidtestCleanup()

        Path path = new Path(p, ".");
        AntClassLoader loader = p.createClassLoader(path);
        try {
            // we don't expect to find this
            loader.findClass("fubar");
            fail("Did not expect to find fubar class");
        } catch (ClassNotFoundException e) {
            // ignore expected
        }

        loader.cleanup();
        try {
            // we don't expect to find this
            loader.findClass("fubar");
            fail("Did not expect to find fubar class");
        } catch (ClassNotFoundException e) {
            // ignore expected
        } catch (NullPointerException e) {
            fail("loader should not fail even if cleaned up");
        }

        // tell the build it is finished
        p.fireBuildFinished(null);
        try {
            // we don't expect to find this
            loader.findClass("fubar");
            fail("Did not expect to find fubar class");
        } catch (ClassNotFoundException e) {
            // ignore expected
        } catch (NullPointerException e) {
            fail("loader should not fail even if project finished");
        }
    
public voidtestJarWithManifestInDirWithSpace()

        String mainjarstring = getProject().getProperty("main.jar");
        String extjarstring = getProject().getProperty("ext.jar");
        Path myPath = new Path(getProject());
        myPath.setLocation(new File(mainjarstring));
        getProject().setUserProperty("build.sysclasspath","ignore");
        AntClassLoader myLoader = getProject().createClassLoader(myPath);
        String path = myLoader.getClasspath();
        assertEquals(mainjarstring + File.pathSeparator + extjarstring, path);
    
public voidtestJarWithManifestInNonAsciiDir()

        String mainjarstring = getProject().getProperty("main.jar.nonascii");
        String extjarstring = getProject().getProperty("ext.jar.nonascii");
        Path myPath = new Path(getProject());
        myPath.setLocation(new File(mainjarstring));
        getProject().setUserProperty("build.sysclasspath","ignore");
        AntClassLoader myLoader = getProject().createClassLoader(myPath);
        String path = myLoader.getClasspath();
        assertEquals(mainjarstring + File.pathSeparator + extjarstring, path);