Author: jalkanen
Date: Sun Jun 8 06:06:59 2008
New Revision: 664500
URL: http://svn.apache.org/viewvc?rev=664500&view=rev
Log:
Now checks if there is a SMTP server before failing.
Modified:
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/util/MailUtilTest.java
Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/util/MailUtilTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/util/MailUtilTest.java?rev=664500&r1=664499&r2=664500&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/util/MailUtilTest.java
(original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/util/MailUtilTest.java Sun
Jun 8 06:06:59 2008
@@ -1,8 +1,11 @@
package com.ecyrd.jspwiki.util;
+import java.net.ConnectException;
import java.util.Properties;
+import javax.mail.MessagingException;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -86,8 +89,6 @@
{
m_props.setProperty( "jspwiki.usePageCache", "true" );
-
System.out.println(m_context.getEngine().getWikiProperties().getProperty(MailUtil.PROP_MAIL_ACCOUNT));
-
String user = System.getProperty( "user.name" ) + "@localhost";
try
@@ -97,6 +98,19 @@
"Mail test",
"This is a test mail generated by
MailUtilTest.");
}
+ catch( MessagingException e )
+ {
+ if( e.getCause() instanceof ConnectException )
+ {
+ // This can occur if you do not have a SMTP server set up. We
just log this
+ // and don't fail.
+ System.out.println("I could not test whether mail sending
works, since I could not connect to your SMTP server.");
+ System.out.println("Reason: "+e.getMessage());
+ return;
+ }
+ e.printStackTrace();
+ fail( "Unknown problem (check the console for error report)" );
+ }
catch (Exception e)
{
e.printStackTrace();