This commit is contained in:
Jan Bartel 2017-01-13 22:30:44 +11:00
parent 7e3d3604ac
commit ec193693a2
168 changed files with 1886 additions and 7068 deletions

View File

@ -20,20 +20,20 @@
package org.eclipse.jetty.server.session;
/**
* EvictionFailureTest
* NullSessionDataStoreFactory
*
*
*/
public class EvictionFailureTest extends AbstractSessionEvictionFailureTest
public class NullSessionDataStoreFactory extends AbstractSessionDataStoreFactory
{
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.SessionDataStoreFactory#getSessionDataStore(org.eclipse.jetty.server.session.SessionHandler)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) throws Exception
public SessionDataStore getSessionDataStore(SessionHandler handler) throws Exception
{
return new HashTestServer(port, maxInactive, scavengeInterval, evictionPolicy);
return new NullSessionDataStore();
}
}

View File

@ -1,58 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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();
}
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
}
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -23,27 +23,32 @@ import org.junit.Before;
import org.junit.Test;
/**
* OrphanedSessionTest
* ClusteredOrphanedSessionTest
*/
public class OrphanedSessionTest extends AbstractOrphanedSessionTest
public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest
{
@Before
public void before() throws Exception
{
FileTestServer.setup();
FileTestHelper.setup();
}
@After
public void after()
{
FileTestServer.teardown();
FileTestHelper.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return FileTestHelper.newSessionDataStoreFactory();
}
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge,evictionPolicy);
}
@Test
public void testOrphanedSession() throws Exception
{

View File

@ -19,19 +19,19 @@
package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import java.io.File;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.util.IO;
/**
* @version $Revision$ $Date$
* FileTestHelper
*
*/
public class FileTestServer extends AbstractTestServer
public class FileTestHelper
{
static int __workers=0;
static File _tmpDir;
@ -118,34 +118,11 @@ public class FileTestServer extends AbstractTestServer
assertTrue(f.delete());
}
}
public FileTestServer(int port, int maxInactivePeriod, int scavengePeriod, int idlePassivatePeriod) throws Exception
public static FileSessionDataStoreFactory newSessionDataStoreFactory()
{
super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod);
FileSessionDataStoreFactory storeFactory = new FileSessionDataStoreFactory();
storeFactory.setStoreDir(_tmpDir);
return storeFactory;
}
public SessionIdManager newSessionIdManager(Object config)
{
DefaultSessionIdManager mgr = new DefaultSessionIdManager(_server);
mgr.setWorkerName("worker"+(__workers++));
return mgr;
}
public SessionHandler newSessionHandler()
{
SessionHandler handler = new TestSessionHandler();
DefaultSessionCache ss = new DefaultSessionCache(handler);
handler.setSessionCache(ss);
FileSessionDataStore ds = new FileSessionDataStore();
ds.setStoreDir(_tmpDir);
ss.setSessionDataStore(ds);
return handler;
}
}

View File

@ -1,64 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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;
/**
* ForwardedSessionTest
*
*
*/
public class ForwardedSessionTest extends AbstractForwardedSessionTest
{
@Before
public void before() throws Exception
{
FileTestServer.setup();
}
@After
public void after()
{
FileTestServer.teardown();
}
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
}
@Test
public void testSessionCreateInForward() throws Exception
{
super.testSessionCreateInForward();
}
}

View File

@ -1,91 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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;
/**
* IdleSessionTest
*
*
*/
public class IdleSessionTest extends AbstractIdleSessionTest
{
@Before
public void before() throws Exception
{
FileTestServer.setup();
}
@After
public void after()
{
FileTestServer.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractIdleSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
}
/**
* @see org.eclipse.jetty.server.session.AbstractIdleSessionTest#checkSessionIdled(java.lang.String)
*/
@Override
public void checkSessionIdled(String sessionId)
{
FileTestServer.assertStoreDirEmpty(false);
FileTestServer.assertFileExists(sessionId, true);
}
/**
* @see org.eclipse.jetty.server.session.AbstractIdleSessionTest#checkSessionDeIdled(java.lang.String)
*/
@Override
public void checkSessionDeIdled(String sessionId)
{
//Can't check absence of file to indicate session is de-idled
//because the FileSessionDataStore writes out the session to a file if anything changes.
//The test changes an attribute so the file will probably exist.
}
/**
* @see org.eclipse.jetty.server.session.AbstractIdleSessionTest#deleteSessionData(java.lang.String)
*/
@Override
public void deleteSessionData(String sessionId)
{
FileTestServer.deleteFile(sessionId);
FileTestServer.assertFileExists(sessionId, false);
}
}

View File

@ -1,58 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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;
/**
* ImmediateSaveTest
*
*
*/
public class ImmediateSaveTest extends AbstractImmediateSaveTest
{
@Before
public void before() throws Exception
{
FileTestServer.setup();
}
@After
public void after()
{
FileTestServer.teardown();
}
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{ return new FileTestServer(port, max, scavenge, evictionPolicy)
{
public SessionHandler newSessionHandler()
{
SessionHandler h = super.newSessionHandler();
h.getSessionCache().setSaveOnCreate(true);
return h;
}
};
}
}

View File

@ -1,45 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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,int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
}
}

View File

@ -23,26 +23,32 @@ import org.junit.Before;
import org.junit.Test;
/**
* NewSessionTest
* NonClusteredSessionScavengingTest
*/
public class NewSessionTest extends AbstractNewSessionTest
public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessionScavengingTest
{
@Before
public void before() throws Exception
{
System.setProperty("org.eclipse.jetty.server.session.LEVEL", "DEBUG");
FileTestServer.setup();
FileTestHelper.setup();
}
@After
public void after()
{
FileTestServer.teardown();
FileTestHelper.teardown();
}
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new FileTestServer(port,max,scavenge,evictionPolicy);
return FileTestHelper.newSessionDataStoreFactory();
}
@Test

View File

@ -19,10 +19,7 @@
package org.eclipse.jetty.server.session;
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;
@ -38,25 +35,25 @@ public class ProxySerializationTest extends AbstractProxySerializationTest
@Before
public void before() throws Exception
{
FileTestServer.setup();
FileTestHelper.setup();
}
@After
public void after()
{
FileTestServer.teardown();
FileTestHelper.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy ) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
return FileTestHelper.newSessionDataStoreFactory();
}

View File

@ -1,55 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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, int max, int scavenge, int evictionPolicy) throws Exception
{
return new FileTestServer(port, max, scavenge, evictionPolicy);
}
@Test
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
}

View File

@ -1,52 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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,int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge,evictionPolicy);
}
@Test
public void testRemoveSession() throws Exception
{
super.testRemoveSession();
}
}

View File

@ -1,59 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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();
}
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
}
@Test
public void testLightLoad() throws Exception
{
super.testLightLoad();
}
}

View File

