-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement findSessions() and return all sessions in the cluster. (#40)
Fixes #39
- Loading branch information
1 parent
bb88c37
commit 2c09b20
Showing
17 changed files
with
286 additions
and
15 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
tomcat-core/src/test/java/com/hazelcast/session/AbstractSessionExpireTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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) | ||
.configLocation("hazelcast-1.xml") | ||
.start(); | ||
|
||
instance2 = getWebContainerConfigurator(); | ||
instance2.port(SERVER_PORT_2) | ||
.sticky(true) | ||
.clientOnly(false) | ||
.mapName(SESSION_REPLICATION_MAP_NAME) | ||
.sessionTimeout(SESSION_TIMEOUT_IN_MINUTES) | ||
.configLocation("hazelcast-2.xml") | ||
.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()); | ||
|
||
instance2.stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tomcat6/src/test/java/com/hazelcast/session/Tomcat6SessionExpireTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.hazelcast.session; | ||
|
||
import com.hazelcast.test.HazelcastSerialClassRunner; | ||
import com.hazelcast.test.annotation.QuickTest; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(HazelcastSerialClassRunner.class) | ||
@Category(QuickTest.class) | ||
public class Tomcat6SessionExpireTest extends AbstractSessionExpireTest { | ||
@Override | ||
protected WebContainerConfigurator<?> getWebContainerConfigurator() { | ||
return new Tomcat6Configurator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tomcat7/src/test/java/com/hazelcast/session/Tomcat7SessionExpireTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.hazelcast.session; | ||
|
||
import com.hazelcast.test.HazelcastSerialClassRunner; | ||
import com.hazelcast.test.annotation.QuickTest; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(HazelcastSerialClassRunner.class) | ||
@Category(QuickTest.class) | ||
public class Tomcat7SessionExpireTest extends AbstractSessionExpireTest { | ||
@Override | ||
protected WebContainerConfigurator<?> getWebContainerConfigurator() { | ||
return new Tomcat7Configurator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tomcat8/src/test/java/com/hazelcast/session/Tomcat8SessionExpireTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.hazelcast.session; | ||
|
||
import com.hazelcast.test.HazelcastSerialClassRunner; | ||
import com.hazelcast.test.annotation.QuickTest; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(HazelcastSerialClassRunner.class) | ||
@Category(QuickTest.class) | ||
public class Tomcat8SessionExpireTest extends AbstractSessionExpireTest { | ||
@Override | ||
protected WebContainerConfigurator<?> getWebContainerConfigurator() { | ||
return new Tomcat8Configurator(); | ||
} | ||
} |
Oops, something went wrong.