-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement findSessions() and return all sessions in the cluster. #40
Changes from 2 commits
bdcd77d
5a34e60
4bea649
5444239
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.hazelcast.session; | ||
|
||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import org.apache.http.client.CookieStore; | ||
import org.apache.http.impl.client.BasicCookieStore; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public abstract class AbstractSessionExpireTest extends AbstractHazelcastSessionsTest { | ||
|
||
@Test | ||
public void testSessionExpireAfterFailoverAndSessionTimeout() throws Exception { | ||
final int SESSION_TIMEOUT_IN_MINUTES = 1; | ||
final int EXTRA_DELAY_IN_SECONDS = 5; | ||
|
||
instance1 = getWebContainerConfigurator(); | ||
instance1.port(SERVER_PORT_1).sticky(true).clientOnly(false).mapName(SESSION_REPLICATION_MAP_NAME).sessionTimeout(SESSION_TIMEOUT_IN_MINUTES).start(); | ||
instance2 = getWebContainerConfigurator(); | ||
instance2.port(SERVER_PORT_2).sticky(true).clientOnly(false).mapName(SESSION_REPLICATION_MAP_NAME).sessionTimeout(SESSION_TIMEOUT_IN_MINUTES).start(); | ||
|
||
CookieStore cookieStore = new BasicCookieStore(); | ||
executeRequest("write", SERVER_PORT_1, cookieStore); | ||
String value = executeRequest("read", SERVER_PORT_1, cookieStore); | ||
assertEquals("value", value); | ||
|
||
instance1.stop(); | ||
|
||
HazelcastInstance hzInstance1 = Hazelcast.getHazelcastInstanceByName("hzInstance1"); | ||
if (hzInstance1 != null) { | ||
hzInstance1.shutdown(); | ||
} | ||
|
||
|
||
sleepSeconds(SESSION_TIMEOUT_IN_MINUTES * 60 + EXTRA_DELAY_IN_SECONDS); | ||
|
||
assertEquals(0, instance2.getManager().getDistributedMap().size()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.hazelcast.session; | ||
|
||
public class Tomcat6SessionExpireTest extends AbstractSessionExpireTest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also please add the following annotations to all the concrete test classes you add?
When I add those, it complains not all instances are stopped after a test, could you please make sure all Hazelcast instances are stopped after a test as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
@Override | ||
protected WebContainerConfigurator<?> getWebContainerConfigurator() { | ||
return new Tomcat6Configurator(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.hazelcast.session; | ||
|
||
public class Tomcat7SessionExpireTest extends AbstractSessionExpireTest { | ||
@Override | ||
protected WebContainerConfigurator<?> getWebContainerConfigurator() { | ||
return new Tomcat7Configurator(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import com.hazelcast.session.AbstractSessionExpireTest; | ||
import com.hazelcast.session.Tomcat8Configurator; | ||
import com.hazelcast.session.WebContainerConfigurator; | ||
|
||
public class Tomcat8SessionExpireTest extends AbstractSessionExpireTest { | ||
@Override | ||
protected WebContainerConfigurator<?> getWebContainerConfigurator() { | ||
return new Tomcat8Configurator(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nicer to read if you put those calls on separate lines, similar to here. Also, you should add
.configLocation("hazelcast-1.xml")
and.configLocation("hazelcast-2.xml")
respectively to the instances.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.