@ -1,55 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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();
}
@Override
public AbstractTestServer createServer(final int port, final int max, final int scavenge, final int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge, evictionPolicy);
}
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -1,48 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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,int evictionPolicy) throws Exception
{
return new FileTestServer(port, max, scavenge,evictionPolicy);
}
}

View File

@ -22,25 +22,29 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
public class SessionInvalidateCreateScavengeTest extends AbstractSessionInvalidateCreateScavengeTest
{
@Before
public void before() throws Exception
{
FileTestServer.setup();
FileTestHelper.setup();
}
@After
public void after()
{
FileTestServer.teardown();
FileTestHelper.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new FileTestServer(port,max,scavenge,evictionPolicy);
return FileTestHelper.newSessionDataStoreFactory();
}
@Test

View File

@ -1,66 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.eclipse.jetty.webapp.WebAppContext;
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,int evictionPolicy) throws Exception
{
return new FileTestServer(port, max, scavenge,evictionPolicy);
}
@Test
public void testSessionRenewal() throws Exception
{
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(WebAppContext, java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(WebAppContext context, String oldSessionId, String newSessionId)
{
((FileTestServer)_server).assertFileExists(oldSessionId, false);
((FileTestServer)_server).assertFileExists(newSessionId, true);
return true;
}
}

View File

@ -1,46 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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,int evictionPolicy) throws Exception
{
return new FileTestServer(port,max,scavenge,evictionPolicy);
}
}

View File

@ -1,56 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractClientCrossContextSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ClientCrossContextSessionTest
*
*
*/
public class ClientCrossContextSessionTest extends AbstractClientCrossContextSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
}
@Test
@Override
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -19,18 +19,17 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractLastAccessTimeTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* LastAccessTimeTest
* ClusteredLastAccessTimeTest
*
*
*/
public class LastAccessTimeTest extends AbstractLastAccessTimeTest
public class ClusteredLastAccessTimeTest extends AbstractClusteredLastAccessTimeTest
{
@AfterClass
@ -38,13 +37,15 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractLastAccessTimeTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test

View File

@ -19,18 +19,17 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractOrphanedSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.AbstractClusteredOrphanedSessionTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* OrphanedSessionTest
* ClusteredOrphanedSessionTest
*
*
*/
public class OrphanedSessionTest extends AbstractOrphanedSessionTest
public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest
{
@AfterClass
@ -40,14 +39,16 @@ public class OrphanedSessionTest extends AbstractOrphanedSessionTest
}
/**
* @see org.eclipse.jetty.server.session.AbstractOrphanedSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test
@Override

View File

@ -19,18 +19,17 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionMigrationTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionMigrationTest
* ClusteredSessionMigrationTest
*
*
*/
public class SessionMigrationTest extends AbstractSessionMigrationTest
public class ClusteredSessionMigrationTest extends AbstractClusteredSessionMigrationTest
{
@AfterClass
public static void teardown () throws Exception
@ -38,14 +37,14 @@ public class SessionMigrationTest extends AbstractSessionMigrationTest
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionMigrationTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test

View File

@ -19,18 +19,17 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* LocalSessionScavengingTest
* ClusteredSessionScavengingTest
*
*
*/
public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTest
public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest
{
@AfterClass
@ -39,13 +38,14 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test

View File

@ -1,48 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractForwardedSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* ForwardedSessionTest
*
*
*/
public class ForwardedSessionTest extends AbstractForwardedSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
}
}

View File

@ -27,6 +27,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.jetty.server.session.SessionDataStore;
import org.eclipse.jetty.server.session.SessionHandler;
import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.datastore.Entity;
@ -47,7 +50,31 @@ public class GCloudSessionTestSupport
LocalDatastoreHelper _helper = LocalDatastoreHelper.create(1.0);
Datastore _ds;
public static class TestGCloudSessionDataStoreFactory extends GCloudSessionDataStoreFactory
{
Datastore _d;
public TestGCloudSessionDataStoreFactory(Datastore d)
{
_d = d;
}
/**
* @see org.eclipse.jetty.gcloud.session.GCloudSessionDataStoreFactory#getSessionDataStore(org.eclipse.jetty.server.session.SessionHandler)
*/
@Override
public SessionDataStore getSessionDataStore(SessionHandler handler) throws Exception
{
GCloudSessionDataStore ds = new GCloudSessionDataStore();
ds.setDatastore(_d);
return ds;
}
}
public static GCloudSessionDataStoreFactory newSessionDataStoreFactory(Datastore d)
{
return new TestGCloudSessionDataStoreFactory(d);
}
public GCloudSessionTestSupport ()
{

View File

@ -1,65 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.DefaultSessionCache;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.server.session.TestSessionHandler;
/**
* GCloudTestServer
*
*
*/
public class GCloudTestServer extends AbstractTestServer
{
/**
* @param port
* @param maxInactivePeriod
* @param scavengePeriod
* @param evictionPolicy
* @throws Exception TODO
*/
public GCloudTestServer(int port, int maxInactivePeriod, int scavengePeriod, int evictionPolicy) throws Exception
{
super(port, maxInactivePeriod, scavengePeriod, evictionPolicy);
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestServer#newSessionHandler()
*/
@Override
public SessionHandler newSessionHandler()
{
SessionHandler handler = new TestSessionHandler();
handler.setSessionIdManager(_sessionIdManager);
GCloudSessionDataStore ds = new GCloudSessionDataStore();
ds.setDatastore(GCloudTestSuite.__testSupport.getDatastore());
DefaultSessionCache ss = new DefaultSessionCache(handler);
ss.setSessionDataStore(ds);
handler.setSessionCache(ss);
return handler;
}
}

View File

@ -31,25 +31,14 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
ClientCrossContextSessionTest.class,
ForwardedSessionTest.class,
ImmediateSaveTest.class,
ImmortalSessionTest.class,
InvalidationSessionTest.class,
LastAccessTimeTest.class,
LocalSessionScavengingTest.class,
NewSessionTest.class,
OrphanedSessionTest.class,
ReentrantRequestSessionTest.class,
RemoveSessionTest.class,
SameNodeLoadTest.class,
ServerCrossContextSessionTest.class,
ClusteredLastAccessTimeTest.class,
ClusteredSessionScavengingTest.class,
NonClusteredSessionScavengingTest.class,
ClusteredOrphanedSessionTest.class,
SessionExpiryTest.class,
SessionInvalidateAndCreateTest.class,
SessionMigrationTest.class,
SessionRenewTest.class,
SessionValueSavingTest.class,
StopSessionManagerPreserveSessionTest.class
SessionInvalidateCreateScavengeTest.class,
ClusteredSessionMigrationTest.class,
})

View File

@ -1,61 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractImmediateSaveTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.SessionHandler;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
/**
* ImmediateSaveTest
*
*
*/
public class ImmediateSaveTest extends AbstractImmediateSaveTest
{
@After
public void deleteSessions () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy)
{
public SessionHandler newSessionHandler()
{
SessionHandler h = super.newSessionHandler();
h.getSessionCache().setSaveOnCreate(true);
return h;
}
};
}
}

