summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinService.java2
-rw-r--r--server/src/test/java/com/vaadin/server/VaadinServiceTest.java30
2 files changed, 31 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java
index 80ae39cb35..f9c44f87ba 100644
--- a/server/src/main/java/com/vaadin/server/VaadinService.java
+++ b/server/src/main/java/com/vaadin/server/VaadinService.java
@@ -1935,7 +1935,7 @@ public abstract class VaadinService implements Serializable {
*/
@Deprecated
public void removeServiceDestroyListener(ServiceDestroyListener listener) {
- serviceDestroyListeners.remove(serviceDestroyListeners);
+ serviceDestroyListeners.remove(listener);
}
/**
diff --git a/server/src/test/java/com/vaadin/server/VaadinServiceTest.java b/server/src/test/java/com/vaadin/server/VaadinServiceTest.java
index 59ddaf3e67..7d6cc70146 100644
--- a/server/src/test/java/com/vaadin/server/VaadinServiceTest.java
+++ b/server/src/test/java/com/vaadin/server/VaadinServiceTest.java
@@ -26,6 +26,7 @@ import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
+import com.vaadin.shared.Registration;
import com.vaadin.util.CurrentInstance;
/**
@@ -44,6 +45,17 @@ public class VaadinServiceTest {
}
}
+ private class TestServiceDestroyListener implements ServiceDestroyListener {
+
+ int callCount = 0;
+
+ @Override
+ public void serviceDestroy(ServiceDestroyEvent event) {
+ callCount++;
+ }
+
+ }
+
private String createCriticalNotification(String caption, String message,
String details, String url) {
return VaadinService.createCriticalNotificationJSON(caption, message,
@@ -169,4 +181,22 @@ public class VaadinServiceTest {
return service;
}
+ @Test
+ public void fireServiceDestroy() {
+ VaadinService service = createService();
+ TestServiceDestroyListener listener = new TestServiceDestroyListener();
+ TestServiceDestroyListener listener2 = new TestServiceDestroyListener();
+ service.addServiceDestroyListener(listener);
+ Registration remover2 = service.addServiceDestroyListener(listener2);
+
+ service.destroy();
+ Assert.assertEquals(1, listener.callCount);
+ Assert.assertEquals(1, listener2.callCount);
+ service.removeServiceDestroyListener(listener);
+ remover2.remove();
+
+ service.destroy();
+ Assert.assertEquals(1, listener.callCount);
+ Assert.assertEquals(1, listener2.callCount);
+ }
}