diff --git a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java index cdf5421ebb5..a02ca33d274 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java +++ b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java @@ -27,14 +27,18 @@ import java.util.List; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.component.LifeCycle; +import org.eclipse.jetty.util.resource.FileSystemPool; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.eclipse.jetty.toolchain.test.ExtraMatchers.ordered; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; @@ -53,11 +57,12 @@ public class WebAppClassLoaderTest @BeforeEach public void init() throws Exception { + assertThat(FileSystemPool.INSTANCE.mounts(), empty()); this.testWebappDir = MavenTestingUtils.getProjectDirPath("src/test/webapp"); - Resource webapp = ResourceFactory.root().newResource(testWebappDir); _context = new WebAppContext(); - _context.setBaseResource(webapp.getPath()); + Resource webapp = ResourceFactory.of(_context).newResource(testWebappDir); + _context.setBaseResource(webapp); _context.setContextPath("/test"); _context.setExtraClasspath("src/test/resources/ext/*"); @@ -67,6 +72,15 @@ public class WebAppClassLoaderTest _loader.setName("test"); _context.setServer(new Server()); + LifeCycle.start(_context); + } + + @AfterEach + public void tearDown() + { + IO.close(_loader); + LifeCycle.stop(_context); + assertThat(FileSystemPool.INSTANCE.mounts(), empty()); } public void assertCanLoadClass(String clazz) throws ClassNotFoundException