View File

@ -1,59 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractImmortalSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ImmortalSessionTest
*
*
*/
public class ImmortalSessionTest extends AbstractImmortalSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractImmortalSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
}
@Test
@Override
public void testImmortalSession() throws Exception
{
super.testImmortalSession();
}
}

View File

@ -20,19 +20,16 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractInvalidationSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.server.session.AbstractClusteredInvalidationSessionTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
/**
* InvalidationSessionTest
*
*
*/
public class InvalidationSessionTest extends AbstractInvalidationSessionTest
public class InvalidationSessionTest extends AbstractClusteredInvalidationSessionTest
{
@AfterClass
@ -40,28 +37,13 @@ public class InvalidationSessionTest extends AbstractInvalidationSessionTest
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractInvalidationSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
GCloudTestServer server = new GCloudTestServer(port, maxInactive, scavengeInterval, evictionPolicy)
{
/**
* @see org.eclipse.jetty.gcloud.session.GCloudTestServer#newSessionHandler()
*/
@Override
public SessionHandler newSessionHandler()
{
SessionHandler handler = super.newSessionHandler();
handler.getSessionCache().setEvictionPolicy(evictionPolicy);
return handler;
}
};
return server;
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
}

View File

@ -19,23 +19,17 @@
package org.eclipse.jetty.gcloud.session;
import java.io.File;
import org.eclipse.jetty.server.session.AbstractNewSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.AbstractNonClusteredSessionScavengingTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/**
* NewSessionTest
* NonClusteredSessionScavengingTest
*
*
*/
public class NewSessionTest extends AbstractNewSessionTest
public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessionScavengingTest
{
@ -46,14 +40,16 @@ public class NewSessionTest extends AbstractNewSessionTest
}
/**
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test
public void testNewSession() throws Exception

View File

@ -1,60 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ReentrantRequestSessionTest
*
*
*/
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port,int max, int scavengePeriod,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, max, scavengePeriod, evictionPolicy);
}
@Test
@Override
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
}

View File

@ -1,63 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractRemoveSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* RemoveSessionTest
*
*
*/
public class RemoveSessionTest extends AbstractRemoveSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractRemoveSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
}
@Test
@Override
public void testRemoveSession() throws Exception
{
super.testRemoveSession();
}
}

View File

@ -1,60 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSameNodeLoadTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SameNodeLoadTest
*
*
*/
public class SameNodeLoadTest extends AbstractSameNodeLoadTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
}
@Test
@Override
public void testLoad() throws Exception
{
super.testLoad();
}
}

View File

@ -1,55 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractServerCrossContextSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ServerCrossContextSessionTest
*
*
*/
public class ServerCrossContextSessionTest extends AbstractServerCrossContextSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
}
@Test
@Override
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -20,13 +20,10 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.After;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.Assert;
import org.junit.Test;
/**
@ -43,14 +40,14 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionExpiryTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test

View File

@ -19,18 +19,17 @@
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionInvalidateAndCreateTest
* SessionInvalidateCreateScavengeTest
*
*
*/
public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
public class SessionInvalidateCreateScavengeTest extends AbstractSessionInvalidateCreateScavengeTest
{
@AfterClass
public static void teardown () throws Exception
@ -40,12 +39,12 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
/**
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test

View File

@ -1,82 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import java.util.Set;
import org.eclipse.jetty.server.session.AbstractSessionRenewTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.webapp.WebAppContext;
import static org.junit.Assert.fail;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionRenewTest
*
*
*/
public class SessionRenewTest extends AbstractSessionRenewTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new GCloudTestServer(port,max, scavenge, evictionPolicy);
}
@Test
@Override
public void testSessionRenewal() throws Exception
{
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(WebAppContext, java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(WebAppContext context, String oldSessionId, String newSessionId)
{
try
{
Set<String> ids = GCloudTestSuite.__testSupport.getSessionIds();
return (!ids.contains(oldSessionId) && ids.contains(newSessionId));
}
catch (Exception e)
{
fail(e.getMessage());
return false;
}
}
}

View File

@ -1,58 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionValueSavingTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionValueSavingTest
*
*
*/
public class SessionValueSavingTest extends AbstractSessionValueSavingTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionValueSavingTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, max, scavenge, evictionPolicy);
}
@Test
@Override
public void testSessionValueSaving() throws Exception
{
super.testSessionValueSaving();
}
}

View File

@ -1,84 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.gcloud.session;
import static org.junit.Assert.fail;
import org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* StopSessionManagerPreserveSessionTest
*
*
*/
public class StopSessionManagerPreserveSessionTest extends AbstractStopSessionManagerPreserveSessionTest
{
@AfterClass
public static void teardown () throws Exception
{
GCloudTestSuite.__testSupport.deleteSessions();
}
/**
* @see org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest#checkSessionPersisted(String, boolean)
*/
@Override
public void checkSessionPersisted(String id, boolean expected)
{
try
{
GCloudTestSuite.__testSupport.assertSessions(1);
}
catch (Exception e)
{
fail(e.getMessage());
}
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) throws Exception
{
return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
}
/**
* @see org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest#configureSessionManagement(org.eclipse.jetty.servlet.ServletContextHandler)
*/
@Override
public void configureSessionManagement(ServletContextHandler context)
{
}
@Test
@Override
public void testStopSessionManagerPreserveSession() throws Exception
{
super.testStopSessionManagerPreserveSession();
}
}

View File

@ -1,44 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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
{
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port,max,scavenge,evictionPolicy);
}
}

View File

@ -18,13 +18,16 @@
package org.eclipse.jetty.server.session;
public class SessionCookieTest extends AbstractSessionCookieTest
/**
* HashTestHelper
*
*/
public class HashTestHelper
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public static SessionDataStoreFactory newSessionDataStoreFactory()
{
return new HashTestServer(port, max, scavenge, evictionPolicy);
return new NullSessionDataStoreFactory();
}
}

View File

@ -1,44 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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;
/**
* @version $Revision$ $Date$
*/
public class HashTestServer extends AbstractTestServer
{
public HashTestServer(int port, int maxInactivePeriod, int scavengePeriod, int evictionPolicy) throws Exception
{
super(port, maxInactivePeriod, scavengePeriod, evictionPolicy);
}
public SessionHandler newSessionHandler()
{
SessionHandler handler = new TestSessionHandler();
DefaultSessionCache ss = new DefaultSessionCache(handler);
handler.setSessionCache(ss);
ss.setSessionDataStore(new NullSessionDataStore());
return handler;
}
}

View File

