This is an automated email from the git hooks/post-receive script. New commit to branch feature/jdk11 in repository nuiton-utils. See https://gitlab.nuiton.org/nuiton/nuiton-utils.git commit 10059514ff3f111c5d8b5214f12f934313722ddc Author: Arnaud Thimel <thimel@codelutin.com> Date: Fri Jan 3 18:08:34 2020 +0100 [iso] setup/teardown method at the top of the class --- src/test/java/org/nuiton/util/ResourceTest.java | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/test/java/org/nuiton/util/ResourceTest.java b/src/test/java/org/nuiton/util/ResourceTest.java index 27be3ce..f8ea5e2 100644 --- a/src/test/java/org/nuiton/util/ResourceTest.java +++ b/src/test/java/org/nuiton/util/ResourceTest.java @@ -54,6 +54,31 @@ public class ResourceTest { // ResourceTest /** Logger. */ private static final Log log = LogFactory.getLog(ResourceTest.class); + // unaltered classloader + static ClassLoader systemClassLoader; + + @BeforeClass + public static void beforeClass() { + systemClassLoader = ClassLoader.getSystemClassLoader(); + } + + @Before + public void beforeTest() throws NoSuchFieldException, IllegalAccessException { + URLClassLoader classLoader = (URLClassLoader) systemClassLoader; + ClassLoader parent = classLoader.getParent(); + ClassLoader currentClassLoader = new URLClassLoader(classLoader.getURLs(), parent); + Field field = ClassLoader.class.getDeclaredField("scl"); + field.setAccessible(true); + field.set(null, currentClassLoader); + } + + @After + public void afterTest() throws NoSuchFieldException, IllegalAccessException { + Field field = ClassLoader.class.getDeclaredField("scl"); + field.setAccessible(true); + field.set(null, systemClassLoader); + } + @Test public void testAddDefaultClassLoader() throws Exception { String javaExecFilename = getJavaExecName(); @@ -125,31 +150,6 @@ public class ResourceTest { // ResourceTest Assert.assertEquals(1, result.size()); } - // unaltered classloader - static ClassLoader systemClassLoader; - - @BeforeClass - public static void beforeClass() { - systemClassLoader = ClassLoader.getSystemClassLoader(); - } - - @Before - public void beforeTest() throws NoSuchFieldException, IllegalAccessException { - URLClassLoader classLoader = (URLClassLoader) systemClassLoader; - ClassLoader parent = classLoader.getParent(); - ClassLoader currentClassLoader = new URLClassLoader(classLoader.getURLs(), parent); - Field field = ClassLoader.class.getDeclaredField("scl"); - field.setAccessible(true); - field.set(null, currentClassLoader); - } - - @After - public void afterTest() throws NoSuchFieldException, IllegalAccessException { - Field field = ClassLoader.class.getDeclaredField("scl"); - field.setAccessible(true); - field.set(null, systemClassLoader); - } - @Test public void testGetURLs() throws Exception { if (log.isInfoEnabled()) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.