From 34809d7cf728bce4bc92d8722df14825b71784d0 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 4 May 2022 18:41:12 +0200 Subject: [PATCH] WIP moving session tests to ee9 --- jetty-core/jetty-bom/pom.xml | 11 ++++++ jetty-ee9/test-ee9-sessions/pom.xml | 6 ++-- .../test-ee9-file-sessions/pom.xml | 9 ++++- .../session/ClusteredOrphanedSessionTest.java | 4 +++ .../test-ee9-jdbc-sessions/pom.xml | 12 +++++++ .../ClusteredInvalidationSessionTest.java | 4 +++ .../session/ClusteredOrphanedSessionTest.java | 4 +++ .../ClusteredSessionMigrationTest.java | 3 ++ .../ClusteredSessionScavengingTest.java | 4 +++ .../session/JDBCSessionDataStoreTest.java | 3 +- .../eclipse/jetty/session/JdbcTestHelper.java | 2 ++ .../ReloadedSessionMissingClassTest.java | 5 +++ .../jetty/session/SessionTableSchemaTest.java | 35 ++++++++++++------- .../session/WebAppObjectInSessionTest.java | 4 +++ .../test-ee9-mongodb-sessions/pom.xml | 6 ++++ .../nosql/mongodb/AttributeNameTest.java | 9 ++--- .../ClusteredInvalidateSessionTest.java | 5 ++- .../mongodb/ClusteredOrphanedSessionTest.java | 5 ++- .../ClusteredSessionScavengingTest.java | 5 ++- .../mongodb/MongoSessionDataStoreTest.java | 9 +++-- 20 files changed, 118 insertions(+), 27 deletions(-) diff --git a/jetty-core/jetty-bom/pom.xml b/jetty-core/jetty-bom/pom.xml index f11ed41abdf..a95ab3349ab 100644 --- a/jetty-core/jetty-bom/pom.xml +++ b/jetty-core/jetty-bom/pom.xml @@ -277,6 +277,17 @@ jetty-server 12.0.0-SNAPSHOT + + org.eclipse.jetty + jetty-session + 12.0.0-SNAPSHOT + + + org.eclipse.jetty + jetty-session + 12.0.0-SNAPSHOT + test-jar + org.eclipse.jetty jetty-slf4j-impl diff --git a/jetty-ee9/test-ee9-sessions/pom.xml b/jetty-ee9/test-ee9-sessions/pom.xml index d5f5b4180bc..68fab4ae8df 100644 --- a/jetty-ee9/test-ee9-sessions/pom.xml +++ b/jetty-ee9/test-ee9-sessions/pom.xml @@ -12,9 +12,9 @@ pom test-ee9-sessions-common - - - + test-ee9-file-sessions + test-ee9-jdbc-sessions + test-ee9-mongodb-sessions diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/pom.xml b/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/pom.xml index 5d396599282..e5a97e472ba 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/pom.xml +++ b/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/pom.xml @@ -3,8 +3,9 @@ 4.0.0 org.eclipse.jetty.ee9 - jetty-ee9 + test-ee9-sessions 12.0.0-SNAPSHOT + ../pom.xml test-ee9-file-sessions Jetty EE9 Tests :: Sessions :: File @@ -29,6 +30,12 @@ jetty-session test + + org.eclipse.jetty + jetty-session + test-jar + test + org.eclipse.jetty.ee9 jetty-ee9-webapp diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java index 37283cd3947..41879296ad2 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-file-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java @@ -17,9 +17,11 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; +import org.eclipse.jetty.ee9.session.AbstractClusteredOrphanedSessionTest; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -28,6 +30,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * ClusteredOrphanedSessionTest */ +//TODO +@Disabled @ExtendWith(WorkDirExtension.class) public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/pom.xml b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/pom.xml index ee2c45c7d65..9fd7fc29a0f 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/pom.xml +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/pom.xml @@ -5,6 +5,7 @@ org.eclipse.jetty.ee9 test-ee9-sessions 12.0.0-SNAPSHOT + ../pom.xml test-ee9-jdbc-sessions Jetty EE9 Tests :: Sessions :: JDBC @@ -38,6 +39,17 @@ jetty-server test + + org.eclipse.jetty + jetty-session + test + + + org.eclipse.jetty + jetty-session + test-jar + test + org.eclipse.jetty.ee9 jetty-ee9-webapp diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredInvalidationSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredInvalidationSessionTest.java index 9b5f499359d..80651c57cb8 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredInvalidationSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredInvalidationSessionTest.java @@ -13,12 +13,16 @@ package org.eclipse.jetty.session; +import org.eclipse.jetty.ee9.session.AbstractClusteredInvalidationSessionTest; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredInvalidationSessionTest */ +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class ClusteredInvalidationSessionTest extends AbstractClusteredInvalidationSessionTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java index bef51c50681..c13bbec83fa 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredOrphanedSessionTest.java @@ -13,12 +13,16 @@ package org.eclipse.jetty.session; +import org.eclipse.jetty.ee9.session.AbstractClusteredOrphanedSessionTest; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredOrphanedSessionTest */ +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java index fd91580d637..bcb05e6586c 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionMigrationTest.java @@ -23,7 +23,10 @@ import jakarta.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.ee9.session.AbstractSessionTestBase; +import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.http.HttpField; +import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Testcontainers; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionScavengingTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionScavengingTest.java index 23b4afd031c..4f797e9461a 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionScavengingTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ClusteredSessionScavengingTest.java @@ -13,12 +13,16 @@ package org.eclipse.jetty.session; +import org.eclipse.jetty.ee9.session.AbstractClusteredSessionScavengingTest; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredSessionScavengingTest */ +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JDBCSessionDataStoreTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JDBCSessionDataStoreTest.java index 4a9b3372d8f..36a2a488e2b 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JDBCSessionDataStoreTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JDBCSessionDataStoreTest.java @@ -13,6 +13,7 @@ package org.eclipse.jetty.session; +import org.eclipse.jetty.session.AbstractSessionDataStoreTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,7 +31,7 @@ public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest } @BeforeEach - public void setUp() throws Exception + public void configure() throws Exception { JdbcTestHelper.prepareTables(); } diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java index 6bffbc7ec5c..99824892355 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java @@ -26,6 +26,8 @@ import java.sql.SQLException; import java.util.HashSet; import java.util.Set; +import org.eclipse.jetty.session.SessionData; +import org.eclipse.jetty.session.SessionDataStoreFactory; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java index 6ec689c5573..1dfa78a32a7 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/ReloadedSessionMissingClassTest.java @@ -22,6 +22,7 @@ import jakarta.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.ee9.webapp.WebAppContext; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -29,6 +30,7 @@ import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension; import org.eclipse.jetty.util.resource.Resource; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.testcontainers.junit.jupiter.Testcontainers; @@ -38,9 +40,12 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; + /** * ReloadedSessionMissingClassTest */ +//TODO +@Disabled @ExtendWith(WorkDirExtension.class) @Testcontainers(disabledWithoutDocker = true) public class ReloadedSessionMissingClassTest diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/SessionTableSchemaTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/SessionTableSchemaTest.java index 3c1f1afc08b..950daf64240 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/SessionTableSchemaTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/SessionTableSchemaTest.java @@ -18,7 +18,8 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.ee9.servlet.ServletContextHandler; +import org.eclipse.jetty.server.Server; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -120,9 +121,10 @@ public class SessionTableSchemaTest try (Connection con = _da.getConnection()) { //make a root context - ContextHandler handler = new ContextHandler(); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + handler.getSessionHandler().getSessionManager().setSessionIdManager(new DefaultSessionIdManager(new Server())); handler.setContextPath("/"); - SessionContext sc = new SessionContext("0", handler.getServletContext()); + SessionContext sc = new SessionContext(handler.getSessionHandler().getSessionManager()); //test the load statement PreparedStatement s = _tableSchema.getLoadStatement(con, id, sc); ResultSet rs = s.executeQuery(); @@ -146,9 +148,10 @@ public class SessionTableSchemaTest //test if it can be seen try (Connection con = _da.getConnection()) { - ContextHandler handler = new ContextHandler(); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + handler.getSessionHandler().getSessionManager().setSessionIdManager(new DefaultSessionIdManager(new Server())); handler.setContextPath("/"); - SessionContext sc = new SessionContext("0", handler.getServletContext()); + SessionContext sc = new SessionContext(handler.getSessionHandler().getSessionManager()); PreparedStatement s = _tableSchema.getCheckSessionExistsStatement(con, sc); s.setString(1, id); ResultSet rs = s.executeQuery(); @@ -172,9 +175,10 @@ public class SessionTableSchemaTest //test if it can be deleted try (Connection con = _da.getConnection()) { - ContextHandler handler = new ContextHandler(); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + handler.getSessionHandler().getSessionManager().setSessionIdManager(new DefaultSessionIdManager(new Server())); handler.setContextPath("/"); - SessionContext sc = new SessionContext("0", handler.getServletContext()); + SessionContext sc = new SessionContext(handler.getSessionHandler().getSessionManager()); PreparedStatement s = _tableSchema.getDeleteStatement(con, id, sc); assertEquals(1, s.executeUpdate()); @@ -197,9 +201,10 @@ public class SessionTableSchemaTest try (Connection con = _da.getConnection()) { - ContextHandler handler = new ContextHandler(); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + handler.getSessionHandler().getSessionManager().setSessionIdManager(new DefaultSessionIdManager(new Server())); handler.setContextPath("/"); - SessionContext sc = new SessionContext("0", handler.getServletContext()); + SessionContext sc = new SessionContext(handler.getSessionHandler().getSessionManager()); PreparedStatement s = _tableSchema.getExpiredSessionsStatement(con, sc.getCanonicalContextPath(), sc.getVhost(), @@ -225,9 +230,12 @@ public class SessionTableSchemaTest try (Connection con = _da.getConnection()) { - ContextHandler handler = new ContextHandler(); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + DefaultSessionIdManager idMgr = new DefaultSessionIdManager(new Server()); + idMgr.setWorkerName("0"); + handler.getSessionHandler().getSessionManager().setSessionIdManager(idMgr); handler.setContextPath("/"); - SessionContext sc = new SessionContext("0", handler.getServletContext()); + SessionContext sc = new SessionContext(handler.getSessionHandler().getSessionManager()); PreparedStatement s = _tableSchema.getMyExpiredSessionsStatement(con, sc, (System.currentTimeMillis() + 100L)); @@ -252,9 +260,10 @@ public class SessionTableSchemaTest try (Connection con = _da.getConnection()) { - ContextHandler handler = new ContextHandler(); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + handler.getSessionHandler().getSessionManager().setSessionIdManager(new DefaultSessionIdManager(new Server())); handler.setContextPath("/"); - SessionContext sc = new SessionContext("0", handler.getServletContext()); + SessionContext sc = new SessionContext(handler.getSessionHandler().getSessionManager()); PreparedStatement s = _tableSchema.getUpdateStatement(con, id, sc); diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/WebAppObjectInSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/WebAppObjectInSessionTest.java index 423764958b7..72ac5dd7c99 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/WebAppObjectInSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-jdbc-sessions/src/test/java/org/eclipse/jetty/session/WebAppObjectInSessionTest.java @@ -13,14 +13,18 @@ package org.eclipse.jetty.session; +import org.eclipse.jetty.ee9.session.AbstractWebAppObjectInSessionTest; import org.eclipse.jetty.util.resource.Resource; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Testcontainers; /** * WebAppObjectInSessionTest */ +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/pom.xml b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/pom.xml index 334daad4750..e23b423c4a8 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/pom.xml +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/pom.xml @@ -66,6 +66,12 @@ jetty-session test + + org.eclipse.jetty + jetty-session + test-jar + test + org.eclipse.jetty.ee9 jetty-ee9-webapp diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java index 0c7a4bbd1a7..45dba13371c 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/AttributeNameTest.java @@ -20,15 +20,16 @@ import java.util.concurrent.TimeUnit; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.ee9.session.SessionTestSupport; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.session.DefaultSessionCacheFactory; import org.eclipse.jetty.session.Session; import org.eclipse.jetty.session.SessionCache; -import org.eclipse.jetty.session.SessionTestSupport; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -136,20 +137,20 @@ public class AttributeNameTest String action = request.getParameter("action"); if ("init".equals(action)) { - Session session = (Session)request.getSession(true); + HttpSession session = request.getSession(true); session.setAttribute("a.b.c", TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); sendResult(session, httpServletResponse.getWriter()); } else { - Session session = (Session)request.getSession(false); + HttpSession session = request.getSession(false); assertNotNull(session); assertNotNull(session.getAttribute("a.b.c")); sendResult(session, httpServletResponse.getWriter()); } } - private void sendResult(Session session, PrintWriter writer) + private void sendResult(HttpSession session, PrintWriter writer) { if (session != null) { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredInvalidateSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredInvalidateSessionTest.java index a3b1ca267d6..dbb0302cc8f 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredInvalidateSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredInvalidateSessionTest.java @@ -13,12 +13,15 @@ package org.eclipse.jetty.nosql.mongodb; -import org.eclipse.jetty.session.AbstractClusteredInvalidationSessionTest; +import org.eclipse.jetty.ee9.session.AbstractClusteredInvalidationSessionTest; import org.eclipse.jetty.session.SessionDataStoreFactory; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.testcontainers.junit.jupiter.Testcontainers; +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class ClusteredInvalidateSessionTest extends AbstractClusteredInvalidationSessionTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredOrphanedSessionTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredOrphanedSessionTest.java index a36d4a22572..9a651bc2cba 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredOrphanedSessionTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredOrphanedSessionTest.java @@ -13,16 +13,19 @@ package org.eclipse.jetty.nosql.mongodb; -import org.eclipse.jetty.session.AbstractClusteredOrphanedSessionTest; +import org.eclipse.jetty.ee9.session.AbstractClusteredOrphanedSessionTest; import org.eclipse.jetty.session.SessionDataStoreFactory; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredOrphanedSessionTest */ +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredSessionScavengingTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredSessionScavengingTest.java index bd7e2392d48..f6a3e0a5acf 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredSessionScavengingTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/ClusteredSessionScavengingTest.java @@ -13,12 +13,15 @@ package org.eclipse.jetty.nosql.mongodb; -import org.eclipse.jetty.session.AbstractClusteredSessionScavengingTest; +import org.eclipse.jetty.ee9.session.AbstractClusteredSessionScavengingTest; import org.eclipse.jetty.session.SessionDataStoreFactory; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.testcontainers.junit.jupiter.Testcontainers; +//TODO +@Disabled @Testcontainers(disabledWithoutDocker = true) public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest { diff --git a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStoreTest.java b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStoreTest.java index 532782f7624..46e27d5a239 100644 --- a/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStoreTest.java +++ b/jetty-ee9/test-ee9-sessions/test-ee9-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStoreTest.java @@ -19,8 +19,10 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.jetty.ee9.servlet.ServletContextHandler; +import org.eclipse.jetty.server.Server; import org.eclipse.jetty.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.session.AbstractSessionDataStoreTest; +import org.eclipse.jetty.session.DefaultSessionIdManager; import org.eclipse.jetty.session.SessionContext; import org.eclipse.jetty.session.SessionData; import org.eclipse.jetty.session.SessionDataStore; @@ -111,13 +113,16 @@ public class MongoSessionDataStoreTest extends AbstractSessionDataStoreTest @Test public void testReadLegacySession() throws Exception { + DefaultSessionIdManager idMgr = new DefaultSessionIdManager(new Server()); + //create the SessionDataStore ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/legacy"); + context.getSessionHandler().getSessionManager().setSessionIdManager(idMgr); SessionDataStoreFactory factory = createSessionDataStoreFactory(); ((AbstractSessionDataStoreFactory)factory).setGracePeriodSec(GRACE_PERIOD_SEC); - SessionDataStore store = factory.getSessionDataStore(context.getSessionHandler()); - SessionContext sessionContext = new SessionContext("foo", context.getServletContext()); + SessionDataStore store = factory.getSessionDataStore(context.getSessionHandler().getSessionManager()); + SessionContext sessionContext = new SessionContext(context.getSessionHandler().getSessionManager()); store.initialize(sessionContext); //persist an old-style session