@ -1,30 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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;
public class ImmortalSessionTest extends AbstractImmortalSessionTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port,max,scavenge,evictionPolicy);
}
}

View File

@ -21,19 +21,25 @@ package org.eclipse.jetty.server.session;
import org.junit.Test;
/**
* NewSessionTest
* NonClusteredSessionScavengingTest
*/
public class NewSessionTest extends AbstractNewSessionTest
public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessionScavengingTest
{
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port,max,scavenge,evictionPolicy);
}
@Test
public void testNewSession() throws Exception
{
super.testNewSession();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return HashTestHelper.newSessionDataStoreFactory();
}
}

View File

@ -1,44 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
/**
* ReentrantRequestSessionTest
*/
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
/**
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port, max, scavenge, evictionPolicy);
}
@Test
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
}

View File

@ -1,42 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
public class RemoveSessionTest extends AbstractRemoveSessionTest
{
@Test
public void testRemoveSession() throws Exception
{
super.testRemoveSession();
}
/**
* @see org.eclipse.jetty.server.session.AbstractRemoveSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer (port, max, scavenge, evictionPolicy);
}
}

View File

@ -1,35 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
public class ServerCrossContextSessionTest extends AbstractServerCrossContextSessionTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port,max,scavenge,evictionPolicy);
}
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -20,13 +20,15 @@ package org.eclipse.jetty.server.session;
import org.junit.Test;
public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
public class SessionInvalidateCreateScavengeTest extends AbstractSessionInvalidateCreateScavengeTest
{
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new HashTestServer(port,max,scavenge,evictionPolicy);
return HashTestHelper.newSessionDataStoreFactory();
}
@Test

View File

@ -1,55 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.eclipse.jetty.webapp.WebAppContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class SessionRenewTest extends AbstractSessionRenewTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port, max, scavenge,evictionPolicy);
}
@Test
public void testSessionRenewal() throws Exception
{
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(WebAppContext, java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(WebAppContext context ,String oldSessionId, String newSessionId)
{
return true; //no other tests possible, sessions only in memory
}
}

View File

@ -1,30 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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;
public class SessionValueSharedSaving extends AbstractSessionValueSavingTest
{
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new HashTestServer(port,max,scavenge,evictionPolicy);
}
}

View File

@ -1,60 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class ClientCrossContextSessionTest extends AbstractClientCrossContextSessionTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
}
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -18,10 +18,11 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class LastAccessTimeTest extends AbstractLastAccessTimeTest
public class ClusteredLastAccessTimeTest extends AbstractClusteredLastAccessTimeTest
{
public static InfinispanTestSupport __testSupport;
@ -39,18 +40,23 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
}
@Override
public void testLastAccessTime() throws Exception
{
super.testLastAccessTime();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
}

View File

@ -19,15 +19,16 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* SessionMigrationTest
* ClusteredSessionMigrationTest
*
*
*/
public class SessionMigrationTest extends AbstractSessionMigrationTest
public class ClusteredSessionMigrationTest extends AbstractClusteredSessionMigrationTest
{
public static InfinispanTestSupport __testSupport;
@ -47,10 +48,15 @@ public class SessionMigrationTest extends AbstractSessionMigrationTest
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Override

View File

@ -19,15 +19,16 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* LocalSessionScavengingTest
* ClusteredSessionScavengingTest
*
*
*/
public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTest
public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest
{
public static InfinispanTestSupport __testSupport;
@ -43,17 +44,18 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
}

View File

@ -1,66 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ForwardedSessionTest
*
*
*/
public class ForwardedSessionTest extends AbstractForwardedSessionTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
}
@Test
public void testSessionCreateInForward() throws Exception
{
super.testSessionCreateInForward();
}
}

View File

@ -1,64 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
import org.junit.BeforeClass;
/**
* RemoteImmediateSaveTest
*
*
*/
public class ImmediateSaveTest extends AbstractImmediateSaveTest
{
InfinispanTestSessionServer _server;
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
_server = new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache())
{
public SessionHandler newSessionHandler()
{
SessionHandler h = super.newSessionHandler();
h.getSessionCache().setSaveOnCreate(true);
return h;
}
};
return _server;
}
}

View File

@ -1,71 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.infinispan.Cache;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* ImmortalSessionTest
*
*
*/
public class ImmortalSessionTest extends AbstractImmortalSessionTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractImmortalSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
}
@Override
public void testImmortalSession() throws Exception
{
super.testImmortalSession();
}
}

View File

@ -1,92 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStore;
import org.eclipse.jetty.webapp.WebAppContext;
import org.infinispan.Cache;
import org.infinispan.commons.api.BasicCache;
import org.infinispan.commons.util.CloseableIteratorSet;
public class InfinispanTestSessionServer extends AbstractTestServer
{
public InfinispanTestSessionServer(int port, int maxInactivePeriod, int scavengePeriod, int evictionPolicy, BasicCache config) throws Exception
{
super(port, maxInactivePeriod, scavengePeriod, evictionPolicy, config);
}
@Override
public SessionHandler newSessionHandler()
{
SessionHandler handler = new TestSessionHandler();
InfinispanSessionDataStore sds = new InfinispanSessionDataStore();
sds.setCache((BasicCache)_config);
DefaultSessionCache ss = new DefaultSessionCache(handler);
ss.setSessionDataStore(sds);
handler.setSessionCache(ss);
return handler;
}
public boolean exists (WebAppContext context, String id)
{
BasicCache cache = (BasicCache)_config;
if (cache != null)
{
return cache.containsKey(((InfinispanSessionDataStore)(context.getSessionHandler().getSessionCache().getSessionDataStore())).getCacheKey(id));
}
return false;
}
public Object get (WebAppContext context, String id)
{
BasicCache cache = (BasicCache)_config;
if (cache != null)
{
return cache.get(((InfinispanSessionDataStore)(context.getSessionHandler().getSessionCache().getSessionDataStore())).getCacheKey(id));
}
return null;
}
public void dumpCache ()
{
BasicCache cache = (BasicCache)_config;
if (cache != null)
{
System.err.println(cache.getName()+" contains "+cache.size()+" entries");
}
}
public void clearCache ()
{
BasicCache cache = (BasicCache)_config;
if (cache != null)
cache.clear();
}
}

View File

@ -57,6 +57,9 @@ public class InfinispanTestSupport
}
}
public InfinispanTestSupport ()
{
this (null);

View File

@ -19,15 +19,16 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* NewSessionTest
* NonClusteredSessionScavengingTest
*
*
*/
public class NewSessionTest extends AbstractNewSessionTest
public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessionScavengingTest
{
public static InfinispanTestSupport __testSupport;
@ -46,15 +47,18 @@ public class NewSessionTest extends AbstractNewSessionTest
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Override
public void testNewSession() throws Exception

View File

@ -1,64 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
import org.junit.BeforeClass;
/**
* ReentrantRequestSessionTest
*
*
*/
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port,int maxInactive, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactive, scavenge, evictionPolicy, __testSupport.getCache());
}
@Override
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
}

