You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sg...@apache.org on 2010/10/27 15:36:55 UTC

svn commit: r1027955 - in /commons/proper/email/trunk/src: java/org/apache/commons/mail/ImageHtmlEmail.java test/attachments/download_email.cgi.html test/html/www.apache.org.html test/org/apache/commons/mail/ImageHtmlEmailTest.java

Author: sgoeschl
Date: Wed Oct 27 13:36:54 2010
New Revision: 1027955

URL: http://svn.apache.org/viewvc?rev=1027955&view=rev
Log:
Cleaning up the tests - resource fetching og ImageHtmlEmail tests are done now lenient to work without internet access.

Modified:
    commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java
    commons/proper/email/trunk/src/test/attachments/download_email.cgi.html
    commons/proper/email/trunk/src/test/html/www.apache.org.html
    commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java

Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java?rev=1027955&r1=1027954&r2=1027955&view=diff
==============================================================================
--- commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java (original)
+++ commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java Wed Oct 27 13:36:54 2010
@@ -77,6 +77,20 @@ public class ImageHtmlEmail extends Html
     public HtmlEmail setHtmlMsg(final String htmlMessage)
             throws EmailException
     {
+        return setHtmlMsg(htmlMessage, false);
+    }
+
+    /**
+     * Set the HTML message and try to add any image that is linked in the HTML
+     * source.
+     *
+     * @param htmlMessage the HTML message
+     * @return An HtmlEmail.
+     * @throws EmailException assembling the email failed
+     */
+    public HtmlEmail setHtmlMsg(final String htmlMessage, boolean isLenient)
+            throws EmailException
+    {
         URL currentWorkingDirectoryUrl;
 
         try
@@ -88,7 +102,7 @@ public class ImageHtmlEmail extends Html
             throw new EmailException("Unable to create URL for current working directory", e);
         }
 
-        return setHtmlMsg(htmlMessage, currentWorkingDirectoryUrl, false);
+        return setHtmlMsg(htmlMessage, currentWorkingDirectoryUrl, isLenient);
     }
 
     /**

Modified: commons/proper/email/trunk/src/test/attachments/download_email.cgi.html
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/attachments/download_email.cgi.html?rev=1027955&r1=1027954&r2=1027955&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/attachments/download_email.cgi.html (original)
+++ commons/proper/email/trunk/src/test/attachments/download_email.cgi.html Wed Oct 27 13:36:54 2010
@@ -43,7 +43,7 @@
 
  <td>
  <a href="http://commons.apache.org">
- <img border="0" name="organization-logo" alt="The Apache Software Foundation" src="asf_logo_wide.gif" align="left"></img> <img src="http://dstadler.org/mambo2/templates/jo_beetle_adjusted/images/beetle2.jpg"/>
+ <img border="0" name="organization-logo" alt="The Apache Software Foundation" src="asf_logo_wide.gif" align="left"></img> <img src="http://www.apache.org/images/asf_logo_wide.gif"/>
  </a>
 
  </td>

Modified: commons/proper/email/trunk/src/test/html/www.apache.org.html
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/html/www.apache.org.html?rev=1027955&r1=1027954&r2=1027955&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/html/www.apache.org.html (original)
+++ commons/proper/email/trunk/src/test/html/www.apache.org.html Wed Oct 27 13:36:54 2010
@@ -260,7 +260,6 @@ href="/foundation/getinvolved.html">Get 
       </ul>
       <h6></h6>
   <ul>
-          <li style="margin-left: -1em;list-style-type: none"><a href="http://www.apachecon.com/" alt="ApacheCon" title="Official Apache Conference"><img style="border: 0; padding: 0" src="http://www.apache.org/events/current-event-125x125.png" /></a></li> 
       </ul>
         </div>
       </div>

Modified: commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java?rev=1027955&r1=1027954&r2=1027955&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java (original)
+++ commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java Wed Oct 27 13:36:54 2010
@@ -38,6 +38,7 @@ import org.subethamail.wiser.WiserMessag
 
 public class ImageHtmlEmailTest extends HtmlEmailTest {
 
+    private static final boolean TEST_IS_LENIENT = true;
     private static final URL TEST_IMAGE_URL = ImageHtmlEmailTest.class.getResource("/images/asf_logo_wide.gif");    
     private static final File TEST_IMAGE_DIR = new File(TEST_IMAGE_URL.getPath()).getParentFile();
     private static final URL TEST_HTML_URL = ImageHtmlEmailTest.class.getResource("/attachments/download_email.cgi.html");
@@ -58,7 +59,7 @@ public class ImageHtmlEmailTest extends 
 		email = new MockImageHtmlEmailConcrete();
 	}
 
-	public void testSendHTML() throws Exception {
+	public void testSendHtml() throws Exception {
 
 		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
 
@@ -89,7 +90,7 @@ public class ImageHtmlEmailTest extends 
 		String html = str.toString();
 
 		// set the html message
-		email.setHtmlMsg(html, TEST_IMAGE_DIR.toURI().toURL(), false);
+		email.setHtmlMsg(html, TEST_IMAGE_DIR.toURI().toURL(), TEST_IS_LENIENT);
 
 		// set the alternative message
 		//email.setTextMsg("Your email client does not support HTML messages");
@@ -128,7 +129,7 @@ public class ImageHtmlEmailTest extends 
 
 		// set the html message
 		try {
-			email.setHtmlMsg(null, new File("/tmp").toURI().toURL(), false);
+			email.setHtmlMsg(null, new File("/tmp").toURI().toURL(), TEST_IS_LENIENT);
 			fail("Should fail here!");
 		} catch (EmailException e) {
 			assertTrue(e.getMessage(), e.getMessage().contains(
@@ -144,7 +145,7 @@ public class ImageHtmlEmailTest extends 
 
 		// set the html message
 		try {
-			email.setHtmlMsg("", new File("/tmp").toURI().toURL(), false);
+			email.setHtmlMsg("", new File("/tmp").toURI().toURL(), TEST_IS_LENIENT);
 			fail("Should fail here!");
 		} catch (EmailException e) {
 			assertTrue(e.getMessage(), e.getMessage().contains(
@@ -153,7 +154,7 @@ public class ImageHtmlEmailTest extends 
 
 	}
 
-	public void testSendHTMLURL() throws Exception {
+	public void testSendHtmlUrl() throws Exception {
 		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
 
 		getMailServer();
@@ -169,7 +170,10 @@ public class ImageHtmlEmailTest extends 
 		email.setSubject(strSubject);
 
 		// set the html message
-		email.setHtmlMsg("<html><body><img src=\"http://dstadler.org/mambo2/templates/jo_beetle_adjusted/images/beetle2.jpg\"/></body></html>");
+		email.setHtmlMsg(
+            "<html><body><img src=\"http://www.apache.org/images/feather.gif\"/></body></html>",
+            TEST_IS_LENIENT
+            );
 
 		// send the email
 		email.send();
@@ -203,7 +207,7 @@ public class ImageHtmlEmailTest extends 
 
 		// set the html message
 		email.setHtmlMsg("<html><body><img src=\"" + file.getAbsolutePath()
-				+ "\"/></body></html>", new File("").toURI().toURL(), false);
+				+ "\"/></body></html>", new File("").toURI().toURL(), TEST_IS_LENIENT);
 
 		// send the email
 		email.send();