[jboss-svn-commits] JBL Code SVN: r5376 - in labs/jbossesb/trunk/product/core/common: src/org/jboss/soa/esb/notification tests/src/org/jboss/soa/esb/notification
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 1 07:55:23 EDT 2006
Author: tfennelly
Date: 2006-08-01 07:55:18 -0400 (Tue, 01 Aug 2006)
New Revision: 5376
Added:
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotifyEmailUnitTest.java
Modified:
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java
Log:
added tests for NotifyEmail
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java 2006-08-01 11:32:34 UTC (rev 5375)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java 2006-08-01 11:55:18 UTC (rev 5376)
@@ -24,6 +24,7 @@
import java.io.Serializable;
+import javax.mail.MessagingException;
import javax.mail.internet.*;
import org.jboss.soa.esb.helpers.*;
@@ -79,14 +80,9 @@
try {
DomElement oP = m_oParms.cloneObj();
String sMsg = oP.getAttr(EsbEmail.MESSAGE);
- sMsg = ((null == sMsg) ? p_o.toString() : sMsg + "\n")
- + p_o.toString();
- // HB added line for debugging
- // System.out.println("Sending Email Notification ->" +sMsg );
-
+ sMsg = ((null == sMsg) ? p_o.toString() : sMsg + "\n") + p_o.toString();
oP.setAttr(EsbEmail.MESSAGE, sMsg);
- EsbEmail esbMail = new EsbEmail(oP);
- esbMail.sendMessage();
+ sendEmailNotification(oP);
} catch (Exception e) {
EsbUtil.getDefaultLogger(this.getClass()).error("Send Mail Failed",
e);
@@ -94,4 +90,15 @@
}
} // __________________________________
+ /**
+ * Send an email notification based on the supplied parameters.
+ * <p/>
+ * This method allows overriding for test purposes.
+ * @param messageParams Message parameters.
+ */
+ protected void sendEmailNotification(DomElement messageParams) throws AddressException, MessagingException {
+ EsbEmail esbMail = new EsbEmail(messageParams);
+ esbMail.sendMessage();
+ }
+
} // ____________________________________________________________________________
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotifyEmailUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotifyEmailUnitTest.java 2006-08-01 11:32:34 UTC (rev 5375)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotifyEmailUnitTest.java 2006-08-01 11:55:18 UTC (rev 5376)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.notification;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+
+import org.jboss.soa.esb.helpers.DomElement;
+import org.jboss.soa.esb.helpers.EsbEmail;
+
+import junit.framework.TestCase;
+
+/**
+ * NotifyEmail unit tests.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class NotifyEmailUnitTest extends TestCase {
+
+ public void test_NotifyEmail() throws Exception {
+ DomElement emailMessageEl = new DomElement("email");
+
+ emailMessageEl.setAttr(EsbEmail.FROM, "a.b at c.com");
+ emailMessageEl.setAttr(EsbEmail.SENDTO, "d.e at f.com");
+ emailMessageEl.setAttr(EsbEmail.COPYTO, "g.h at i.com");
+ emailMessageEl.setAttr(EsbEmail.MESSAGE, "Hi there!!!");
+
+ NotifyEmail ne = new TestNotifyEmail(emailMessageEl);
+ ne.sendNotification("Hello");
+ }
+
+ private class TestNotifyEmail extends NotifyEmail {
+ public TestNotifyEmail(DomElement p_oP) throws Exception {
+ super(p_oP);
+ }
+ protected void sendEmailNotification(DomElement messageParams) throws AddressException, MessagingException {
+ assertEquals("Hi there!!!\nHello", messageParams.getAttr(EsbEmail.MESSAGE));
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list