View File

@ -1,58 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class RemoveSessionTest extends AbstractRemoveSessionTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
InfinispanTestSessionServer s = new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
return s;
}
@Test
public void testRemoveSession() throws Exception
{
super.testRemoveSession();
}
}

View File

@ -1,66 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
import org.junit.BeforeClass;
/**
* SameNodeLoadTest
*
*
*/
public class SameNodeLoadTest extends AbstractSameNodeLoadTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port,int maxInactive, int scavenge, int evictionPolicy) throws Exception
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port,maxInactive, scavenge, evictionPolicy, __testSupport.getCache());
return server;
}
@Override
public void testLoad() throws Exception
{
super.testLoad();
}
}

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -41,13 +42,18 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
return server;
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Test
@Override
public void testSessionNotExpired() throws Exception

View File

@ -19,15 +19,16 @@
package org.eclipse.jetty.server.session;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* SessionInvalidateAndCreateTest
* SessionInvalidateCreateScavengeTest
*
*
*/
public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
public class SessionInvalidateCreateScavengeTest extends AbstractSessionInvalidateCreateScavengeTest
{
public static InfinispanTestSupport __testSupport;
@ -46,13 +47,16 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Override

View File

@ -1,83 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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 static org.junit.Assert.assertTrue;
import org.eclipse.jetty.webapp.WebAppContext;
import static org.junit.Assert.assertFalse;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionRenewTest
*
*
*/
public class SessionRenewTest extends AbstractSessionRenewTest
{
public static InfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new InfinispanTestSupport();
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
}
@Test
public void testSessionRenewal() throws Exception
{
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(WebAppContext, java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(WebAppContext context, String oldSessionId, String newSessionId)
{
assertTrue(((InfinispanTestSessionServer)_server).exists(context, newSessionId));
assertFalse(((InfinispanTestSessionServer)_server).exists(context, oldSessionId));
return (!((InfinispanTestSessionServer)_server).exists(context, oldSessionId)) && ((InfinispanTestSessionServer)_server).exists(context, newSessionId);
}
}

View File

@ -19,18 +19,18 @@
package org.eclipse.jetty.server.session.remote;
import org.eclipse.jetty.server.session.AbstractNewSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.AbstractNonClusteredSessionScavengingTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* NewSessionTest
* NonClusteredSessionScavengingTest
*
*
*/
public class RemoteNewSessionTest extends AbstractNewSessionTest
public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessionScavengingTest
{
public static RemoteInfinispanTestSupport __testSupport;
@ -48,14 +48,16 @@ public class RemoteNewSessionTest extends AbstractNewSessionTest
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}

View File

@ -1,69 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractClientCrossContextSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
/**
* RemoteClientCrossContextSessionTest
*
*
*/
public class RemoteClientCrossContextSessionTest extends AbstractClientCrossContextSessionTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
}
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -19,19 +19,18 @@
package org.eclipse.jetty.server.session.remote;
import org.eclipse.jetty.server.session.AbstractInvalidationSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.AbstractClusteredInvalidationSessionTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
/**
* InvalidationSessionTest
*
*
*/
public class RemoteInvalidationSessionTest extends AbstractInvalidationSessionTest
public class RemoteClusteredInvalidationSessionTest extends AbstractClusteredInvalidationSessionTest
{
public static RemoteInfinispanTestSupport __testSupport;
@ -52,15 +51,17 @@ public class RemoteInvalidationSessionTest extends AbstractInvalidationSessionTe
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractInvalidationSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int maxInterval, int scavengeInterval, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, maxInterval, scavengeInterval, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
}

View File

@ -18,21 +18,13 @@
package org.eclipse.jetty.server.session.remote;
import java.io.File;
import org.eclipse.jetty.server.session.AbstractLastAccessTimeTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
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.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class RemoteLastAccessTimeTest extends AbstractLastAccessTimeTest
public class RemoteClusteredLastAccessTimeTest extends AbstractClusteredLastAccessTimeTest
{
public static RemoteInfinispanTestSupport __testSupport;
@ -51,10 +43,16 @@ public class RemoteLastAccessTimeTest extends AbstractLastAccessTimeTest
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Override

View File

@ -19,18 +19,18 @@
package org.eclipse.jetty.server.session.remote;
import org.eclipse.jetty.server.session.AbstractSessionMigrationTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* RemoteSessionMigrationTest
* RemoteClusteredSessionMigrationTest
*
*
*/
public class RemoteSessionMigrationTest extends AbstractSessionMigrationTest
public class RemoteClusteredSessionMigrationTest extends AbstractClusteredSessionMigrationTest
{
public static RemoteInfinispanTestSupport __testSupport;
@ -50,11 +50,17 @@ public class RemoteSessionMigrationTest extends AbstractSessionMigrationTest
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Override
public void testSessionMigration() throws Exception
{

View File

@ -19,18 +19,18 @@
package org.eclipse.jetty.server.session.remote;
import org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* LocalSessionScavengingTest
* ClusteredSessionScavengingTest
*
*
*/
public class RemoteLocalSessionScavengingTest extends AbstractLocalSessionScavengingTest
public class RemoteClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest
{
public static RemoteInfinispanTestSupport __testSupport;
@ -49,13 +49,16 @@ public class RemoteLocalSessionScavengingTest extends AbstractLocalSessionScaven
}
/**
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
}

View File

@ -1,67 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractForwardedSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* RemoteForwardedSessionTest
*
*
*/
public class RemoteForwardedSessionTest extends AbstractForwardedSessionTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
}
@Test
public void testSessionCreateInForward() throws Exception
{
super.testSessionCreateInForward();
}
}

View File

@ -1,66 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractImmediateSaveTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.SessionHandler;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* RemoteImmediateSaveTest
*
*
*/
public class RemoteImmediateSaveTest extends AbstractImmediateSaveTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache())
{
public SessionHandler newSessionHandler()
{
SessionHandler h = super.newSessionHandler();
h.getSessionCache().setSaveOnCreate(true);
return h;
}
};
}
}

View File

@ -1,74 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractImmortalSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* ImmortalSessionTest
*
*
*/
public class RemoteImmortalSessionTest extends AbstractImmortalSessionTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractImmortalSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactiveMs, scavenge, evictionPolicy, __testSupport.getCache());
}
@Override
public void testImmortalSession() throws Exception
{
super.testImmortalSession();
}
}

View File

@ -19,17 +19,8 @@
package org.eclipse.jetty.server.session.remote;
import java.io.File;
import org.eclipse.jetty.util.IO;
import org.infinispan.Cache;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
/**
* RemoteInfinispanTestSupport

View File

@ -1,67 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* ReentrantRequestSessionTest
*
*
*/
public class RemoteReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, maxInactive, scavenge, evictionPolicy, __testSupport.getCache());
}
@Override
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
}

