On 15 February 2014 09:52, Benedikt Ritter <brit...@apache.org> wrote: > HI Bernd, > > > 2014-02-14 23:44 GMT+01:00 <e...@apache.org>: > >> Author: ecki >> Date: Fri Feb 14 22:44:04 2014 >> New Revision: 1568538 >> >> URL: http://svn.apache.org/r1568538 >> Log: >> [VFS-500][tests] use a non-delegating parent class loader to fix continuum >> CI test failure due to found system resource. >> >> Modified: >> >> commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/impl/test/VfsClassLoaderTests.java >> >> Modified: >> commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/impl/test/VfsClassLoaderTests.java >> URL: >> http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/impl/test/VfsClassLoaderTests.java?rev=1568538&r1=1568537&r2=1568538&view=diff >> >> ============================================================================== >> --- >> commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/impl/test/VfsClassLoaderTests.java >> (original) >> +++ >> commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/impl/test/VfsClassLoaderTests.java >> Fri Feb 14 22:44:04 2014 >> @@ -17,8 +17,10 @@ >> package org.apache.commons.vfs2.impl.test; >> >> import java.io.File; >> +import java.io.IOException; >> import java.net.URL; >> import java.net.URLConnection; >> +import java.util.Collections; >> import java.util.Enumeration; >> >> import org.apache.commons.AbstractVfsTestCase; >> @@ -140,7 +142,13 @@ public class VfsClassLoaderTests >> assertTrue("nested.jar is required for testing", >> nestedJar.getType() == FileType.FILE); >> assertTrue("test.jar is required for testing", testJar.getType() >> == FileType.FILE); >> >> - final VFSClassLoader loader = new VFSClassLoader(search, >> getManager()); >> + // System class loader (null) might be unpredictable in regards >> + // to returning resources for META-INF/MANIFEST.MF (see VFS-500) >> + // so we use our own which is guaranteed to not return any hit >> + final ClassLoader mockClassloader = new MockClassloader(); >> + >> + final VFSClassLoader loader = new VFSClassLoader(search, >> getManager(), mockClassloader); >> + >> final Enumeration<URL> urls = >> loader.getResources("META-INF/MANIFEST.MF"); >> final URL url1 = urls.nextElement(); >> final URL url2 = urls.nextElement(); >> @@ -178,4 +186,34 @@ public class VfsClassLoaderTests >> } >> } >> >> + >> + /** >> + * Non-Delegating Class Loader. >> + */ >> + public static class MockClassloader extends ClassLoader >> + { >> > > If this class is not used elsewhere, it can be made private.
True, but this is test code, so we don't need to worry about binary compatibility. > Benedikt > > >> + MockClassloader() >> + { >> + super(null); >> + } >> + >> + /** >> + * This method will not return any hit to >> + * VFSClassLoader#testGetResourcesJARs. >> + */ >> + @Override >> + public Enumeration<URL> getResources(String name) >> + throws IOException >> + { >> + return Collections.enumeration(Collections.<URL> emptyList()); >> + } >> + >> + @Override >> + protected Class<?> findClass(String name) >> + throws ClassNotFoundException >> + { >> + fail("Not intended to be used for class loading."); >> + return null; >> + } >> + } >> } >> >> >> > > > -- > http://people.apache.org/~britter/ > http://www.systemoutprintln.de/ > http://twitter.com/BenediktRitter > http://github.com/britter --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org