Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2015-11-04 02:15:43 -0500
committerJan Bartel2015-11-04 02:15:43 -0500
commitd5649e1d1b5e1a827b86a4635e980ebdbcd8889a (patch)
tree551067d3e9382a2f3d4aafbe08d1baf338efed6c
parent06f3486b8dc9e8c5d5537d90ff63e8110ca093a5 (diff)
downloadorg.eclipse.jetty.project-d5649e1d1b5e1a827b86a4635e980ebdbcd8889a.tar.gz
org.eclipse.jetty.project-d5649e1d1b5e1a827b86a4635e980ebdbcd8889a.tar.xz
org.eclipse.jetty.project-d5649e1d1b5e1a827b86a4635e980ebdbcd8889a.zip
481075 Session statistics are not accurate
-rw-r--r--jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java2
-rw-r--r--jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java4
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java3
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java4
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java2
-rw-r--r--tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java16
-rw-r--r--tests/test-sessions/test-jdbc-sessions/pom.xml4
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java13
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java9
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java7
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/InvalidationSessionTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java24
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LocalSessionScavengingTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ModifyMaxInactiveIntervalTest.java8
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java8
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java13
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java8
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SaveIntervalTest.java7
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionExpiryTest.java15
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java9
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionMigrationTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java14
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSavingTest.java30
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/StopSessionManagerPreserveSessionTest.java14
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java13
-rw-r--r--tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java6
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java30
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java35
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java19
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSameNodeLoadTest.java2
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java6
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java4
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java10
40 files changed, 228 insertions, 216 deletions
diff --git a/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java b/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java
index b6b39a9bba..a6137e47ea 100644
--- a/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java
+++ b/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java
@@ -829,6 +829,7 @@ public class GCloudSessionManager extends AbstractSessionManager
if (memSession == null)
{
memSession = session;
+ _sessionsStats.increment();
}
//final check
@@ -1008,6 +1009,7 @@ public class GCloudSessionManager extends AbstractSessionManager
{
//indicate that the session was reinflated
session.didActivate();
+ _sessionsStats.increment();
LOG.debug("getSession({}): loaded session from cluster", idInCluster);
}
return session;
diff --git a/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java b/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java
index 039263a46c..072d0f1a77 100644
--- a/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java
+++ b/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java
@@ -664,7 +664,7 @@ public class InfinispanSessionManager extends AbstractSessionManager
for (String candidateId:candidateIds)
{
if (LOG.isDebugEnabled())
- LOG.debug("Session {} expired ", candidateId);
+ LOG.debug("Session {} candidate for expiry", candidateId);
Session candidateSession = _sessions.get(candidateId);
if (candidateSession != null)
@@ -691,6 +691,7 @@ public class InfinispanSessionManager extends AbstractSessionManager
if (LOG.isDebugEnabled()) LOG.debug("Session({}) not local to this session manager, removing from local memory", candidateId);
candidateSession.willPassivate();
_sessions.remove(candidateSession.getClusterId());
+ _sessionsStats.decrement();
}
}
@@ -870,6 +871,7 @@ public class InfinispanSessionManager extends AbstractSessionManager
{
//indicate that the session was reinflated
session.didActivate();
+ _sessionsStats.increment();
LOG.debug("getSession({}): loaded session from cluster", idInCluster);
}
return session;
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java
index 7d5e9dca58..51b8d60912 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java
@@ -96,7 +96,10 @@ public abstract class NoSqlSessionManager extends AbstractSessionManager impleme
session=race;
}
else
+ {
__log.debug("session loaded ", idInCluster);
+ _sessionsStats.increment();
+ }
//check if the session we just loaded has actually expired, maybe while we weren't running
if (getMaxInactiveInterval() > 0 && session.getAccessed() > 0 && ((getMaxInactiveInterval()*1000L)+session.getAccessed()) < System.currentTimeMillis())
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
index d822ea7926..894a3fda10 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
@@ -206,7 +206,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
protected void scavenge()
{
long now = System.currentTimeMillis();
- __log.debug("SessionIdManager:scavenge:at {}", now);
+ __log.debug(getWorkerName()+":SessionIdManager:scavenge:at {}", now);
/*
* run a query returning results that:
* - are in the known list of sessionIds
@@ -258,7 +258,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
for ( DBObject session : checkSessions )
{
- __log.debug("SessionIdManager:scavenge: expiring session {}", (String)session.get(MongoSessionManager.__ID));
+ __log.debug(getWorkerName()+":SessionIdManager:scavenge: {} expiring session {}", atTime,(String)session.get(MongoSessionManager.__ID));
expireAll((String)session.get(MongoSessionManager.__ID));
}
}
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
index df8f917188..8c44e9fa47 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
@@ -268,7 +268,9 @@ public class MongoSessionManager extends NoSqlSessionManager
if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle)
sets.put(__MAX_IDLE, getMaxInactiveInterval());
if (currentExpiry != null && expiry > 0 && expiry != currentExpiry)
+ {
sets.put(__EXPIRY, expiry);
+ }
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java
index 7b86fbb95d..6962694507 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java
@@ -535,6 +535,7 @@ public class JDBCSessionManager extends AbstractSessionManager
session.setLastNode(getSessionIdManager().getWorkerName());
_sessions.put(idInCluster, session);
+ _sessionsStats.increment();
//update in db
try
@@ -843,6 +844,7 @@ public class JDBCSessionManager extends AbstractSessionManager
//loaded an expired session last managed on this node for this context, add it to the list so we can
//treat it like a normal expired session
_sessions.put(session.getClusterId(), session);
+ _sessionsStats.increment();
}
else
{
diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java
index 25c0ad2308..bb09b64333 100644
--- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java
+++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java
@@ -18,14 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.io.File;
-
-import org.eclipse.jetty.util.IO;
-import org.infinispan.Cache;
-import org.infinispan.configuration.cache.Configuration;
-import org.infinispan.configuration.cache.ConfigurationBuilder;
-import org.infinispan.manager.DefaultCacheManager;
-import org.infinispan.manager.EmbeddedCacheManager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -61,5 +53,13 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
super.testLastAccessTime();
}
+ @Override
+ public void assertAfterScavenge(AbstractSessionManager manager)
+ {
+ //The infinispan session manager will remove a session from its local memory that was a candidate to be scavenged if
+ //it checks with the cluster and discovers that another node is managing it, so the count is 0
+ assertSessionCounts(0, 1, 1, manager);
+ }
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml
index 9d4a1b8a15..b4a75a545a 100644
--- a/tests/test-sessions/test-jdbc-sessions/pom.xml
+++ b/tests/test-sessions/test-jdbc-sessions/pom.xml
@@ -65,13 +65,13 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
- <version>10.4.1.3</version>
+ <version>10.12.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
- <version>10.4.1.3</version>
+ <version>10.12.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
index eb4109b1f8..a5348ef81f 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -46,12 +43,8 @@ public class ClientCrossContextSessionTest extends AbstractClientCrossContextSes
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
+
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java
index 5d2379ab6c..e123a80b2d 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java
@@ -38,6 +38,7 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.junit.After;
import org.junit.Test;
@@ -127,6 +128,14 @@ public class DirtyAttributeTest
}
}
+
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
+
+
public static class TestValue implements HttpSessionActivationListener, HttpSessionBindingListener, Serializable
{
int passivates = 0;
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java
index 7d2f42b976..de843b8608 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.server.session;
+import org.junit.After;
import org.junit.Test;
/**
@@ -45,6 +46,12 @@ public class ForwardedSessionTest extends AbstractForwardedSessionTest
}
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
index cabd7248e0..fd4b53e796 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -46,12 +43,7 @@ public class ImmortalSessionTest extends AbstractImmortalSessionTest
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/InvalidationSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/InvalidationSessionTest.java
index 8075dbdfec..dd68fff5b5 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/InvalidationSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/InvalidationSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -60,12 +57,6 @@ public class InvalidationSessionTest extends AbstractInvalidationSessionTest
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java
index 5b55861707..03e9ff1d06 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java
@@ -22,6 +22,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
@@ -35,7 +36,8 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
public class JdbcTestServer extends AbstractTestServer
{
public static final String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver";
- public static final String DEFAULT_CONNECTION_URL = "jdbc:derby:sessions;create=true";
+ public static final String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true";
+ public static final String DEFAULT_SHUTDOWN_URL = "jdbc:derby:memory:sessions;drop=true";
public static final int SAVE_INTERVAL = 1;
@@ -43,6 +45,26 @@ public class JdbcTestServer extends AbstractTestServer
{
System.setProperty("derby.system.home", MavenTestingUtils.getTargetFile("test-derby").getAbsolutePath());
}
+
+
+ public static void shutdown (String connectionUrl)
+ throws Exception
+ {
+ if (connectionUrl == null)
+ connectionUrl = DEFAULT_SHUTDOWN_URL;
+
+ try
+ {
+ DriverManager.getConnection(connectionUrl);
+ }
+ catch( SQLException expected )
+ {
+ if (!"08006".equals(expected.getSQLState()))
+ {
+ throw expected;
+ }
+ }
+ }
public JdbcTestServer(int port)
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java
index 541c1ef41c..6939fb4683 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -37,20 +34,13 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
@Test
public void testLastAccessTime() throws Exception
{
- // Log.getLog().setDebugEnabled(true);
super.testLastAccessTime();
}
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LocalSessionScavengingTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LocalSessionScavengingTest.java
index 87eec2c6dd..ac89427445 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LocalSessionScavengingTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LocalSessionScavengingTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -56,16 +53,11 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
{
super.testLocalSessionsScavenging();
}
+
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java
index 6256945aed..b32500aa77 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java
@@ -23,8 +23,6 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.PrintWriter;
-import java.sql.DriverManager;
-import java.sql.SQLException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -81,13 +79,8 @@ public class MaxInactiveMigrationTest
testServer1.stop();
testServer2.stop();
client.stop();
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+
+ JdbcTestServer.shutdown(null);
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ModifyMaxInactiveIntervalTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ModifyMaxInactiveIntervalTest.java
index a39b655f73..d777a61ee3 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ModifyMaxInactiveIntervalTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ModifyMaxInactiveIntervalTest.java
@@ -33,6 +33,7 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.junit.After;
import org.junit.Test;
@@ -103,6 +104,13 @@ public class ModifyMaxInactiveIntervalTest
}
}
+
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
+
public static class TestModServlet extends HttpServlet
{
@Override
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java
index fc05235225..5a6006cdd1 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -46,12 +43,7 @@ public class NewSessionTest extends AbstractNewSessionTest
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java
index 391f3e0e49..4042f373fe 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -43,12 +40,6 @@ public class OrphanedSessionTest extends AbstractOrphanedSessionTest
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java
index 38db019ce5..6efffa406a 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java
@@ -20,6 +20,7 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.junit.After;
import org.junit.Test;
/**
@@ -55,4 +56,11 @@ public class ProxySerializationTest extends AbstractProxySerializationTest
super.testProxySerialization();
}
+
+
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
index dced30d8d2..82b3d5f6eb 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -42,15 +39,11 @@ public class ReentrantRequestSessionTest extends AbstractReentrantRequestSession
super.testReentrantRequestSession();
}
+
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java
index 4dbec1c397..44acb9d263 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java
@@ -38,6 +38,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StdErrLog;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -139,4 +140,11 @@ public class ReloadedSessionMissingClassTest
server1.stop();
}
}
+
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SaveIntervalTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SaveIntervalTest.java
index 3b02825a9a..e031b29543 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SaveIntervalTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SaveIntervalTest.java
@@ -35,6 +35,7 @@ import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
+import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
@@ -133,6 +134,12 @@ public class SaveIntervalTest
}
}
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
+
public static class TestSaveIntervalServlet extends HttpServlet
{
public HttpSession _session;
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java
index 83c69448d7..497881fc72 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -44,12 +41,6 @@ public class ServerCrossContextSessionTest extends AbstractServerCrossContextSes
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionExpiryTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionExpiryTest.java
index 5177b93987..581113df63 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionExpiryTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionExpiryTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -58,18 +55,10 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
super.testSessionNotExpired();
}
-
-
-
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java
index 746e0bd522..de88616878 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.server.session;
+import org.junit.After;
import org.junit.Test;
public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
@@ -35,4 +36,12 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
{
super.testSessionScavenge();
}
+
+
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionMigrationTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionMigrationTest.java
index 2ff6fa42bc..e8bbbf7509 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionMigrationTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionMigrationTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -44,12 +41,6 @@ public class SessionMigrationTest extends AbstractSessionMigrationTest
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
index 60416b6e8f..cfd4f15b1a 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -39,16 +36,11 @@ public class SessionRenewTest extends AbstractSessionRenewTest
super.testSessionRenewal();
}
+
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
-
+
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSavingTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSavingTest.java
index 41c25609f7..d647534943 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSavingTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSavingTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.junit.After;
import org.junit.Test;
@@ -34,21 +31,16 @@ public class SessionValueSavingTest extends AbstractSessionValueSavingTest
return new JdbcTestServer(port,max,scavenge);
}
- @Test
- public void testSessionValueSaving() throws Exception
- {
- super.testSessionValueSaving();
- }
+ @Test
+ public void testSessionValueSaving() throws Exception
+ {
+ super.testSessionValueSaving();
+ }
+
- @After
- public void tearDown() throws Exception
- {
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
- }
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestServer.shutdown(null);
+ }
}
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/StopSessionManagerPreserveSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/StopSessionManagerPreserveSessionTest.java
index 84b2ac32ad..1c43a75024 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/StopSessionManagerPreserveSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/StopSessionManagerPreserveSessionTest.java
@@ -21,9 +21,6 @@ package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.After;
import org.junit.Test;
@@ -31,17 +28,12 @@ import org.junit.Test;
public class StopSessionManagerPreserveSessionTest extends AbstractStopSessionManagerPreserveSessionTest
{
JdbcTestServer _server;
-
+
+
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
@Override
diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java
index 8a480903b2..88d7df119d 100644
--- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server.session;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
import org.eclipse.jetty.util.resource.Resource;
import org.junit.After;
import org.junit.Test;
@@ -45,17 +42,11 @@ public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest
super.testWebappObjectInSession();
}
-
@After
public void tearDown() throws Exception
{
- try
- {
- DriverManager.getConnection( "jdbc:derby:sessions;shutdown=true" );
- }
- catch( SQLException expected )
- {
- }
+ JdbcTestServer.shutdown(null);
}
+
}
diff --git a/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java b/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java
index e3c78c2222..0ada08a41d 100644
--- a/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java
+++ b/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java
@@ -39,6 +39,7 @@ public class MongoTestServer extends AbstractTestServer
{
static int __workers=0;
private boolean _saveAllAttributes = false; // false save dirty, true save all
+ private int _saveInterval = 0;
public static class TestMongoSessionIdManager extends MongoSessionIdManager
@@ -70,13 +71,13 @@ public class MongoTestServer extends AbstractTestServer
public MongoTestServer(int port, int maxInactivePeriod, int scavengePeriod)
{
super(port, maxInactivePeriod, scavengePeriod);
+ _saveInterval = 0;
}
public MongoTestServer(int port, int maxInactivePeriod, int scavengePeriod, boolean saveAllAttributes)
{
super(port, maxInactivePeriod, scavengePeriod);
-
_saveAllAttributes = saveAllAttributes;
}
@@ -109,10 +110,9 @@ public class MongoTestServer extends AbstractTestServer
throw new RuntimeException(e);
}
- manager.setSavePeriod(1);
+ manager.setSavePeriod(_saveInterval);
manager.setStalePeriod(0);
manager.setSaveAllAttributes(_saveAllAttributes);
- //manager.setScavengePeriod((int)TimeUnit.SECONDS.toMillis(_scavengePeriod));
return manager;
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java
index 8d2d660404..de345efba3 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java
@@ -32,6 +32,7 @@ import javax.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.servlet.ServletContextHandler;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.Test;
@@ -51,16 +52,20 @@ public abstract class AbstractInvalidationSessionTest
String contextPath = "";
String servletMapping = "/server";
AbstractTestServer server1 = createServer(0);
- server1.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
+ ServletContextHandler context1 = server1.addContext(contextPath);
+ context1.addServlet(TestServlet.class, servletMapping);
+ AbstractSessionManager m1 = (AbstractSessionManager) context1.getSessionHandler().getSessionManager();
try
{
server1.start();
int port1 = server1.getPort();
AbstractTestServer server2 = createServer(0);
- server2.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
-
+ ServletContextHandler context2 = server2.addContext(contextPath);
+ context2.addServlet(TestServlet.class, servletMapping);
+ AbstractSessionManager m2 = (AbstractSessionManager) context2.getSessionHandler().getSessionManager();
+
try
{
server2.start();
@@ -81,25 +86,33 @@ public abstract class AbstractInvalidationSessionTest
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
+ assertEquals(1, m1.getSessions());
+ assertEquals(1, m1.getSessionsMax());
+ assertEquals(1, m1.getSessionsTotal());
+
// Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
// Be sure the session is also present in node2
-
Request request2 = client.newRequest(urls[1] + "?action=increment");
request2.header("Cookie", sessionCookie);
ContentResponse response2 = request2.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
-
+ assertEquals(1, m2.getSessions());
+ assertEquals(1, m2.getSessionsMax());
+ assertEquals(1, m2.getSessionsTotal());
+
// Invalidate on node1
Request request1 = client.newRequest(urls[0] + "?action=invalidate");
request1.header("Cookie", sessionCookie);
response1 = request1.send();
assertEquals(HttpServletResponse.SC_OK, response1.getStatus());
-
-
+ assertEquals(0, m1.getSessions());
+ assertEquals(1, m1.getSessionsMax());
+ assertEquals(1, m1.getSessionsTotal());
+
pause();
// Be sure on node2 we don't see the session anymore
@@ -107,6 +120,9 @@ public abstract class AbstractInvalidationSessionTest
request2.header("Cookie", sessionCookie);
response2 = request2.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
+ assertEquals(0, m2.getSessions());
+ assertEquals(1, m2.getSessionsMax());
+ assertEquals(1, m2.getSessionsTotal());
}
finally
{
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java
index 787eb739f3..847e800dc8 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java
@@ -65,15 +65,19 @@ public abstract class AbstractLastAccessTimeTest
ServletHolder holder1 = new ServletHolder(servlet1);
ServletContextHandler context = server1.addContext(contextPath);
TestSessionListener listener1 = new TestSessionListener();
- context.addEventListener(listener1);
+ context.getSessionHandler().addEventListener(listener1);
context.addServlet(holder1, servletMapping);
+ AbstractSessionManager m1 = (AbstractSessionManager)context.getSessionHandler().getSessionManager();
+
try
{
server1.start();
int port1=server1.getPort();
AbstractTestServer server2 = createServer(0, maxInactivePeriod, scavengePeriod);
- server2.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
+ ServletContextHandler context2 = server2.addContext(contextPath);
+ context2.addServlet(TestServlet.class, servletMapping);
+ AbstractSessionManager m2 = (AbstractSessionManager)context2.getSessionHandler().getSessionManager();
try
{
@@ -89,9 +93,12 @@ public abstract class AbstractLastAccessTimeTest
assertEquals("test", response1.getContentAsString());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue( sessionCookie != null );
+ assertEquals(1, m1.getSessions());
+ assertEquals(1, m1.getSessionsMax());
+ assertEquals(1, m1.getSessionsTotal());
// Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
+ sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
+
// Perform some request to server2 using the session cookie from the previous request
// This should migrate the session from server1 to server2, and leave server1's
// session in a very stale state, while server2 has a very fresh session.
@@ -111,14 +118,15 @@ public abstract class AbstractLastAccessTimeTest
sessionCookie = setCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
Thread.sleep(requestInterval);
+ assertSessionCounts(1,1,1, m2);
}
-
// At this point, session1 should be eligible for expiration.
// Let's wait for the scavenger to run, waiting 2.5 times the scavenger period
Thread.sleep(scavengePeriod * 2500L);
//check that the session was not scavenged over on server1 by ensuring that the SessionListener destroy method wasn't called
assertFalse(listener1.destroyed);
+ assertAfterScavenge(m1);
}
finally
{
@@ -135,6 +143,23 @@ public abstract class AbstractLastAccessTimeTest
server1.stop();
}
}
+
+ public void assertAfterSessionCreated (AbstractSessionManager m)
+ {
+ assertSessionCounts(1, 1, 1, m);
+ }
+
+ public void assertAfterScavenge (AbstractSessionManager manager)
+ {
+ assertSessionCounts(1,1,1, manager);
+ }
+
+ public void assertSessionCounts (int current, int max, int total, AbstractSessionManager manager)
+ {
+ assertEquals(current, manager.getSessions());
+ assertEquals(max, manager.getSessionsMax());
+ assertEquals(total, manager.getSessionsTotal());
+ }
public static class TestSessionListener implements HttpSessionListener
{
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java
index c344d72530..bb126f68db 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java
@@ -39,6 +39,12 @@ import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.Test;
+/**
+ * AbstractRemoveSessionTest
+ *
+ * Test that invalidating a session does not return the session on the next request.
+ *
+ */
public abstract class AbstractRemoveSessionTest
{
public abstract AbstractTestServer createServer(int port, int max, int scavenge);
@@ -55,6 +61,7 @@ public abstract class AbstractRemoveSessionTest
context.addServlet(TestServlet.class, servletMapping);
TestEventListener testListener = new TestEventListener();
context.getSessionHandler().addEventListener(testListener);
+ AbstractSessionManager m = (AbstractSessionManager)context.getSessionHandler().getSessionManager();
try
{
server.start();
@@ -72,7 +79,10 @@ public abstract class AbstractRemoveSessionTest
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//ensure sessionCreated listener is called
assertTrue (testListener.isCreated());
-
+ assertEquals(1, m.getSessions());
+ assertEquals(1, m.getSessionsMax());
+ assertEquals(1, m.getSessionsTotal());
+
//now delete the session
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=delete");
request.header("Cookie", sessionCookie);
@@ -80,13 +90,18 @@ public abstract class AbstractRemoveSessionTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//ensure sessionDestroyed listener is called
assertTrue(testListener.isDestroyed());
-
+ assertEquals(0, m.getSessions());
+ assertEquals(1, m.getSessionsMax());
+ assertEquals(1, m.getSessionsTotal());
// The session is not there anymore, even if we present an old cookie
request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=check");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
+ assertEquals(0, m.getSessions());
+ assertEquals(1, m.getSessionsMax());
+ assertEquals(1, m.getSessionsTotal());
}
finally
{
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSameNodeLoadTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSameNodeLoadTest.java
index 999858fb5b..28e6cbdc1e 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSameNodeLoadTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSameNodeLoadTest.java
@@ -19,8 +19,8 @@
package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.PrintWriter;
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java
index 30a080a732..ed7737f359 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
-import java.util.Collections;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
@@ -87,10 +86,9 @@ public abstract class AbstractServerCrossContextSessionTest
{
HttpSession session = request.getSession(false);
if (session == null) session = request.getSession(true);
-
// Add something to the session
session.setAttribute("A", "A");
- System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
+
// Perform cross context dispatch to another context
// Over there we will check that the session attribute added above is not visible
@@ -101,7 +99,6 @@ public abstract class AbstractServerCrossContextSessionTest
// Check that we don't see things put in session by contextB
Object objectB = session.getAttribute("B");
assertTrue(objectB == null);
- System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
}
}
@@ -119,7 +116,6 @@ public abstract class AbstractServerCrossContextSessionTest
// Add something, so in contextA we can check if it is visible (it must not).
session.setAttribute("B", "B");
- System.out.println("B: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
}
}
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java
index b79a0a33ac..a867711ce4 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java
@@ -29,8 +29,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import junit.framework.Assert;
-
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
@@ -38,6 +36,8 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.Ignore;
import org.junit.Test;
+import junit.framework.Assert;
+
/**
* AbstractSessionCookieTest
*/
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
index 5c11f8b35c..0c221a2860 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
@@ -40,6 +40,11 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.Test;
+/**
+ * AbstractSessionExpiryTest
+ *
+ *
+ */
public abstract class AbstractSessionExpiryTest
{
public abstract AbstractTestServer createServer(int port, int max, int scavenge);
@@ -104,6 +109,7 @@ public abstract class AbstractSessionExpiryTest
//now stop the server
server1.stop();
+
//start the server again, before the session times out
server1.start();
@@ -161,12 +167,12 @@ public abstract class AbstractSessionExpiryTest
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
String sessionId = AbstractTestServer.extractSessionId(sessionCookie);
-
+
verifySessionCreated(listener,sessionId);
//now stop the server
server1.stop();
-
+
//and wait until the expiry time has passed
pause(inactivePeriod);

Back to the top