View File

@ -1,61 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractRemoveSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class RemoteRemoveSessionTest extends AbstractRemoveSessionTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
InfinispanTestSessionServer s = new InfinispanTestSessionServer(port, max, scavenge,evictionPolicy, __testSupport.getCache());
return s;
}
@Test
public void testRemoveSession() throws Exception
{
super.testRemoveSession();
}
}

View File

@ -1,69 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractSameNodeLoadTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* SameNodeLoadTest
*
*
*/
public class RemoteSameNodeLoadTest extends AbstractSameNodeLoadTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavenge, int evictionPolicy) throws Exception
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, maxInactive, scavenge,evictionPolicy, __testSupport.getCache());
return server;
}
@Override
public void testLoad() throws Exception
{
super.testLoad();
}
}

View File

@ -20,8 +20,8 @@
package org.eclipse.jetty.server.session.remote;
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -44,11 +44,16 @@ public class RemoteSessionExpiryTest extends AbstractSessionExpiryTest
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
InfinispanTestSessionServer server = new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
return server;
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Test

View File

@ -19,18 +19,18 @@
package org.eclipse.jetty.server.session.remote;
import org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.eclipse.jetty.session.infinispan.InfinispanSessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* SessionInvalidateAndCreateTest
* SessionInvalidateCreateScavengeTest
*
*
*/
public class RemoteSessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
public class RemoteSessionInvalidateCreateScavengeTest extends AbstractSessionInvalidateCreateScavengeTest
{
public static RemoteInfinispanTestSupport __testSupport;
@ -49,13 +49,16 @@ public class RemoteSessionInvalidateAndCreateTest extends AbstractSessionInvalid
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
InfinispanSessionDataStoreFactory factory = new InfinispanSessionDataStoreFactory();
factory.setCache(__testSupport.getCache());
return factory;
}
@Override

View File

@ -1,78 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.remote;
import org.eclipse.jetty.server.session.AbstractSessionRenewTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.InfinispanTestSessionServer;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionRenewTest
*
*
*/
public class RemoteSessionRenewTest extends AbstractSessionRenewTest
{
public static RemoteInfinispanTestSupport __testSupport;
@BeforeClass
public static void setup () throws Exception
{
__testSupport = new RemoteInfinispanTestSupport("remote-session-test");
__testSupport.setup();
}
@AfterClass
public static void teardown () throws Exception
{
__testSupport.teardown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new InfinispanTestSessionServer(port, max, scavenge, evictionPolicy, __testSupport.getCache());
}
@Test
public void testSessionRenewal() throws Exception
{
super.testSessionRenewal();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#verifyChange(WebAppContext, java.lang.String, java.lang.String)
*/
@Override
public boolean verifyChange(WebAppContext context, String oldSessionId, String newSessionId)
{
return !((InfinispanTestSessionServer)_server).exists(context, oldSessionId) && ((InfinispanTestSessionServer)_server).exists(context, newSessionId);
}
}

View File

@ -1,52 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
/**
* ClientCrossContextSessionTest
*
*
*/
public class ClientCrossContextSessionTest extends AbstractClientCrossContextSessionTest
{
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) throws Exception
{
return new JdbcTestServer(port, maxInactive, scavengeInterval, evictionPolicy);
}
@Test
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
}
}

View File

@ -23,16 +23,10 @@ import org.junit.After;
import org.junit.Test;
/**
* InvalidationSessionTest
* ClusteredInvalidationSessionTest
*/
public class InvalidationSessionTest extends AbstractInvalidationSessionTest
public class ClusteredInvalidationSessionTest extends AbstractClusteredInvalidationSessionTest
{
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) throws Exception
{
return new JdbcTestServer(port, maxInactive, scavengeInterval, evictionPolicy);
}
@Test
public void testInvalidation() throws Exception
@ -44,6 +38,16 @@ public class InvalidationSessionTest extends AbstractInvalidationSessionTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return JdbcTestHelper.newSessionDataStoreFactory();
}
}

View File

@ -22,15 +22,18 @@ import org.junit.After;
import org.junit.Test;
/**
* LastAccessTimeTest
* ClusteredLastAccessTimeTest
*/
public class LastAccessTimeTest extends AbstractLastAccessTimeTest
public class ClusteredLastAccessTimeTest extends AbstractClusteredLastAccessTimeTest
{
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new JdbcTestServer(port,max,scavenge, evictionPolicy);
return JdbcTestHelper.newSessionDataStoreFactory();
}
@Test
public void testLastAccessTime() throws Exception
{
@ -40,7 +43,7 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -22,13 +22,17 @@ import org.junit.After;
import org.junit.Test;
/**
* OrphanedSessionTest
* ClusteredOrphanedSessionTest
*/
public class OrphanedSessionTest extends AbstractOrphanedSessionTest
public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest
{
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new JdbcTestServer(port,max,scavenge,evictionPolicy);
return JdbcTestHelper.newSessionDataStoreFactory();
}
@Test
@ -40,6 +44,6 @@ public class OrphanedSessionTest extends AbstractOrphanedSessionTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -22,16 +22,19 @@ import org.junit.After;
import org.junit.Test;
/**
* SessionMigrationTest
* ClusteredSessionMigrationTest
*/
public class SessionMigrationTest extends AbstractSessionMigrationTest
public class ClusteredSessionMigrationTest extends AbstractClusteredSessionMigrationTest
{
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new JdbcTestServer(port, maxInactive, scavengeInterval, evictionPolicy);
return JdbcTestHelper.newSessionDataStoreFactory();
}
@Test
public void testSessionMigration() throws Exception
{
@ -41,6 +44,6 @@ public class SessionMigrationTest extends AbstractSessionMigrationTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -22,9 +22,9 @@ import org.junit.After;
import org.junit.Test;
/**
* LocalSessionScavengingTest
* ClusteredSessionScavengingTest
*/
public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTest
public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest
{
public void pause (int scavenge)
{
@ -43,9 +43,13 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
}
}
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new JdbcTestServer(port,max,scavenge, evictionPolicy);
return JdbcTestHelper.newSessionDataStoreFactory();
}
@Test
@ -65,6 +69,6 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -1,54 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
/**
* ForwardedSessionTest
*
*
*/
public class ForwardedSessionTest extends AbstractForwardedSessionTest
{
@Override
public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) throws Exception
{
return new JdbcTestServer(port, maxInactive, scavengeInterval, evictionPolicy);
}
@Test
public void testSessionCreateInForward() throws Exception
{
super.testSessionCreateInForward();
}
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
}
}

View File

