diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java index 6c5c519ca11..87741bdfe33 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java @@ -28,6 +28,7 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; import javax.servlet.DispatcherType; +import javax.servlet.ServletContext; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.HttpTester; @@ -69,7 +70,7 @@ public class PutFilterTest tester.addServlet(org.eclipse.jetty.servlet.DefaultServlet.class, "/"); FilterHolder holder = tester.addFilter(PutFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); holder.setInitParameter("delAllowed", "true"); - tester.setAttribute("javax.servlet.context.tempdir", workDir.getPath().toFile()); + tester.setAttribute(ServletContext.TEMPDIR, workDir.getPath().toFile()); // Bloody Windows does not allow file renaming if (!System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")) holder.setInitParameter("putAtomic", "true"); diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java index 7f928dacda1..5bea929c867 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java @@ -18,30 +18,33 @@ package org.eclipse.jetty.server.session; -import java.nio.file.Files; - import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; +import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; /** * ClusteredOrphanedSessionTest */ +@ExtendWith(WorkDirExtension.class) public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest { - public static InfinispanTestSupport __testSupport; + public WorkDir workDir; + public InfinispanTestSupport testSupport; - @BeforeAll - public static void setup() throws Exception + @BeforeEach + public void setup() throws Exception { - __testSupport = new InfinispanTestSupport(); - __testSupport.setup(Files.createTempDirectory(ClusteredOrphanedSessionTest.class.getName())); + testSupport = new InfinispanTestSupport(); + testSupport.setup(workDir.getEmptyPathDir()); } - @AfterAll - public static void teardown() throws Exception + @AfterEach + public void teardown() throws Exception { - __testSupport.teardown(); + testSupport.teardown(); } /** @@ -51,7 +54,7 @@ public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessi public SessionDataStoreFactory createSessionDataStoreFactory() { InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory(); - factory.setCache(__testSupport.getCache()); + factory.setCache(testSupport.getCache()); return factory; } } diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSerializedSessionScavengingTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSerializedSessionScavengingTest.java index 266f506d3e9..b7d5fef4828 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSerializedSessionScavengingTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSerializedSessionScavengingTest.java @@ -18,34 +18,37 @@ package org.eclipse.jetty.server.session; -import java.nio.file.Files; - import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; +import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * ClusteredSerializedSessionScavengingTest */ +@ExtendWith(WorkDirExtension.class) public class ClusteredSerializedSessionScavengingTest extends AbstractClusteredSessionScavengingTest { - public static InfinispanTestSupport __testSupport; + public WorkDir workDir; + public static InfinispanTestSupport testSupport; - @BeforeAll - public static void setup() throws Exception + @BeforeEach + public void setup() throws Exception { - __testSupport = new InfinispanTestSupport(); - __testSupport.setUseFileStore(true); - __testSupport.setSerializeSessionData(true); - __testSupport.setup(Files.createTempDirectory(ClusteredSerializedSessionScavengingTest.class.getName())); + testSupport = new InfinispanTestSupport(); + testSupport.setUseFileStore(true); + testSupport.setSerializeSessionData(true); + testSupport.setup(workDir.getEmptyPathDir()); } - @AfterAll - public static void teardown() throws Exception + @AfterEach + public void teardown() throws Exception { - if (__testSupport != null) - __testSupport.teardown(); + if (testSupport != null) + testSupport.teardown(); } @Override @@ -63,7 +66,7 @@ public class ClusteredSerializedSessionScavengingTest extends AbstractClusteredS public SessionDataStoreFactory createSessionDataStoreFactory() { InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory(); - factory.setCache(__testSupport.getCache()); + factory.setCache(testSupport.getCache()); return factory; } } diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java index 849ec6a85bb..6f4d3bdf371 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java @@ -18,33 +18,36 @@ package org.eclipse.jetty.server.session; -import java.nio.file.Files; - import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; +import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * ClusteredSessionScavengingTest */ +@ExtendWith(WorkDirExtension.class) public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest { - public static InfinispanTestSupport __testSupport; + public WorkDir workDir; + public InfinispanTestSupport testSupport; - @BeforeAll - public static void setup() throws Exception + @BeforeEach + public void setup() throws Exception { - __testSupport = new InfinispanTestSupport(); - __testSupport.setUseFileStore(true); - __testSupport.setup(Files.createTempDirectory(ClusteredSessionScavengingTest.class.getName())); + testSupport = new InfinispanTestSupport(); + testSupport.setUseFileStore(true); + testSupport.setup(workDir.getEmptyPathDir()); } - @AfterAll - public static void teardown() throws Exception + @AfterEach + public void teardown() throws Exception { - if (__testSupport != null) - __testSupport.teardown(); + if (testSupport != null) + testSupport.teardown(); } @Override @@ -62,7 +65,7 @@ public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScav public SessionDataStoreFactory createSessionDataStoreFactory() { InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory(); - factory.setCache(__testSupport.getCache()); + factory.setCache(testSupport.getCache()); return factory; } }