Examples of PathableClassLoader


Examples of org.apache.commons.logging.PathableClassLoader

    /**
     * Return the tests included in this test suite.
     */
    public static Test suite() throws Exception {
        PathableClassLoader parent = new PathableClassLoader(null);
        parent.useSystemLoader("junit.");
        // the TestHandler class must be accessable from the System classloader
        // in order for java.util.logging.LogManager.readConfiguration to
        // be able to instantiate it. And this test case must see the same
        // class in order to be able to access its data. Yes this is ugly
        // but the whole jdk14 API is a ******* mess anyway.
        parent.useSystemLoader("org.apache.commons.logging.jdk14.TestHandler");
        parent.addLogicalLib("commons-logging");

        PathableClassLoader child = new PathableClassLoader(parent);
        child.addLogicalLib("testclasses");
       
        Class testClass = child.loadClass(CustomConfigFullTestCase.class.getName());
        return new PathableTestSuite(testClass, child);
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

     */
    public static Test suite() throws Exception {
        Class thisClass = GeneralTestCase.class;
        ClassLoader thisClassLoader = thisClass.getClassLoader();
       
        PathableClassLoader loader = new PathableClassLoader(null);
        loader.useExplicitLoader("junit.", thisClassLoader);
        loader.addLogicalLib("testclasses");

        // reload this class via the child classloader
        Class testClass = loader.loadClass(thisClass.getName());
       
        // and return our custom TestSuite class
        return new PathableTestSuite(testClass, loader);
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

        Class thisClass = ChildFirstTestCase.class;
        ClassLoader thisClassLoader = thisClass.getClassLoader();
       
        // Make the parent a direct child of the bootloader to hide all
        // other classes in the system classpath
        PathableClassLoader parent = new PathableClassLoader(null);
        parent.setParentFirst(false);
       
        // Make the junit classes visible as a special case, as junit
        // won't be able to call this class at all without this. The
        // junit classes must be visible from the classloader that loaded
        // this class, so use that as the source for future access to classes
        // from the junit package.
        parent.useExplicitLoader("junit.", thisClassLoader);
       
        // Make the commons-logging.jar classes visible via the parent
        parent.addLogicalLib("commons-logging");
       
        // Create a child classloader to load the test case through
        PathableClassLoader child = new PathableClassLoader(parent);
        child.setParentFirst(false);
       
        // Obviously, the child classloader needs to have the test classes
        // in its path!
        child.addLogicalLib("testclasses");
        child.addLogicalLib("commons-logging-adapters");
       
        // Create a third classloader to be the context classloader.
        PathableClassLoader context = new PathableClassLoader(child);
        context.setParentFirst(false);

        // reload this class via the child classloader
        Class testClass = child.loadClass(thisClass.getName());
       
        // and return our custom TestSuite class
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

        Class thisClass = ParentFirstTestCase.class;
        ClassLoader thisClassLoader = thisClass.getClassLoader();

        // Make the parent a direct child of the bootloader to hide all
        // other classes in the system classpath
        PathableClassLoader parent = new PathableClassLoader(null);
       
        // Make the junit classes visible as a special case, as junit
        // won't be able to call this class at all without this. The
        // junit classes must be visible from the classloader that loaded
        // this class, so use that as the source for future access to classes
        // from the junit package.
        parent.useExplicitLoader("junit.", thisClassLoader);
       
        // make the commons-logging.jar classes visible via the parent
        parent.addLogicalLib("commons-logging");
       
        // create a child classloader to load the test case through
        PathableClassLoader child = new PathableClassLoader(parent);
       
        // obviously, the child classloader needs to have the test classes
        // in its path!
        child.addLogicalLib("testclasses");
        child.addLogicalLib("commons-logging-adapters");
       
        // create a third classloader to be the context classloader.
        PathableClassLoader context = new PathableClassLoader(child);

        // reload this class via the child classloader
        Class testClass = child.loadClass(thisClass.getName());
       
        // and return our custom TestSuite class
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

     * Or we could fix SimpleLog to be sane...
     */
    public static Test suite() throws Exception {
        Class thisClass = DefaultConfigTestCase.class;

        PathableClassLoader loader = new PathableClassLoader(null);
        loader.useSystemLoader("junit.");
        loader.addLogicalLib("testclasses");
        loader.addLogicalLib("commons-logging");
       
        Class testClass = loader.loadClass(thisClass.getName());
        return new PathableTestSuite(testClass, loader);
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

     * Or we could fix SimpleLog to be sane...
     */
    public static Test suite() throws Exception {
        Class thisClass = DateTimeCustomConfigTestCase.class;

        PathableClassLoader loader = new PathableClassLoader(null);
        loader.useSystemLoader("junit.");
        loader.addLogicalLib("testclasses");
        loader.addLogicalLib("commons-logging");
       
        Class testClass = loader.loadClass(thisClass.getName());
        return new PathableTestSuite(testClass, loader);
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

     * Or we could fix SimpleLog to be sane...
     */
    public static Test suite() throws Exception {
        Class thisClass = CustomConfigTestCase.class;

        PathableClassLoader loader = new PathableClassLoader(null);
        loader.useSystemLoader("junit.");
        loader.addLogicalLib("testclasses");
        loader.addLogicalLib("commons-logging");
       
        Class testClass = loader.loadClass(thisClass.getName());
        return new PathableTestSuite(testClass, loader);
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

* Simulates the case when TCCL is badly set and cannot load JCL.
*/
public class BadTCCLTestCase extends TestCase {

    public static Test suite() throws Exception {
        PathableClassLoader contextClassLoader = new PathableClassLoader(null);
        contextClassLoader.useSystemLoader("junit.");
        PathableTestSuite suite = new PathableTestSuite(BadTCCLTestCase.class, contextClassLoader);
        return suite;
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

        // Determine the URL to this .class file, so that we can then
        // append the priority dirs to it. For tidiness, load this
        // class through a dummy loader though this is not absolutely
        // necessary...
        PathableClassLoader dummy = new PathableClassLoader(null);
        dummy.useSystemLoader("junit.");
        dummy.addLogicalLib("testclasses");
        dummy.addLogicalLib("commons-logging");
       
        String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
        URL baseUrl = dummy.findResource(thisClassPath);

        // Now set up the desired classloader hierarchy. Everything goes into
        // the parent classpath, but we exclude the custom LogFactoryImpl
        // class.
        //
        // We then create a tccl classloader that can see the custom
        // LogFactory class. Therefore if that class can be found, then the
        // TCCL must have been used to load it.
        PathableClassLoader emptyLoader = new PathableClassLoader(null);
       
        PathableClassLoader parentLoader = new PathableClassLoader(null);
        parentLoader.useSystemLoader("junit.");
        parentLoader.addLogicalLib("commons-logging");
        parentLoader.addLogicalLib("testclasses");
        // hack to ensure that the testcase classloader can't see
        // the custom MyLogFactoryImpl
        parentLoader.useExplicitLoader(
            MY_LOG_FACTORY_PKG + ".", emptyLoader);
       
        URL propsEnableUrl = new URL(baseUrl, "props_disable_tccl/");
        parentLoader.addURL(propsEnableUrl);

        PathableClassLoader tcclLoader = new PathableClassLoader(parentLoader);
        tcclLoader.addLogicalLib("testclasses");

        Class testClass = parentLoader.loadClass(thisClass.getName());
        return new PathableTestSuite(testClass, tcclLoader);
    }
View Full Code Here

Examples of org.apache.commons.logging.PathableClassLoader

        // Determine the URL to this .class file, so that we can then
        // append the priority dirs to it. For tidiness, load this
        // class through a dummy loader though this is not absolutely
        // necessary...
        PathableClassLoader dummy = new PathableClassLoader(null);
        dummy.useSystemLoader("junit.");
        dummy.addLogicalLib("testclasses");
        dummy.addLogicalLib("commons-logging");
       
        String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
        URL baseUrl = dummy.findResource(thisClassPath);

        // Now set up the desired classloader hierarchy. Everything goes into
        // the parent classpath, but we exclude the custom Log class.
        //
        // We then create a tccl classloader that can see the custom
        // Log class. Therefore if that class can be found, then the
        // TCCL must have been used to load it.
        PathableClassLoader emptyLoader = new PathableClassLoader(null);
       
        PathableClassLoader parentLoader = new PathableClassLoader(null);
        parentLoader.useSystemLoader("junit.");
        parentLoader.addLogicalLib("commons-logging");
        parentLoader.addLogicalLib("testclasses");
        // hack to ensure that the testcase classloader can't see
        // the custom MyLog
        parentLoader.useExplicitLoader(MY_LOG_PKG + ".", emptyLoader);
       
        URL propsEnableUrl = new URL(baseUrl, "props_disable_tccl/");
        parentLoader.addURL(propsEnableUrl);

        PathableClassLoader tcclLoader = new PathableClassLoader(parentLoader);
        tcclLoader.addLogicalLib("testclasses");

        Class testClass = parentLoader.loadClass(thisClass.getName());
        return new PathableTestSuite(testClass, tcclLoader);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.