@ -1,55 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.AfterClass;
/**
* ImmediateSaveTest
*
*
*/
public class ImmediateSaveTest extends AbstractImmediateSaveTest
{
JdbcTestServer _server;
@AfterClass
public static void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
}
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
_server = new JdbcTestServer(port, max, scavenge, evictionPolicy)
{
public SessionHandler newSessionHandler()
{
SessionHandler h = super.newSessionHandler();
h.getSessionCache().setSaveOnCreate(true);
return h;
}
};
return _server;
}
}

View File

@ -1,49 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
/**
* ImmortalSessionTest
*
*
*/
public class ImmortalSessionTest extends AbstractImmortalSessionTest
{
public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs, int evictionPolicy) throws Exception
{
return new JdbcTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy);
}
@Test
public void testImmortalSession() throws Exception
{
super.testImmortalSession();
}
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
}
}

View File

@ -30,9 +30,9 @@ import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
/**
* JdbcTestServer
* JdbcTestHelper
*/
public class JdbcTestServer extends AbstractTestServer
public class JdbcTestHelper
{
public static final String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver";
public static final String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true";
@ -79,32 +79,20 @@ public class JdbcTestServer extends AbstractTestServer
}
public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, int idlePassivatePeriod, String connectionUrl) throws Exception
{
super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod);
}
public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, int idlePassivatePeriod) throws Exception
{
super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod);
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestServer#newSessionHandler()
/**
* @return a fresh JDBCSessionDataStoreFactory
*/
@Override
public SessionHandler newSessionHandler()
public static SessionDataStoreFactory newSessionDataStoreFactory()
{
SessionHandler handler = new TestSessionHandler();
DefaultSessionCache sessionStore = new DefaultSessionCache(handler);
handler.setSessionCache(sessionStore);
JDBCSessionDataStore ds = new JDBCSessionDataStore();
sessionStore.setSessionDataStore(ds);
ds.setGracePeriodSec(_scavengePeriod);
JDBCSessionDataStoreFactory factory = new JDBCSessionDataStoreFactory();
DatabaseAdaptor da = new DatabaseAdaptor();
da.setDriverInfo(DRIVER_CLASS, (_config==null?DEFAULT_CONNECTION_URL:(String)_config));
ds.setDatabaseAdaptor(da);
da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL);
factory.setDatabaseAdaptor(da);
JDBCSessionDataStore.SessionTableSchema sessionTableSchema = new JDBCSessionDataStore.SessionTableSchema();
sessionTableSchema.setTableName(TABLE);
sessionTableSchema.setIdColumn(ID_COL);
@ -118,15 +106,15 @@ public class JdbcTestServer extends AbstractTestServer
sessionTableSchema.setLastSavedTimeColumn(LAST_SAVE_COL);
sessionTableSchema.setMapColumn(MAP_COL);
sessionTableSchema.setMaxIntervalColumn(MAX_IDLE_COL);
ds.setSessionTableSchema(sessionTableSchema);
return handler;
factory.setSessionTableSchema(sessionTableSchema);
return factory;
}
public boolean existsInSessionTable(String id, boolean verbose)
public static boolean existsInSessionTable(String id, boolean verbose)
throws Exception
{
Class.forName(DRIVER_CLASS);
@ -160,7 +148,7 @@ public class JdbcTestServer extends AbstractTestServer
public Set<String> getSessionIds ()
public static Set<String> getSessionIds ()
throws Exception
{
HashSet<String> ids = new HashSet<String>();

View File

@ -1,133 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* MaxInactiveMigrationTest
*
* Test
*/
public class MaxInactiveMigrationTest
{
private JdbcTestServer testServer1;
private JdbcTestServer testServer2;
private HttpClient client;
private String sessionCookie;
@Test
public void testFailover() throws Exception {
String response1 = sendRequest( testServer1 );
String response2 = sendRequest( testServer2 );
assertEquals( "Hello World 1", response1 );
assertEquals( "Hello World 2", response2 );
}
@Before
public void setUp() throws Exception {
testServer1 = new JdbcTestServer(0, -1, 2, -1);
testServer2 = new JdbcTestServer(0, -1, 2, -1);
ServletContextHandler context = testServer1.addContext("");
context.addServlet(TestServlet.class, "/test");
ServletContextHandler context2 = testServer2.addContext("");
context2.addServlet(TestServlet.class, "/test");
testServer1.start();
testServer2.start();
client = new HttpClient();
client.start();
}
@After
public void tearDown() throws Exception {
testServer1.stop();
testServer2.stop();
client.stop();
JdbcTestServer.shutdown(null);
}
private String sendRequest( JdbcTestServer server ) throws Exception {
int port=server.getPort();
//Log.getLog().setDebugEnabled(true);
Request request = client.newRequest("http://localhost:" + port + "" + "/test");
if (sessionCookie != null)
request.header("Cookie", sessionCookie);
ContentResponse response = request.send();
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue( sessionCookie != null );
// Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
return response.getContentAsString();
}
public static class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String ATTR_COUNTER = "counter";
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws IOException
{
HttpSession session = request.getSession( true );
Integer counter = ( Integer )session.getAttribute( ATTR_COUNTER );
if( counter == null ) {
counter = 0;
}
counter = counter + 1;
session.setAttribute( ATTR_COUNTER, counter );
PrintWriter writer = response.getWriter();
writer.write( "Hello World " + counter);
writer.flush();
}
public String getServletInfo() {
return "Test Servlet";
}
}
}

View File

@ -16,138 +16,42 @@
// ========================================================================
//
package org.eclipse.jetty.server.session;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.junit.After;
import org.junit.Test;
/**
* ModifyMaxInactiveIntervalTest
*
*
*
*/
public class ModifyMaxInactiveIntervalTest
public class ModifyMaxInactiveIntervalTest extends AbstractModifyMaxInactiveIntervalTest
{
public static int __inactive = 4;
public static int newMaxInactive = 20;
public static int __scavenge = 1;
@Test
public void testSessionExpiryAfterModifiedMaxInactiveInterval() throws Exception
{
AbstractTestServer server = new JdbcTestServer(0,__inactive,__scavenge, SessionCache.NEVER_EVICT);
ServletContextHandler ctxA = server.addContext("/mod");
ctxA.addServlet(TestModServlet.class, "/test");
server.start();
int port=server.getPort();
try
{
HttpClient client = new HttpClient();
client.start();
try
{
// Perform a request to create a session
ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to change the maxinactive interval
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive);
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//wait for longer than the old inactive interval
Thread.currentThread().sleep(10*1000L);
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
finally
{
client.stop();
}
}
finally
{
server.stop();
}
}
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
public static class TestModServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String action = request.getParameter("action");
if ("create".equals(action))
{
HttpSession session = request.getSession(true);
return;
}
if ("change".equals(action))
{
HttpSession session = request.getSession(false);
if (session == null)
throw new ServletException("Session is null for action=change");
String tmp = request.getParameter("val");
int interval = -1;
interval = (tmp==null?-1:Integer.parseInt(tmp));
if (interval > 0)
session.setMaxInactiveInterval(interval);
return;
}
if ("test".equals(action))
{
HttpSession session = request.getSession(false);
if (session == null)
throw new ServletException("Session does not exist");
assertEquals(ModifyMaxInactiveIntervalTest.newMaxInactive, session.getMaxInactiveInterval());
return;
}
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return JdbcTestHelper.newSessionDataStoreFactory();
}
/**
* @see org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest#testSessionExpiryAfterModifiedMaxInactiveInterval()
*/
@Override
public void testSessionExpiryAfterModifiedMaxInactiveInterval() throws Exception
{
super.testSessionExpiryAfterModifiedMaxInactiveInterval();
}
}

