Skip to content

Commit

Permalink
Merge pull request from GHSA-g3wg-6mcf-8jj6
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime authored Oct 15, 2020
1 parent 53e0e0e commit 9ad6beb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@

import java.io.File;
import java.lang.annotation.ElementType;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;

import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.IO;
import org.hibernate.search.cfg.Environment;
import org.hibernate.search.cfg.SearchMapping;
Expand All @@ -33,15 +37,18 @@
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* InfinispanTestSupport
*/
@ExtendWith(WorkDirExtension.class)
public class InfinispanTestSupport
{
public WorkDir workDir;
public static final String DEFAULT_CACHE_NAME = "session_test_cache";
public Cache _cache;

Expand Down Expand Up @@ -95,22 +102,20 @@ public Cache getCache()

public void setup() throws Exception
{
File testdir = MavenTestingUtils.getTargetTestingDir();
File tmp = new File(testdir, "indexes");
IO.delete(tmp);
tmp.mkdirs();
Path root = workDir.getEmptyPathDir();
Path indexesDir = root.resolve("indexes");
FS.ensureDirExists(indexesDir);

SearchMapping mapping = new SearchMapping();
mapping.entity(SessionData.class).indexed().providedId().property("expiry", ElementType.FIELD).field();
Properties properties = new Properties();
properties.put(Environment.MODEL_MAPPING, mapping);
properties.put("hibernate.search.default.indexBase", tmp.getAbsolutePath());
properties.put("hibernate.search.default.indexBase", indexesDir.toString());

if (_useFileStore)
{
_tmpdir = File.createTempFile("infini", "span");
_tmpdir.delete();
_tmpdir.mkdir();
Path tmpDir = Files.createTempDirectory("infinispan");
_tmpdir = tmpDir.toFile();

ConfigurationChildBuilder b = _builder.indexing()
.index(Index.ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.eclipse.jetty;

import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.file.FileSystems;
Expand Down Expand Up @@ -116,8 +115,8 @@ public static void main(String[] args) throws Exception
login.setConfig(jettyRoot.resolve("tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/etc/realm.properties").toString());
server.addBean(login);

File log = File.createTempFile("jetty-yyyy_mm_dd", "log");
CustomRequestLog requestLog = new CustomRequestLog(log.toString());
Path logPath = Files.createTempFile("jetty-yyyy_mm_dd", "log");
CustomRequestLog requestLog = new CustomRequestLog(logPath.toString());
server.setRequestLog(requestLog);

server.setStopAtShutdown(true);
Expand All @@ -127,15 +126,11 @@ public static void main(String[] args) throws Exception
webapp.setParentLoaderPriority(true);
webapp.setResourceBase(jettyRoot.resolve("tests/test-webapps/test-jetty-webapp/src/main/webapp").toString());
webapp.setAttribute("testAttribute", "testValue");
File sessiondir = File.createTempFile("sessions", null);
if (sessiondir.exists())
sessiondir.delete();
sessiondir.mkdir();
sessiondir.deleteOnExit();
Path sessionDir = Files.createTempDirectory("sessions");
DefaultSessionCache ss = new DefaultSessionCache(webapp.getSessionHandler());
FileSessionDataStore sds = new FileSessionDataStore();
ss.setSessionDataStore(sds);
sds.setStoreDir(sessiondir);
sds.setStoreDir(sessionDir.toFile());
webapp.getSessionHandler().setSessionCache(ss);

contexts.addHandler(webapp);
Expand Down

0 comments on commit 9ad6beb

Please sign in to comment.