Jetty 12 - Re-enable some disabled session tests. (#8714)

* Re-enable some disabled session tests.

* Add needed test resources to ee8 jdbc session test.
This commit is contained in:
Jan Bartel 2022-11-22 17:25:06 +11:00 committed by GitHub
parent 11fdbbef02
commit 07202102b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 31 additions and 18 deletions

View File

@ -44,7 +44,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* ReloadedSessionMissingClassTest
*/
//TODO
@Disabled
@ExtendWith(WorkDirExtension.class)
@Testcontainers(disabledWithoutDocker = true)
public class ReloadedSessionMissingClassTest

View File

@ -23,7 +23,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
* WebAppObjectInSessionTest
*/
//TODO
@Disabled
@Testcontainers(disabledWithoutDocker = true)
public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest
{

View File

@ -16,6 +16,7 @@ package org.eclipse.jetty.ee10.session;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.net.URL;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
@ -74,14 +75,14 @@ public abstract class AbstractWebAppObjectInSessionTest extends AbstractSessionT
w.close();
File classesDir = new File(webInfDir, "classes");
classesDir.mkdir();
String packageName = WebAppObjectInSessionServlet.class.getPackage().getName();
File packageDirs = new File(classesDir, packageName.replace('.', File.separatorChar));
String packageName = File.separator + WebAppObjectInSessionServlet.class.getPackage().getName().replace('.', File.separatorChar) + File.separator;
File packageDirs = new File(classesDir, packageName);
packageDirs.mkdirs();
try (ResourceFactory.Closeable resourceFactory = ResourceFactory.closeable())
{
String resourceName = WebAppObjectInSessionServlet.class.getSimpleName() + ".class";
Resource resource = resourceFactory.newResource(getClass().getResource(resourceName));
Resource resource = resourceFactory.newResource(getClass().getResource(packageName + resourceName));
//File sourceFile = new File(getClass().getClassLoader().getResource(resourceName).toURI());
File targetFile = new File(packageDirs, resourceName);
@ -89,7 +90,7 @@ public abstract class AbstractWebAppObjectInSessionTest extends AbstractSessionT
IO.copy(resource.newInputStream(), new FileOutputStream(targetFile));
resourceName = WebAppObjectInSessionServlet.class.getSimpleName() + "$" + WebAppObjectInSessionServlet.TestSharedStatic.class.getSimpleName() + ".class";
resource = resourceFactory.newResource(getClass().getResource(resourceName));
resource = resourceFactory.newResource(getClass().getResource(packageName + resourceName));
//sourceFile = new File(getClass().getClassLoader().getResource(resourceName).toURI());
targetFile = new File(packageDirs, resourceName);
//copy(sourceFile, targetFile);

View File

@ -136,8 +136,14 @@ public class SessionTestSupport
public WebAppContext addWebAppContext(String warPath, String contextPath) throws Exception
{
//TODO
throw new UnsupportedOperationException("TODO!");
WebAppContext context = new WebAppContext(warPath, contextPath);
SessionHandler sessionHandler = newSessionHandler();
sessionHandler.setSessionIdManager(_sessionIdManager);
sessionHandler.setMaxInactiveInterval(_maxInactivePeriod);
context.setSessionHandler(sessionHandler);
_contexts.addHandler(context);
return context;
}
public Server getServer()

View File

@ -0,0 +1,2 @@
# Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.LEVEL=DEBUG

View File

@ -0,0 +1,3 @@
org.slf4j.simpleLogger.defaultLogLevel=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.session.MariaDbLogs=error
org.slf4j.simpleLogger.log.org.eclipse.jetty.session.JdbcTestHelper=info

View File

@ -43,8 +43,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* ReloadedSessionMissingClassTest
*/
//TODO
@Disabled
@ExtendWith(WorkDirExtension.class)
@Testcontainers(disabledWithoutDocker = true)
public class ReloadedSessionMissingClassTest
@ -115,6 +113,7 @@ public class ReloadedSessionMissingClassTest
assertNotNull(sessionId);
//Stop the webapp
webApp.get().stop();
webApp.stop();
webApp.setClassLoader(loaderWithoutFoo);

View File

@ -22,8 +22,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
/**
* WebAppObjectInSessionTest
*/
//TODO
@Disabled
@Testcontainers(disabledWithoutDocker = true)
public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest
{

View File

@ -74,14 +74,14 @@ public abstract class AbstractWebAppObjectInSessionTest extends AbstractSessionT
w.close();
File classesDir = new File(webInfDir, "classes");
classesDir.mkdir();
String packageName = WebAppObjectInSessionServlet.class.getPackage().getName();
File packageDirs = new File(classesDir, packageName.replace('.', File.separatorChar));
String packageName = File.separator + WebAppObjectInSessionServlet.class.getPackage().getName().replace('.', File.separatorChar) + File.separator;
File packageDirs = new File(classesDir, packageName);
packageDirs.mkdirs();
try (ResourceFactory.Closeable resourceFactory = ResourceFactory.closeable())
{
String resourceName = WebAppObjectInSessionServlet.class.getSimpleName() + ".class";
Resource resource = resourceFactory.newResource(getClass().getResource(resourceName));
Resource resource = resourceFactory.newResource(getClass().getResource(packageName + resourceName));
//File sourceFile = new File(getClass().getClassLoader().getResource(resourceName).toURI());
File targetFile = new File(packageDirs, resourceName);
@ -89,7 +89,7 @@ public abstract class AbstractWebAppObjectInSessionTest extends AbstractSessionT
IO.copy(resource.newInputStream(), new FileOutputStream(targetFile));
resourceName = WebAppObjectInSessionServlet.class.getSimpleName() + "$" + WebAppObjectInSessionServlet.TestSharedStatic.class.getSimpleName() + ".class";
resource = resourceFactory.newResource(getClass().getResource(resourceName));
resource = resourceFactory.newResource(getClass().getResource(packageName + resourceName));
//sourceFile = new File(getClass().getClassLoader().getResource(resourceName).toURI());
targetFile = new File(packageDirs, resourceName);
//copy(sourceFile, targetFile);

View File

@ -136,8 +136,14 @@ public class SessionTestSupport
public WebAppContext addWebAppContext(String warPath, String contextPath) throws Exception
{
//TODO
throw new UnsupportedOperationException("TODO!");
WebAppContext context = new WebAppContext(warPath, contextPath);
SessionHandler sessionHandler = newSessionHandler();
sessionHandler.getSessionManager().setSessionIdManager(_sessionIdManager);
sessionHandler.setMaxInactiveInterval(_maxInactivePeriod);
context.setSessionHandler(sessionHandler);
_contexts.addHandler(context);
return context;
}
public Server getServer()