Skip to content

Commit

Permalink
Issue #5451 - Proper use of WorkDir
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Oct 16, 2020
1 parent 6f98b13 commit 369940c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 45 deletions.
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void setUp() throws Exception
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");
Expand Down
Expand Up @@ -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();
}

/**
Expand All @@ -51,7 +54,7 @@ public static void teardown() throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
factory.setCache(testSupport.getCache());
return factory;
}
}
Expand Up @@ -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
Expand All @@ -63,7 +66,7 @@ public void testClusteredScavenge()
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
factory.setCache(testSupport.getCache());
return factory;
}
}
Expand Up @@ -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
Expand All @@ -62,7 +65,7 @@ public void testClusteredScavenge()
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
factory.setCache(testSupport.getCache());
return factory;
}
}

0 comments on commit 369940c

Please sign in to comment.