summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2014-04-07 15:00:49 +0300
committerVaadin Code Review <review@vaadin.com>2014-04-10 11:18:20 +0000
commit55dfd2936a1680f444be8e7357ac4ceaa6870e23 (patch)
tree67c1e78ede4ee2c4221514adf39edc442c63955f /server/tests
parent2067d4e01045fa4ca1d512322d6442499d6aded0 (diff)
downloadvaadin-framework-55dfd2936a1680f444be8e7357ac4ceaa6870e23.tar.gz
vaadin-framework-55dfd2936a1680f444be8e7357ac4ceaa6870e23.zip
Prevent duplicate session destroy events (#12612)
Change-Id: Ic752268a9deac350dbff29ecf73cfce2eb1ba0cc
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServiceTest.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/server/tests/src/com/vaadin/server/VaadinServiceTest.java b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
index cead5df79c..77eb155378 100644
--- a/server/tests/src/com/vaadin/server/VaadinServiceTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
@@ -29,6 +29,16 @@ import org.junit.Test;
*/
public class VaadinServiceTest {
+ private class TestSessionDestroyListener implements SessionDestroyListener {
+
+ int callCount = 0;
+
+ @Override
+ public void sessionDestroy(SessionDestroyEvent event) {
+ callCount++;
+ }
+ }
+
@Test
public void testFireSessionDestroy() throws ServletException {
ServletConfig servletConfig = new MockServletConfig();
@@ -36,6 +46,10 @@ public class VaadinServiceTest {
servlet.init(servletConfig);
VaadinService service = servlet.getService();
+ TestSessionDestroyListener listener = new TestSessionDestroyListener();
+
+ service.addSessionDestroyListener(listener);
+
MockVaadinSession vaadinSession = new MockVaadinSession(service);
service.fireSessionDestroy(vaadinSession);
Assert.assertEquals(
@@ -45,9 +59,11 @@ public class VaadinServiceTest {
vaadinSession.valueUnbound(EasyMock
.createMock(HttpSessionBindingEvent.class));
- org.junit.Assert.assertEquals(
- "'fireSessionDestroy' method may not call 'close' "
- + "method for closing session", 1,
+ Assert.assertEquals("'fireSessionDestroy' method may not call 'close' "
+ + "method for closing session", 1,
vaadinSession.getCloseCount());
+
+ Assert.assertEquals("SessionDestroyListeners not called exactly once",
+ 1, listener.callCount);
}
}