Package org.codehaus.loom.classman.runtime

Examples of org.codehaus.loom.classman.runtime.JoinClassLoader


     * @throws Exception if unable to create classloader
     */
    public ClassLoader createJoinClassLoader( final ClassLoader[] classLoaders )
        throws Exception
    {
        return new JoinClassLoader( classLoaders,
                                    ClassLoader.getSystemClassLoader() );
    }
View Full Code Here


        }

        final URLClassLoader cl1 = createClassLoader( "cl1.jar" );
        final URLClassLoader cl2 = createClassLoader( "cl2.jar" );
        final ClassLoader[] cls = new ClassLoader[]{cl1, cl2};
        final JoinClassLoader join =
            new JoinClassLoader( cls, ClassLoader.getSystemClassLoader() );
        try
        {
            join.loadClass( DataConstants.DATA1_CLASS );
        }
        catch( ClassNotFoundException e )
        {
            fail( "Unable to load Data1 from cl1 classloader" );
        }
        try
        {
            join.loadClass( DataConstants.DATA2_CLASS );
        }
        catch( ClassNotFoundException e )
        {
            fail( "Unable to load CL2Data from cl2 classloader" );
        }
        try
        {
            join.loadClass( "i.no.exist" );
            fail( "Expected that would be unable to load non-existent class" );
        }
        catch( ClassNotFoundException e )
        {
        }

        try
        {
            assertEquals( "Loading from system classloader",
                          Integer.class,
                          join.loadClass( Integer.class.getName() ) );
        }
        catch( ClassNotFoundException e )
        {
            fail( "Unable to load Integer from classloader" );
        }

        final URL url1 = join.getResource( DataConstants.DATA1_RESOURCE );
        assertNotNull( "Loading " + DataConstants.DATA1_RESOURCE + " from c1 classloader",
                       url1 );
        final URL url2 = join.getResource( "noexist.txt" );
        assertNull( "Loading noexist.txt from c1 classloader", url2 );

        final Enumeration resources1 = join.getResources( DataConstants.DATA1_RESOURCE );
        assertNotNull( "Loading set of " + DataConstants.DATA1_RESOURCE + " from c1 classloader",
                       resources1 );
        assertTrue( "Count of resource from classloader", resources1.hasMoreElements() );
        assertEquals( "Resource found from classloader", url1, resources1.nextElement() );

        assertTrue( "Second Count of resource from classloader", !resources1.hasMoreElements() );

        final Enumeration resources2 = join.getResources( "noexist.txt" );
        assertNotNull( "Loading set of noexist.txt from c1 classloader", resources2 );
        assertTrue( "Count of noexist.txt from classloader", !resources2.hasMoreElements() );

        try
        {
View Full Code Here

    public void testCtorNullsInClassLoaderSet()
        throws Exception
    {
        try
        {
            new JoinClassLoader( null,
                                 ClassLoader.getSystemClassLoader() );
            fail( "Expected a NPE" );
        }
        catch( NullPointerException e )
        {
            assertEquals( "NPE type", "classLoaders", e.getMessage() );
        }
        try
        {
            new JoinClassLoader( new ClassLoader[]{null},
                                 ClassLoader.getSystemClassLoader() );
            fail( "Expected a NPE" );
        }
        catch( NullPointerException e )
        {
View Full Code Here

TOP

Related Classes of org.codehaus.loom.classman.runtime.JoinClassLoader

Copyright © 2018 www.massapicom. 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.