Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2015-10-23 01:52:05 -0400
committerJan Bartel2015-10-23 01:52:05 -0400
commit84239bc7f2e13afeb80bb50445f499d918511eb3 (patch)
treec720abc19fc8830e1cf299d18ec98e8fafa85cde
parentc5489bd7b2d071b0e7b95cf327c604b3a3cb6015 (diff)
downloadorg.eclipse.jetty.project-84239bc7f2e13afeb80bb50445f499d918511eb3.tar.gz
org.eclipse.jetty.project-84239bc7f2e13afeb80bb50445f499d918511eb3.tar.xz
org.eclipse.jetty.project-84239bc7f2e13afeb80bb50445f499d918511eb3.zip
Start making unit tests work.
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionStore.java11
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java7
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionManager.java57
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java14
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/MemorySessionStore.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionKey.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionManager.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionScavenger.java12
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/session/FileSessionManagerTest.java (renamed from jetty-server/src/test/java/org/eclipse/jetty/server/session/HashSessionManagerTest.java)97
-rw-r--r--tests/test-sessions/pom.xml1
-rw-r--r--tests/test-sessions/test-file-sessions/.gitignore1
-rw-r--r--tests/test-sessions/test-file-sessions/pom.xml72
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java54
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/FileTestServer.java84
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java (renamed from tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java)34
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java45
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java53
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java52
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java (renamed from tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java)49
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java54
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java52
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ScatterGunLoadTest.java55
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java51
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionCookieTest.java48
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java51
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java58
-rw-r--r--tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSharedSaving.java46
-rw-r--r--tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java19
-rw-r--r--tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java8
-rw-r--r--tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java24
-rw-r--r--tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java38
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java2
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java6
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java5
35 files changed, 1007 insertions, 158 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java
index c8ed6debc1..5692e7d447 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java
@@ -243,6 +243,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
}
_scavenger.start();
+ System.err.println("Started scavenger "+_scavenger);
}
/* ------------------------------------------------------------ */
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionStore.java
index 0a3ad38e15..a04656a6f2 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionStore.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionStore.java
@@ -130,14 +130,17 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
{
//look locally
Session session = doGet(key);
-
+
//not in session store, load the data for the session if possible
if (session == null && _sessionDataStore != null)
{
SessionData data = _sessionDataStore.load(key);
- session = newSession(data);
- session.setSessionManager(_manager);
- doPut(key, session);
+ if (data != null)
+ {
+ session = newSession(data);
+ session.setSessionManager(_manager);
+ doPut(key, session);
+ }
}
return session;
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java
index 01e17250c0..d304ab1860 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java
@@ -105,7 +105,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore
if (_storeDir != null)
{
file = new File(_storeDir, key.toString());
- if (file.exists())
+ if (file.exists() && file.getParentFile().equals(_storeDir))
{
file.delete();
return true;
@@ -150,13 +150,12 @@ public class FileSessionDataStore extends AbstractSessionDataStore
}
catch (UnreadableSessionDataException e)
{
- if (isDeleteUnrestorableFiles() && file.exists())
+ if (isDeleteUnrestorableFiles() && file.exists() && file.getParentFile().equals(_storeDir));
{
file.delete();
LOG.warn("Deleted unrestorable file for session {}", key);
- return null;
}
- return null;
+ throw e;
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionManager.java
new file mode 100644
index 0000000000..f107957f5f
--- /dev/null
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionManager.java
@@ -0,0 +1,57 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+
+package org.eclipse.jetty.server.session;
+
+/**
+ * FileHashSessionManager
+ *
+ * Session manager that stores its sessions in files on disk
+ *
+ */
+public class FileSessionManager extends SessionManager
+{
+ protected FileSessionDataStore _sessionDataStore = new FileSessionDataStore();
+
+
+ @Override
+ public void doStart() throws Exception
+ {
+ _sessionStore = new MemorySessionStore();
+ ((AbstractSessionStore)_sessionStore).setSessionDataStore(_sessionDataStore);
+
+ super.doStart();
+ }
+
+ @Override
+ public void doStop() throws Exception
+ {
+ super.doStop();
+ }
+
+ /**
+ * Get the SessionDataStore to configure it
+ * @return
+ */
+ public FileSessionDataStore getSessionDataStore()
+ {
+ return _sessionDataStore;
+ }
+
+}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java
index 591dc333ca..62a6c83cfd 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java
@@ -22,11 +22,12 @@ package org.eclipse.jetty.server.session;
/**
* HashSessionManager
*
- *
+ * In memory-only session manager.
+ *
*/
public class HashSessionManager extends SessionManager
{
- protected FileSessionDataStore _sessionDataStore = new FileSessionDataStore();
+ protected NullSessionDataStore _sessionDataStore = new NullSessionDataStore();
@Override
@@ -44,13 +45,4 @@ public class HashSessionManager extends SessionManager
super.doStop();
}
- /**
- * Get the SessionDataStore to configure it
- * @return
- */
- public FileSessionDataStore getSessionDataStore()
- {
- return _sessionDataStore;
- }
-
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/MemorySessionStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/MemorySessionStore.java
index cb5bb2dc5c..b696a6c254 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/MemorySessionStore.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/MemorySessionStore.java
@@ -199,6 +199,7 @@ public class MemorySessionStore extends AbstractSessionStore
@Override
public Session newSession(SessionKey key, long created, long accessed, long lastAccessed, long maxInactiveMs)
{
+ //TODO - how to tell that the session is new?!
return new MemorySession(_sessionDataStore.newSessionData(key, created, accessed, lastAccessed, maxInactiveMs));
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionKey.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionKey.java
index 804ebf2237..72415631c7 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionKey.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionKey.java
@@ -83,6 +83,8 @@ public class SessionKey
public static String getContextPath (Context context)
{
+ if (context == null)
+ return "";
return canonicalize (context.getContextPath());
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionManager.java
index ba8c87a13c..eaa5f2ba0f 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionManager.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionManager.java
@@ -621,6 +621,7 @@ public class SessionManager extends ContainerLifeCycle implements org.eclipse.je
Session session = _sessionStore.newSession(key, created, created, created, (_dftMaxIdleSecs>0?_dftMaxIdleSecs*1000L:-1));
session.setExtendedId(_sessionIdManager.getExtendedId(id,request));
session.setSessionManager(this);
+ session.setLastNode(_sessionIdManager.getWorkerName());
if (request.isSecure())
session.setAttribute(Session.SESSION_CREATED_SECURE, Boolean.TRUE);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionScavenger.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionScavenger.java
index a58a59278b..e7ac0ffa83 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionScavenger.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionScavenger.java
@@ -167,6 +167,9 @@ public class SessionScavenger extends AbstractLifeCycle
if (isStopping() || isStopped())
return;
+ if (LOG.isDebugEnabled())
+ LOG.debug("Scavenging sessions");
+
//find the session managers
Handler[] contexts = ((AbstractSessionIdManager)_sessionIdManager).getServer().getChildHandlersByClass(ContextHandler.class);
for (int i=0; contexts!=null && i<contexts.length; i++)
@@ -199,4 +202,13 @@ public class SessionScavenger extends AbstractLifeCycle
}
+
+ @Override
+ public String toString()
+ {
+ return super.toString()+"[interval="+_scavengeIntervalMs+", ownscheduler="+_ownScheduler+"]";
+ }
+
+
+
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/session/HashSessionManagerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/session/FileSessionManagerTest.java
index 9e2fd3ebff..a3aa1f5044 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/session/HashSessionManagerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/session/FileSessionManagerTest.java
@@ -25,62 +25,110 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.StdErrLog;
+import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
-public class HashSessionManagerTest
+public class FileSessionManagerTest
{
+ private static StdErrLog _log;
+ private static boolean _stacks;
+
+
+ // @BeforeClass
+ public static void beforeClass ()
+ {
+ _log = ((StdErrLog)Log.getLogger("org.eclipse.jetty.server.session"));
+ _stacks = _log.isHideStacks();
+ _log.setHideStacks(true);
+ }
+
+ //@AfterClass
+ public static void afterClass()
+ {
+ _log.setHideStacks(_stacks);
+ }
+
+
+
@Test
public void testDangerousSessionIdRemoval() throws Exception
{
- final HashSessionManager manager = new HashSessionManager();
+ Server server = new Server();
+ SessionHandler handler = new SessionHandler();
+ handler.setServer(server);
+ final HashSessionIdManager idmgr = new HashSessionIdManager();
+ idmgr.setServer(server);
+ server.setSessionIdManager(idmgr);
+
+ final FileSessionManager manager = new FileSessionManager();
manager.getSessionDataStore().setDeleteUnrestorableFiles(true);
//manager.setLazyLoad(true);
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
testDir.mkdirs();
manager.getSessionDataStore().setStoreDir(testDir);
-
- MavenTestingUtils.getTargetFile("dangerFile.session").createNewFile();
+ manager.setSessionIdManager(idmgr);
+ handler.setSessionManager(manager);
+ manager.start();
+
+ String expectedFilename = "../../_0.0.0.0_dangerFile";
+
+ MavenTestingUtils.getTargetFile(expectedFilename).createNewFile();
- Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile("dangerFile.session").exists());
+ Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile(expectedFilename).exists());
- manager.getSession("../../dangerFile.session");
+ manager.getSession("../../_0.0.0.0_dangerFile");
- Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile("dangerFile.session").exists());
+ Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile(expectedFilename).exists());
}
-
- @Test
+
+ @Test
public void testValidSessionIdRemoval() throws Exception
- {
- final HashSessionManager manager = new HashSessionManager();
+ {
+ Server server = new Server();
+ SessionHandler handler = new SessionHandler();
+ handler.setServer(server);
+ final HashSessionIdManager idmgr = new HashSessionIdManager();
+ idmgr.setServer(server);
+ server.setSessionIdManager(idmgr);
+ final FileSessionManager manager = new FileSessionManager();
manager.getSessionDataStore().setDeleteUnrestorableFiles(true);
- // manager.setLazyLoad(true);
+ manager.setSessionIdManager(idmgr);
+ handler.setSessionManager(manager);
+ // manager.setLazyLoad(true);
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
FS.ensureEmpty(testDir);
-
+
manager.getSessionDataStore().setStoreDir(testDir);
+ manager.start();
- Assert.assertTrue(new File(testDir, "validFile.session").createNewFile());
+ //See SessionKey.getKey()
+ String expectedFilename = "_0.0.0.0_validFile123";
- Assert.assertTrue("File should exist!", new File(testDir, "validFile.session").exists());
-
- manager.getSession("validFile.session");
+ Assert.assertTrue(new File(testDir, expectedFilename).createNewFile());
+
+ Assert.assertTrue("File should exist!", new File(testDir, expectedFilename).exists());
- Assert.assertTrue("File shouldn't exist!", !new File(testDir,"validFile.session").exists());
+ manager.getSession("validFile123");
+
+ Assert.assertTrue("File shouldn't exist!", !new File(testDir,expectedFilename).exists());
}
-
+
@Test
public void testHashSession() throws Exception
{
File testDir = MavenTestingUtils.getTargetTestingDir("saved");
IO.delete(testDir);
testDir.mkdirs();
-
+
Server server = new Server();
SessionHandler handler = new SessionHandler();
handler.setServer(server);
- HashSessionManager manager = new HashSessionManager();
+ FileSessionManager manager = new FileSessionManager();
manager.getSessionDataStore().setStoreDir(testDir);
manager.setMaxInactiveInterval(5);
Assert.assertTrue(testDir.exists());
@@ -88,6 +136,7 @@ public class HashSessionManagerTest
handler.setSessionManager(manager);
AbstractSessionIdManager idManager = new HashSessionIdManager();
+ idManager.setServer(server);
idManager.setWorkerName("foo");
manager.setSessionIdManager(idManager);
server.setSessionIdManager(idManager);
@@ -105,7 +154,11 @@ public class HashSessionManagerTest
manager.setMaxInactiveInterval(30); // change max inactive interval for *new* sessions
manager.stop();
- Assert.assertTrue("File should exist!", new File(testDir, session.getId()).exists());
+ for (String f: testDir.list())
+ System.err.println(f);
+
+ String expectedFilename = "_0.0.0.0_"+session.getId();
+ Assert.assertTrue("File should exist!", new File(testDir, expectedFilename).exists());
manager.start();
diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml
index e566937086..8dccc12ed9 100644
--- a/tests/test-sessions/pom.xml
+++ b/tests/test-sessions/pom.xml
@@ -32,6 +32,7 @@
<modules>
<module>test-sessions-common</module>
<module>test-hash-sessions</module>
+ <module>test-file-sessions</module>
<module>test-jdbc-sessions</module>
<module>test-mongodb-sessions</module>
<module>test-infinispan-sessions</module>
diff --git a/tests/test-sessions/test-file-sessions/.gitignore b/tests/test-sessions/test-file-sessions/.gitignore
new file mode 100644
index 0000000000..b83d22266a
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/tests/test-sessions/test-file-sessions/pom.xml b/tests/test-sessions/test-file-sessions/pom.xml
new file mode 100644
index 0000000000..f937ef47e9
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+// ========================================================================
+// Copyright (c) Webtide LLC
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.apache.org/licenses/LICENSE-2.0.txt
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.eclipse.jetty.tests</groupId>
+ <artifactId>test-sessions-parent</artifactId>
+ <version>9.3.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>test-file-sessions</artifactId>
+ <name>Jetty Tests :: Sessions :: File</name>
+ <url>http://www.eclipse.org/jetty</url>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.sessions.file</bundle-symbolic-name>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <!-- DO NOT DEPLOY (or Release) -->
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.tests</groupId>
+ <artifactId>test-sessions-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.toolchain</groupId>
+ <artifactId>jetty-test-helper</artifactId>
+ <!-- Leaving at compile scope for intellij bug reasons -->
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
new file mode 100644
index 0000000000..c10d8159fc
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
@@ -0,0 +1,54 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import java.io.File;
+
+import org.eclipse.jetty.util.IO;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ClientCrossContextSessionTest extends AbstractClientCrossContextSessionTest
+{
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ public AbstractTestServer createServer(int port)
+ {
+ return new FileTestServer(port);
+ }
+
+ @Test
+ public void testCrossContextDispatch() throws Exception
+ {
+ super.testCrossContextDispatch();
+ }
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/FileTestServer.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/FileTestServer.java
new file mode 100644
index 0000000000..390b3b8286
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/FileTestServer.java
@@ -0,0 +1,84 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import java.io.File;
+
+import org.eclipse.jetty.server.SessionIdManager;
+import org.eclipse.jetty.server.SessionManager;
+import org.eclipse.jetty.util.IO;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FileTestServer extends AbstractTestServer
+{
+ static int __workers=0;
+ static File _tmpDir;
+
+ public static void setup ()
+ throws Exception
+ {
+
+ _tmpDir = File.createTempFile("file", null);
+ _tmpDir.delete();
+ _tmpDir.mkdirs();
+ _tmpDir.deleteOnExit();
+ }
+
+
+ public static void teardown ()
+ {
+ IO.delete(_tmpDir);
+ _tmpDir = null;
+ }
+
+
+
+ public FileTestServer(int port)
+ {
+ super(port, 30, 10);
+ }
+
+ public FileTestServer(int port, int maxInactivePeriod, int scavengePeriod)
+ {
+ super(port, maxInactivePeriod, scavengePeriod);
+ }
+
+
+ public SessionIdManager newSessionIdManager(Object config)
+ {
+ HashSessionIdManager mgr = new HashSessionIdManager();
+ mgr.setWorkerName("worker"+(__workers++));
+ return mgr;
+ }
+
+ public SessionManager newSessionManager()
+ {
+ FileSessionManager manager = new FileSessionManager();
+ manager.getSessionDataStore().setStoreDir(_tmpDir);
+ return manager;
+ }
+
+ public SessionHandler newSessionHandler(SessionManager sessionManager)
+ {
+ return new SessionHandler(sessionManager);
+ }
+
+}
diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java
index 48bcf5a13a..f16bb08acb 100644
--- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java
@@ -19,10 +19,6 @@
package org.eclipse.jetty.server.session;
-import java.io.File;
-
-import org.eclipse.jetty.server.SessionManager;
-import org.eclipse.jetty.util.IO;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -34,47 +30,23 @@ import org.junit.Test;
*/
public class ForwardedSessionTest extends AbstractForwardedSessionTest
{
- File tmpDir;
@Before
public void before() throws Exception
{
- tmpDir = File.createTempFile("hash-session-forward-test", null);
- tmpDir.delete();
- tmpDir.mkdirs();
- tmpDir.deleteOnExit();
+ FileTestServer.setup();
}
@After
public void after()
{
- IO.delete(tmpDir);
+ FileTestServer.teardown();
}
@Override
public AbstractTestServer createServer(int port)
{
- return new HashTestServer(port)
- {
-
- @Override
- public SessionManager newSessionManager()
- {
- HashSessionManager sessionManager = (HashSessionManager)super.newSessionManager();
- sessionManager.setSavePeriod(2);
-
- try
- {
- sessionManager.setStoreDirectory(tmpDir);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- return sessionManager;
- }
-
- };
+ return new FileTestServer(port);
}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
new file mode 100644
index 0000000000..b044301a99
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
@@ -0,0 +1,45 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class ImmortalSessionTest extends AbstractImmortalSessionTest
+{
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+
+ @Override
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port,max,scavenge);
+ }
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java
new file mode 100644
index 0000000000..6076ae043e
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java
@@ -0,0 +1,53 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * NewSessionTest
+ */
+public class NewSessionTest extends AbstractNewSessionTest
+{
+ @Before
+ public void before() throws Exception
+ {
+ System.setProperty("org.eclipse.jetty.server.session.LEVEL", "DEBUG");
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port,max,scavenge);
+ }
+
+ @Test
+ public void testNewSession() throws Exception
+ {
+ super.testNewSession();
+ }
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java
new file mode 100644
index 0000000000..c34c7cb26d
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java
@@ -0,0 +1,52 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * OrphanedSessionTest
+ */
+public class OrphanedSessionTest extends AbstractOrphanedSessionTest
+{
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port,max,scavenge);
+ }
+
+ @Test
+ public void testOrphanedSession() throws Exception
+ {
+ super.testOrphanedSession();
+ }
+}
diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java
index d01cb17939..7c48b87625 100644
--- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java
@@ -23,6 +23,8 @@ import java.io.File;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -32,40 +34,29 @@ import org.junit.Test;
*/
public class ProxySerializationTest extends AbstractProxySerializationTest
{
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
/**
* @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
- return new HashTestServer(port,max,scavenge);
+ return new FileTestServer(port,max,scavenge);
}
-
- @Override
- public void customizeContext(ServletContextHandler c)
- {
- if (c == null)
- return;
-
- //Ensure that the HashSessionManager will persist sessions on passivation
- HashSessionManager manager = (HashSessionManager)c.getSessionHandler().getSessionManager();
- manager.setLazyLoad(false);
- manager.setIdleSavePeriod(1);
- try
- {
- File testDir = MavenTestingUtils.getTargetTestingDir("foo");
- testDir.mkdirs();
- manager.setStoreDirectory(testDir);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- }
-
@@ -75,4 +66,14 @@ public class ProxySerializationTest extends AbstractProxySerializationTest
super.testProxySerialization();
}
+ /**
+ * @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#customizeContext(org.eclipse.jetty.servlet.ServletContextHandler)
+ */
+ @Override
+ public void customizeContext(ServletContextHandler c)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
new file mode 100644
index 0000000000..147c63e714
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
@@ -0,0 +1,54 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * ReentrantRequestSessionTest
+ */
+public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
+{
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ public AbstractTestServer createServer(int port)
+ {
+ return new FileTestServer(port);
+ }
+
+ @Test
+ public void testReentrantRequestSession() throws Exception
+ {
+ super.testReentrantRequestSession();
+ }
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java
new file mode 100644
index 0000000000..a6e1511b48
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java
@@ -0,0 +1,52 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RemoveSessionTest extends AbstractRemoveSessionTest
+{
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port,max,scavenge);
+ }
+
+ @Test
+ public void testRemoveSession() throws Exception
+ {
+ super.testRemoveSession();
+ }
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ScatterGunLoadTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ScatterGunLoadTest.java
new file mode 100644
index 0000000000..9a990f3fa9
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ScatterGunLoadTest.java
@@ -0,0 +1,55 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * ScatterGunLoadTest
+ */
+public class ScatterGunLoadTest extends AbstractScatterGunLoadTest
+{
+
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ public AbstractTestServer createServer(int port)
+ {
+ return new FileTestServer(port);
+ }
+
+ @Test
+ public void testLightLoad() throws Exception
+ {
+ super.testLightLoad();
+ }
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java
new file mode 100644
index 0000000000..35c6492408
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java
@@ -0,0 +1,51 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ServerCrossContextSessionTest extends AbstractServerCrossContextSessionTest
+{
+
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ public AbstractTestServer createServer(int port)
+ {
+ return new FileTestServer(port);
+ }
+
+ @Test
+ public void testCrossContextDispatch() throws Exception
+ {
+ super.testCrossContextDispatch();
+ }
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionCookieTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionCookieTest.java
new file mode 100644
index 0000000000..8a7ae517d4
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionCookieTest.java
@@ -0,0 +1,48 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class SessionCookieTest extends AbstractSessionCookieTest
+{
+
+
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+
+ @Override
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port, max, scavenge);
+ }
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java
new file mode 100644
index 0000000000..c28a156ca6
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java
@@ -0,0 +1,51 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
+{
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ @Override
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port,max,scavenge);
+ }
+
+ @Test
+ public void testSessionScavenge() throws Exception
+ {
+ super.testSessionScavenge();
+ }
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
new file mode 100644
index 0000000000..e9a1b46236
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
@@ -0,0 +1,58 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import java.io.File;
+
+import org.eclipse.jetty.server.SessionManager;
+import org.eclipse.jetty.util.IO;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SessionRenewTest extends AbstractSessionRenewTest
+{
+
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+ @Override
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port, max, scavenge);
+ }
+
+ @Test
+ public void testSessionRenewal() throws Exception
+ {
+ super.testSessionRenewal();
+ }
+
+
+}
diff --git a/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSharedSaving.java b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSharedSaving.java
new file mode 100644
index 0000000000..d22537d91e
--- /dev/null
+++ b/tests/test-sessions/test-file-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSharedSaving.java
@@ -0,0 +1,46 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server.session;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class SessionValueSharedSaving extends AbstractSessionValueSavingTest
+{
+
+ @Before
+ public void before() throws Exception
+ {
+ FileTestServer.setup();
+ }
+
+ @After
+ public void after()
+ {
+ FileTestServer.teardown();
+ }
+
+
+ @Override
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new FileTestServer(port,max,scavenge);
+ }
+
+}
diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
index acb34033e1..46a3e5b62d 100644
--- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
+++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java
@@ -18,14 +18,16 @@
package org.eclipse.jetty.server.session;
+import java.io.File;
+
+import org.eclipse.jetty.util.IO;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
public class ClientCrossContextSessionTest extends AbstractClientCrossContextSessionTest
{
- public AbstractTestServer createServer(int port)
- {
- return new HashTestServer(port);
- }
+
@Test
public void testCrossContextDispatch() throws Exception
@@ -33,4 +35,13 @@ public class ClientCrossContextSessionTest extends AbstractClientCrossContextSes
super.testCrossContextDispatch();
}
+ /**
+ * @see org.eclipse.jetty.server.session.AbstractClientCrossContextSessionTest#createServer(int)
+ */
+ @Override
+ public AbstractTestServer createServer(int port)
+ {
+ return new HashTestServer(port);
+ }
+
}
diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java
index 3393d8ea2f..dd4de0e3a6 100644
--- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java
+++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java
@@ -26,7 +26,8 @@ import org.eclipse.jetty.server.SessionManager;
*/
public class HashTestServer extends AbstractTestServer
{
-
+ static int __workers=0;
+
public HashTestServer(int port)
{
super(port, 30, 10);
@@ -40,13 +41,14 @@ public class HashTestServer extends AbstractTestServer
public SessionIdManager newSessionIdManager(Object config)
{
- return new HashSessionIdManager();
+ HashSessionIdManager mgr = new HashSessionIdManager();
+ mgr.setWorkerName("worker"+(__workers++));
+ return mgr;
}
public SessionManager newSessionManager()
{
HashSessionManager manager = new HashSessionManager();
- manager.setScavengePeriod(_scavengePeriod);
return manager;
}
diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java
index 30ff2d19c6..331d6031e0 100644
--- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java
+++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java
@@ -47,6 +47,8 @@ import org.junit.Test;
* IdleSessionTest
*
* Checks that a session can be idled and de-idled on the next request if it hasn't expired.
+ *
+ * TODO support session idling in FileSessionDataStore?
*
*/
public class IdleSessionTest
@@ -67,17 +69,10 @@ public class IdleSessionTest
@Override
public SessionManager newSessionManager()
{
- try
- {
- HashSessionManager manager = (HashSessionManager)super.newSessionManager();
- manager.setStoreDirectory(_storeDir);
- manager.setIdleSavePeriod(_idlePeriod);
- return manager;
- }
- catch ( IOException e)
- {
- return null;
- }
+ HashSessionManager manager = (HashSessionManager)super.newSessionManager();
+ //manager.getSessionDataStore().setStoreDir(_storeDir);
+ //manager.setIdleSavePeriod(_idlePeriod);
+ return manager;
}
@@ -103,7 +98,6 @@ public class IdleSessionTest
}
}
- @Test
public void testSessionIdle() throws Exception
{
String contextPath = "";
@@ -111,7 +105,7 @@ public class IdleSessionTest
int inactivePeriod = 200;
int scavengePeriod = 3;
int idlePeriod = 5;
- ((StdErrLog)Log.getLogger(org.eclipse.jetty.server.session.HashedSession.class)).setHideStacks(true);
+ ((StdErrLog)Log.getLogger("org.eclipse.jetty.server.session")).setHideStacks(true);
System.setProperty("org.eclipse.jetty.STACKS", "false");
File storeDir = new File (System.getProperty("java.io.tmpdir"), "idle-test");
storeDir.deleteOnExit();
@@ -229,7 +223,7 @@ public class IdleSessionTest
HttpSession session = request.getSession(true);
session.setAttribute("test", "test");
originalId = session.getId();
- assertTrue(!((HashedSession)session).isIdled());
+// assertTrue(!((HashedSession)session).isIdled());
}
else if ("test".equals(action))
{
@@ -237,7 +231,7 @@ public class IdleSessionTest
assertTrue(session != null);
assertTrue(originalId.equals(session.getId()));
assertEquals("test", session.getAttribute("test"));
- assertTrue(!((HashedSession)session).isIdled());
+ // assertTrue(!((HashedSession)session).isIdled());
}
else if ("testfail".equals(action))
{
diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
index 207dbdbc4c..9391cbf9ce 100644
--- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
+++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
@@ -28,47 +28,11 @@ import org.junit.Test;
public class SessionRenewTest extends AbstractSessionRenewTest
{
- File tmpDir;
-
- @Before
- public void before() throws Exception
- {
- tmpDir = File.createTempFile("hash-session-renew-test", null);
- tmpDir.delete();
- tmpDir.mkdirs();
- tmpDir.deleteOnExit();
- }
-
- @After
- public void after()
- {
- IO.delete(tmpDir);
- }
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
- return new HashTestServer(port, max, scavenge)
- {
-
- @Override
- public SessionManager newSessionManager()
- {
- HashSessionManager sessionManager = (HashSessionManager)super.newSessionManager();
- sessionManager.setSavePeriod(2);
-
- try
- {
- sessionManager.setStoreDirectory(tmpDir);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- return sessionManager;
- }
-
- };
+ return new HashTestServer(port, max, scavenge);
}
@Test
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java
index 61111efc4c..410e1a72ed 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java
@@ -46,7 +46,9 @@ public abstract class AbstractNewSessionTest
{
try
{
+ System.err.println("Sleeping "+(scavenge * 2500L));
Thread.sleep(scavenge * 2500L);
+ System.err.println("Sleeping "+(scavenge * 2500L));
}
catch (InterruptedException e)
{
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java
index db150ba5b6..0899fac669 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java
@@ -131,7 +131,7 @@ public abstract class AbstractSessionRenewTest
String beforeSessionId = beforeSession.getId();
- ((AbstractSession)beforeSession).renewId(request);
+ ((Session)beforeSession).renewId(request);
HttpSession afterSession = request.getSession(false);
assertTrue(afterSession != null);
@@ -140,7 +140,7 @@ public abstract class AbstractSessionRenewTest
assertTrue(beforeSession==afterSession);
assertFalse(beforeSessionId.equals(afterSessionId));
- AbstractSessionManager sessionManager = (AbstractSessionManager)((AbstractSession)afterSession).getSessionManager();
+ SessionManager sessionManager = ((Session)afterSession).getSessionManager();
AbstractSessionIdManager sessionIdManager = (AbstractSessionIdManager)sessionManager.getSessionIdManager();
assertTrue(sessionIdManager.isIdInUse(afterSessionId));
@@ -151,7 +151,7 @@ public abstract class AbstractSessionRenewTest
session = sessionManager.getSession(beforeSessionId);
assertNull(session);
- if (((AbstractSession)afterSession).isIdChanged())
+ if (((Session)afterSession).isIdChanged())
{
((org.eclipse.jetty.server.Response)response).addCookie(sessionManager.getSessionCookie(afterSession, request.getContextPath(), request.isSecure()));
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java
index 789f6b28d1..b98bd16382 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractTestServer.java
@@ -42,6 +42,7 @@ public abstract class AbstractTestServer
protected final int _scavengePeriod;
protected final ContextHandlerCollection _contexts;
protected SessionIdManager _sessionIdManager;
+ private SessionScavenger _scavenger;
@@ -81,6 +82,10 @@ public abstract class AbstractTestServer
_contexts = new ContextHandlerCollection();
_sessionIdManager = newSessionIdManager(sessionIdMgrConfig);
_server.setSessionIdManager(_sessionIdManager);
+ ((AbstractSessionIdManager) _sessionIdManager).setServer(_server);
+ _scavenger = new SessionScavenger();
+ _scavenger.setScavengeIntervalSec(scavengePeriod);
+ ((AbstractSessionIdManager)_sessionIdManager).setSessionScavenger(_scavenger);
}

Back to the top