ensure we really use only client test

Signed-off-by: olivier lamy <olamy@webtide.com>

use a randomized map name to store sessions in order to avoid conflicts

Signed-off-by: olivier lamy <olamy@webtide.com>

reduce hazelcast logging noise

Signed-off-by: olivier lamy <olamy@webtide.com>

clarify onlyClient mode

Signed-off-by: olivier lamy <olamy@webtide.com>
This commit is contained in:
olivier lamy 2017-12-13 22:09:54 +11:00 committed by Greg Wilkins
parent 005ae95bea
commit 696b60a541
20 changed files with 139 additions and 17 deletions

View File

@ -121,6 +121,11 @@ public class HazelcastSessionDataStoreFactory
return onlyClient;
}
/**
*
* @param onlyClient if <code>true</code> the session manager will only connect to an external Hazelcast instance
* and not use this JVM to start an Hazelcast instance
*/
public void setOnlyClient( boolean onlyClient )
{
this.onlyClient = onlyClient;

View File

@ -49,6 +49,15 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.util.logging.config.file>${project.build.testOutputDirectory}/logging.properties</java.util.logging.config.file>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
@ -88,7 +97,6 @@
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -20,19 +20,29 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
public class ClusteredLastAccessTimeTest
extends AbstractClusteredLastAccessTimeTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractClusteredOrphanedSessionTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
/**
* ClusteredOrphanedSessionTest
@ -29,6 +30,7 @@ public class ClusteredOrphanedSessionTest
extends AbstractClusteredOrphanedSessionTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
@ -36,9 +38,14 @@ public class ClusteredOrphanedSessionTest
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
/**
* ClusteredSessionMigrationTest
@ -28,6 +29,7 @@ import org.eclipse.jetty.server.session.SessionDataStoreFactory;
public class ClusteredSessionMigrationTest
extends AbstractClusteredSessionMigrationTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
@ -35,7 +37,14 @@ public class ClusteredSessionMigrationTest
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
/**
* ClusteredSessionScavengingTest
@ -29,13 +30,22 @@ public class ClusteredSessionScavengingTest
extends AbstractClusteredSessionScavengingTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
/**
* ModifyMaxInactiveIntervalTest
@ -29,14 +30,23 @@ public class ModifyMaxInactiveIntervalTest
extends AbstractModifyMaxInactiveIntervalTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractNonClusteredSessionScavengingTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
import static org.junit.Assert.*;
@ -31,6 +32,8 @@ public class NonClusteredSessionScavengingTest
extends AbstractNonClusteredSessionScavengingTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractNonClusteredSessionScavengingTest#assertSession(java.lang.String, boolean)
*/
@ -63,7 +66,14 @@ public class NonClusteredSessionScavengingTest
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,20 +21,30 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
import org.junit.Test;
public class SessionExpiryTest
extends AbstractSessionExpiryTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.hazelcast.session;
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
/**
* SessionInvalidateCreateScavengeTest
@ -29,13 +30,22 @@ public class SessionInvalidateCreateScavengeTest
extends AbstractSessionInvalidateCreateScavengeTest
{
HazelcastSessionDataStoreFactory factory;
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@Override
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory = new HazelcastSessionDataStoreFactory();
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
return factory;
}
@After
public void shutdown()
{
factory.getHazelcastInstance().getMap( factory.getMapName() ).clear();
}
}

View File

@ -32,7 +32,7 @@ public class ClientLastAccessTimeTest
extends AbstractClusteredLastAccessTimeTest
{
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -19,9 +19,15 @@
package org.eclipse.jetty.hazelcast.session.client;
import com.hazelcast.config.Config;
import com.hazelcast.config.MapConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
import org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest;
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.After;
import org.junit.Before;
/**
* ModifyMaxInactiveIntervalTest
@ -30,6 +36,27 @@ public class ClientModifyMaxInactiveIntervalTest
extends AbstractModifyMaxInactiveIntervalTest
{
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;
@Before
public void startHazelcast()
throws Exception
{
Config config = new Config().addMapConfig( new MapConfig().setName( MAP_NAME ) ) //
.setInstanceName( "beer" );
// start Hazelcast instance
hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance( config );
}
@After
public void stopHazelcast()
throws Exception
{
hazelcastInstance.shutdown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractTestBase#createSessionDataStoreFactory()
*/
@ -37,6 +64,8 @@ public class ClientModifyMaxInactiveIntervalTest
public SessionDataStoreFactory createSessionDataStoreFactory()
{
HazelcastSessionDataStoreFactory factory = new HazelcastSessionDataStoreFactory();
factory.setOnlyClient( true );
factory.setMapName( MAP_NAME );
return factory;
}

View File

@ -60,7 +60,7 @@ public class ClientNonClusteredSessionScavengingTest
fail( e.getMessage() );
}
}
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -33,7 +33,7 @@ public class ClientOrphanedSessionTest
extends AbstractClusteredOrphanedSessionTest
{
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -33,7 +33,7 @@ public class ClientSessionExpiryTest
extends AbstractSessionExpiryTest
{
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -32,7 +32,7 @@ import org.junit.Before;
public class ClientSessionInvalidateCreateScavengeTest
extends AbstractSessionInvalidateCreateScavengeTest
{
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -35,7 +35,7 @@ import org.junit.Before;
public class ClientSessionMigrationTest
extends AbstractClusteredSessionMigrationTest
{
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -33,7 +33,7 @@ public class ClientSessionScavengingTest
extends AbstractClusteredSessionScavengingTest
{
private static final String MAP_NAME = "jetty_foo_session";
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
private HazelcastInstance hazelcastInstance;

View File

@ -0,0 +1 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog

View File

@ -0,0 +1,3 @@
handlers=java.util.logging.ConsoleHandler
.level=INFO
com.hazelcast.level=SEVERE