aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/test
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-07-19 13:09:51 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-07-20 19:02:49 +0400
commit5f730dc9ed7a80ad2de100940e051279c2018e1d (patch)
tree1fa0100c6f94fd93d5921a0722ce01dfd3481a96 /sonar-core/src/test
parenta77a5b874799dc15edffe740a3ca34d896813238 (diff)
downloadsonarqube-5f730dc9ed7a80ad2de100940e051279c2018e1d.tar.gz
sonarqube-5f730dc9ed7a80ad2de100940e051279c2018e1d.zip
SONAR-2596,SONAR-2600 Improve notification mechanism
* Persist notifications into DB for later delivery. * Add sonar-email-plugin, which sends notifications by email.
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/notifications/DefaultNotificationManagerTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/notifications/DefaultNotificationManagerTest.java b/sonar-core/src/test/java/org/sonar/core/notifications/DefaultNotificationManagerTest.java
new file mode 100644
index 00000000000..70587fa8493
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/notifications/DefaultNotificationManagerTest.java
@@ -0,0 +1,52 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.notifications;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.notifications.Notification;
+import org.sonar.jpa.entity.NotificationQueueElement;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+public class DefaultNotificationManagerTest extends AbstractDbUnitTestCase {
+
+ private DefaultNotificationManager manager;
+
+ @Before
+ public void setUp() {
+ manager = new DefaultNotificationManager(getSessionFactory());
+ }
+
+ @Test
+ public void shouldPersist() throws Exception {
+ Notification notification = new Notification("test");
+ manager.scheduleForSending(notification);
+
+ NotificationQueueElement queueElement = manager.getFromQueue();
+ assertThat(queueElement.getNotification(), is(notification));
+
+ assertThat(manager.getFromQueue(), nullValue());
+ }
+
+}