View File

@ -22,17 +22,20 @@ import org.junit.After;
import org.junit.Test;
/**
* NewSessionTest
* NonClusteredSessionScavengingTest
*/
public class NewSessionTest extends AbstractNewSessionTest
public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessionScavengingTest
{
/**
* @see org.eclipse.jetty.server.session.AbstractNewSessionTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new JdbcTestServer(port,max,scavenge, evictionPolicy);
return JdbcTestHelper.newSessionDataStoreFactory();
}
@Test
public void testNewSession() throws Exception
@ -43,7 +46,7 @@ public class NewSessionTest extends AbstractNewSessionTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -30,15 +30,17 @@ import org.junit.Test;
*/
public class ProxySerializationTest extends AbstractProxySerializationTest
{
/**
* @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#createServer(int, int, int, int)
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
public SessionDataStoreFactory createSessionDataStoreFactory()
{
return new JdbcTestServer(port, max, scavenge, evictionPolicy);
return JdbcTestHelper.newSessionDataStoreFactory();
}
/**
* @see org.eclipse.jetty.server.session.AbstractProxySerializationTest#customizeContext(org.eclipse.jetty.servlet.ServletContextHandler)
@ -61,6 +63,6 @@ public class ProxySerializationTest extends AbstractProxySerializationTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -1,49 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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.Test;
/**
* ReentrantRequestSessionTest
*/
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) throws Exception
{
return new JdbcTestServer(port,max,scavenge,evictionPolicy);
}
@Test
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
}
}

View File

@ -88,8 +88,12 @@ public class ReloadedSessionMissingClassTest
URLClassLoader loaderWithFoo = new URLClassLoader(foobarUrls, Thread.currentThread().getContextClassLoader());
URLClassLoader loaderWithoutFoo = new URLClassLoader(barUrls, Thread.currentThread().getContextClassLoader());
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT);
SessionDataStoreFactory storeFactory = JdbcTestHelper.newSessionDataStoreFactory();
((AbstractSessionDataStoreFactory)storeFactory).setGracePeriodSec(TestServer.DEFAULT_SCAVENGE_SEC);
AbstractTestServer server1 = new JdbcTestServer(0, AbstractTestServer.DEFAULT_MAX_INACTIVE, AbstractTestServer.DEFAULT_SCAVENGE_SEC, AbstractTestServer.DEFAULT_EVICTIONPOLICY);
TestServer server1 = new TestServer(0, TestServer.DEFAULT_MAX_INACTIVE, TestServer.DEFAULT_SCAVENGE_SEC,cacheFactory, storeFactory);
WebAppContext webApp = server1.addWebAppContext(unpackedWarDir.getCanonicalPath(), contextPath);
webApp.getSessionHandler().getSessionCache().setRemoveUnloadableSessions(true);
@ -148,7 +152,7 @@ public class ReloadedSessionMissingClassTest
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
JdbcTestHelper.shutdown(null);
}
}

View File

@ -1,187 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2016 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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.servlet.ServletHolder;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
/**
* SaveIntervalTest
*
* Checks to see that potentially stale sessions that have not
* changed are not always reloaded from the database.
*
* This test is Ignored because it takes a little while to run.
*
*/
public class SaveIntervalTest
{
public static int INACTIVE = 90; //sec
public static int SCAVENGE = 100; //sec
public static int SAVE = 10; //sec
@Ignore
@Test
public void testSaveInterval() throws Exception
{
AbstractTestServer server = new JdbcTestServer(0,INACTIVE,SCAVENGE, SessionCache.NEVER_EVICT);
ServletContextHandler ctxA = server.addContext("/mod");
ServletHolder holder = new ServletHolder();
TestSaveIntervalServlet servlet = new TestSaveIntervalServlet();
holder.setServlet(servlet);
ctxA.addServlet(holder, "/test");
//TODO set up the intermittent save
server.start();
int port=server.getPort();
try
{
HttpClient client = new HttpClient();
client.start();
try
{
// Perform a request to create a session
ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
long lastSaved = ((Session)servlet._session).getSessionData().getLastSaved();
//do another request to change the session attribute
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=set");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
long tmp = ((Session)servlet._session).getSessionData().getLastSaved();
assertNotEquals(lastSaved, tmp); //set of attribute will cause save to db
lastSaved = tmp;
//do nothing for just a bit longer than the save interval to ensure
//session will be checked against database on next request
Thread.currentThread().sleep((SAVE+2)*1000);
//do another request to access the session, this will cause session to be initially
//checked against db. On exit of request, the access time will need updating, so the
//session will be saved to db.
request = client.newRequest("http://localhost:" + port + "/mod/test?action=tickle");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
tmp = ((Session)servlet._session).getSessionData().getLastSaved();
assertNotEquals(lastSaved, tmp);
lastSaved = tmp;
//wait a little and do another request to access the session
Thread.currentThread().sleep((SAVE/2)*1000);
//do another request to access the session. This time, the save interval has not
//expired, so we should NOT see a debug trace of loading stale session. Nor should
//the exit of the request cause a save of the updated access time.
request = client.newRequest("http://localhost:" + port + "/mod/test?action=tickle");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
tmp = ((Session)servlet._session).getSessionData().getLastSaved();
assertEquals(lastSaved, tmp); //the save interval did not expire, so update to the access time will not have been persisted
}
finally
{
client.stop();
}
}
finally
{
server.stop();
}
}
@After
public void tearDown() throws Exception
{
JdbcTestServer.shutdown(null);
}
public static class TestSaveIntervalServlet extends HttpServlet
{
public HttpSession _session;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String action = request.getParameter("action");
if ("create".equals(action))
{
HttpSession session = request.getSession(true);
_session = session;
return;
}
if ("set".equals(action))
{
HttpSession session = request.getSession(false);
if (session == null)
throw new ServletException("Session is null for action=change");
session.setAttribute("aaa", "12345");
assertEquals(_session.getId(), session.getId());
return;
}
if ("tickle".equals(action))
{
HttpSession session = request.getSession(false);
if (session == null)
throw new ServletException("Session does not exist");
assertEquals(_session.getId(), session.getId());
return;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More