Hello mooli tayer,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/24697
to review the following change.
Change subject: tools: notifier: remove SmtpTest.
......................................................................
tools: notifier: remove SmtpTest.
MailSenderTest uses external resources that should not be used for
unit testing. some of which are also not available.
Change-Id: I040014e8afaa19db0b5127fac2712b874806e4b8
Signed-off-by: Mooli Tayer <[email protected]>
---
D
backend/manager/tools/src/test/java/org/ovirt/engine/core/notifier/utils/mail/MailSenderTest.java
D backend/manager/tools/src/test/resources/conf/notifier-mail-test-plain.conf
D backend/manager/tools/src/test/resources/conf/notifier-mail-test-secured.conf
3 files changed, 0 insertions(+), 162 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/97/24697/1
diff --git
a/backend/manager/tools/src/test/java/org/ovirt/engine/core/notifier/utils/mail/MailSenderTest.java
b/backend/manager/tools/src/test/java/org/ovirt/engine/core/notifier/utils/mail/MailSenderTest.java
deleted file mode 100644
index 09e3ae4..0000000
---
a/backend/manager/tools/src/test/java/org/ovirt/engine/core/notifier/utils/mail/MailSenderTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.ovirt.engine.core.notifier.utils.mail;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.ovirt.engine.core.common.businessentities.EventAuditLogSubscriber;
-import org.ovirt.engine.core.notifier.utils.NotificationProperties;
-import org.ovirt.engine.core.notifier.utils.sender.EventSenderResult;
-import org.ovirt.engine.core.notifier.utils.sender.mail.EventSenderMailImpl;
-
-/**
- * A tester of the {@link JavaMailSender}. Tests both secured and non-secured
methods of mail sending as SMTP and SMTP
- * over SSL.
- */
-public class MailSenderTest {
-
- @BeforeClass
- public static void beforeClass() {
- NotificationProperties.release();
- }
-
- /**
- * The test covers sending an email using non-secured mail client (SMTP)
configuration. <br>
- * The test covers the following: <br>
- * <li>Creation of a formatted message
- * <li>Creating a non secured mail client
- * <li>Send an email to the user which contains faked data with HTML body
message
- */
- @Test
- public void testNonSecuredEventMailSender() {
- EventAuditLogSubscriber eventData = new EventAuditLogSubscriber();
- eventData.setlog_time(new Date());
- eventData.setevent_type(0);
- eventData.setuser_name("a test user name");
- eventData.setvm_name("a fine test VM");
- eventData.setvds_name("a fine test host");
- eventData.setmethod_address("[email protected]");
- eventData.setvm_template_name("a test template");
- eventData.setstorage_pool_name("a test storage pool name");
- eventData.setstorage_domain_name("a test storage pool domain");
- eventData.setseverity(3);
-
- NotificationProperties.setDefaults(
- "src/test/resources/conf/notifier-mail-test-plain.conf",
- "src/test/resources/conf/missing.conf"
- );
- EventSenderMailImpl mailSender = new
EventSenderMailImpl(NotificationProperties.getInstance());
- eventData.setmessage("a test message to be sent via non-secured mode");
- EventSenderResult sentResult = null;
- try {
- sentResult = mailSender.send(eventData);
- } catch (Exception e) {
- sentResult = new EventSenderResult();
- sentResult.setSent(false);
- }
- assertTrue(sentResult.isSent());
- }
-
- /**
- * The test covers sending an email using secured mail client (SMTP over
SSL) configuration. <br>
- * The test covers the following: <br>
- * <li>Creation of a formatted message
- * <li>Creating a non secured mail client
- * <li>Send an email to the user which contains faked data as a plan text
message
- */
- @Test
- public void testSecuredEventMailSender() {
- EventAuditLogSubscriber eventData = new EventAuditLogSubscriber();
- eventData.setlog_time(new Date());
- eventData.setevent_type(0);
- eventData.setuser_name("a test user name");
- eventData.setvm_name("a fine test VM");
- eventData.setvds_name("a fine test host");
- eventData.setmethod_address("[email protected]");
- eventData.setvm_template_name("a test template");
- eventData.setstorage_pool_name("a test storage pool name");
- eventData.setstorage_domain_name("a test storage pool domain");
- eventData.setseverity(3);
-
- NotificationProperties.setDefaults(
- "src/test/resources/conf/notifier-mail-test-secured.conf",
- "src/test/resources/conf/missing.conf"
- );
- EventSenderMailImpl mailSender = new
EventSenderMailImpl(NotificationProperties.getInstance());
- eventData.setmessage("a test message to be sent via secured mode");
- mailSender.send(eventData);
-
- EventSenderResult sentResult = null;
- try {
- sentResult = mailSender.send(eventData);
- } catch (Exception e) {
- sentResult = new EventSenderResult();
- sentResult.setSent(false);
- }
-
- assertTrue(sentResult.isSent());
- }
-
- private static Map<String, String> getMailProperties() {
- Map<String, String> prop = new HashMap<String, String>();
- prop.put(NotificationProperties.MAIL_SERVER, "smtp.redhat.com");
- prop.put(NotificationProperties.MAIL_USER, "[email protected]");
- prop.put(NotificationProperties.HTML_MESSAGE_FORMAT, "true");
- prop.put(NotificationProperties.MAIL_SMTP_ENCRYPTION,
NotificationProperties.MAIL_SMTP_ENCRYPTION_NONE);
-
- return prop;
- }
-
- private static Map<String, String> getSecuredMailProperties() {
- Map<String, String> prop = new HashMap<String, String>();
- prop.put(NotificationProperties.MAIL_SERVER, "smtp.gmail.com");
- prop.put(NotificationProperties.MAIL_PORT, "465");
- prop.put(NotificationProperties.MAIL_USER,
"[email protected]");
- prop.put(NotificationProperties.MAIL_PASSWORD, "q1!w2@e3#!");
- prop.put(NotificationProperties.MAIL_FROM, "[email protected]");
- prop.put(NotificationProperties.MAIL_SMTP_ENCRYPTION,
NotificationProperties.MAIL_SMTP_ENCRYPTION_SSL);
- return prop;
- }
-
-}
diff --git
a/backend/manager/tools/src/test/resources/conf/notifier-mail-test-plain.conf
b/backend/manager/tools/src/test/resources/conf/notifier-mail-test-plain.conf
deleted file mode 100644
index 6b6e2b2..0000000
---
a/backend/manager/tools/src/test/resources/conf/notifier-mail-test-plain.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-# Notification settings
-INTERVAL_IN_SECONDS=60
-
-# Engine server monitor settings
-ENGINE_INTERVAL_IN_SECONDS=300
-ENGINE_TIMEOUT_IN_SECONDS=30
-
-# Days to keep history in the event_notification_history table
-DAYS_TO_KEEP_HISTORY=30
-
-# oVirt lib location
-engineLib=/usr/local/jboss-eap-5.1/jboss-as/server/default/deploy/engine.ear/lib
-
-MAIL_SERVER=smtp.redhat.com
-MAIL_PORT=25
[email protected]
-HTML_MESSAGE_FORMAT=true
-MAIL_SMTP_ENCRYPTION=none
diff --git
a/backend/manager/tools/src/test/resources/conf/notifier-mail-test-secured.conf
b/backend/manager/tools/src/test/resources/conf/notifier-mail-test-secured.conf
deleted file mode 100644
index 34d234a..0000000
---
a/backend/manager/tools/src/test/resources/conf/notifier-mail-test-secured.conf
+++ /dev/null
@@ -1,19 +0,0 @@
-# Notification settings
-INTERVAL_IN_SECONDS=60
-
-# Engine server monitor settings
-ENGINE_INTERVAL_IN_SECONDS=300
-ENGINE_TIMEOUT_IN_SECONDS=30
-
-# Days to keep history in the event_notification_history table
-DAYS_TO_KEEP_HISTORY=30
-
-# oVirt lib location
-engineLib=/usr/local/jboss-eap-5.1/jboss-as/server/default/deploy/engine.ear/lib
-
-MAIL_SERVER=smtp.gmail.com
-MAIL_PORT=465
[email protected]
-MAIL_PASSWORD="q1!w2@e3#!"
[email protected]
-MAIL_SMTP_ENCRYPTION=ssl
--
To view, visit http://gerrit.ovirt.org/24697
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I040014e8afaa19db0b5127fac2712b874806e4b8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: mooli tayer <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches