commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgoes...@apache.org
Subject svn commit: r961524 - in /commons/proper/email/trunk: ./ src/changes/ src/java/org/apache/commons/mail/ src/java/org/apache/commons/mail/impl/ src/test/attachments/ src/test/html/ src/test/images/logos/ src/test/org/apache/commons/mail/ src/test/org/ap...
Date Wed, 07 Jul 2010 22:26:20 GMT
Author: sgoeschl
Date: Wed Jul  7 22:26:19 2010
New Revision: 961524

URL: http://svn.apache.org/viewvc?rev=961524&view=rev
Log:
[EMAIL-92] Adding ImageHtmlEmail to automatically embed images into an HTML email.

Added:
    commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java
    commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/
    commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/URLFactory.java
    commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/package.html
      - copied, changed from r960092, commons/proper/email/trunk/src/java/org/apache/commons/mail/package.html
    commons/proper/email/trunk/src/test/attachments/download_email.cgi.html
    commons/proper/email/trunk/src/test/html/
    commons/proper/email/trunk/src/test/html/www.apache.org.html
    commons/proper/email/trunk/src/test/images/logos/
    commons/proper/email/trunk/src/test/images/logos/maven-feather.png   (with props)
    commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java
    commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java
Modified:
    commons/proper/email/trunk/pom.xml
    commons/proper/email/trunk/src/changes/changes.xml
    commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailAttachment.java
    commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java
    commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailLiveTest.java

Modified: commons/proper/email/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/pom.xml?rev=961524&r1=961523&r2=961524&view=diff
==============================================================================
--- commons/proper/email/trunk/pom.xml (original)
+++ commons/proper/email/trunk/pom.xml Wed Jul  7 22:26:19 2010
@@ -185,6 +185,9 @@
         <contributor>
             <name>Cedrik Lime</name>
         </contributor>
+        <contributor>
+            <name>Dominik Stadler</name>
+        </contributor>
     </contributors>
 
     <dependencies>
@@ -192,13 +195,11 @@
             <groupId>javax.mail</groupId>
             <artifactId>mail</artifactId>
             <version>1.4.1</version>
-            <!--<url>http://java.sun.com/products/javamail/</url>-->
         </dependency>
         <dependency>
             <groupId>javax.activation</groupId>
             <artifactId>activation</artifactId>
             <version>1.1</version>
-            <!--<url>http://java.sun.com/products/javabeans/glasgow/jaf.html</url>-->
         </dependency>
         <dependency>
             <groupId>junit</groupId>
@@ -207,6 +208,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>net.sf.retrotranslator</groupId>
             <artifactId>retrotranslator-runtime</artifactId>
             <version>1.2.1</version>
@@ -380,4 +387,4 @@
             </distributionManagement>
         </profile>
     </profiles>
-</project>
\ No newline at end of file
+</project>

Modified: commons/proper/email/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/changes/changes.xml?rev=961524&r1=961523&r2=961524&view=diff
==============================================================================
--- commons/proper/email/trunk/src/changes/changes.xml (original)
+++ commons/proper/email/trunk/src/changes/changes.xml Wed Jul  7 22:26:19 2010
@@ -23,6 +23,10 @@
 
   <body>
     <release version="1.3-SNAPSHOT" date="as in SVN">
+      <action dev="sgoeschl" type="fix" issue="EMAIL-92" date="2010-06-08" due-to="Dominik Stadler">
+        Adding ImageHtmlEmail to create HTML emails with embedded images either
+        downloaded from HTTP or from the local file system.
+      </action>
       <action dev="sgoeschl" type="fix" issue="EMAIL-95" date="2010-05-13">
        Calling buildMimeMessage() before invoking send() caused
        duplicated mime parts for HtmlEmail. The implementation now enforces

Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailAttachment.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailAttachment.java?rev=961524&r1=961523&r2=961524&view=diff
==============================================================================
--- commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailAttachment.java (original)
+++ commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailAttachment.java Wed Jul  7 22:26:19 2010
@@ -19,7 +19,7 @@ package org.apache.commons.mail;
 import java.net.URL;
 
 /**
- * This class models an email attachment.  Used by MultiPartEmail.
+ * This class models an email attachment. Used by MultiPartEmail.
  *
  * @since 1.0
  * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
@@ -29,6 +29,7 @@ public class EmailAttachment
 {
     /** Definition of the part being an attachment */
     public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
+
     /** Definition of the part being inline */
     public static final String INLINE = javax.mail.Part.INLINE;
 

Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java?rev=961524&r1=961523&r2=961524&view=diff
==============================================================================
--- commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java (original)
+++ commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java Wed Jul  7 22:26:19 2010
@@ -246,7 +246,7 @@ final class EmailUtils
 
         if (resultFile == null)
         {
-            throw new IllegalArgumentException("resulFile is null");
+            throw new IllegalArgumentException("resultFile is null");
         }
 
         if (resultFile.getParentFile() != null)

Added: 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=961524&view=auto
==============================================================================
--- commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java (added)
+++ commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java Wed Jul  7 22:26:19 2010
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.mail;
+
+import org.apache.commons.mail.impl.URLFactory;
+
+import javax.activation.DataSource;
+import javax.activation.URLDataSource;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Small wrapper class on top of HtmlEmail which encapsulates the required logic
+ * to retrieve images that are contained in "<img src=../>" elements in the HTML
+ * code. This is done by replacing all img-src-elements with "cid:"-entries and
+ * embedding images in the email.
+ *
+ * For local files the class tries to either load them via an absolute path or -
+ * if available - use a relative path starting from a base directory.For files
+ * that are not found locally, the implementation tries to download
+ * the element and link it in.
+ *
+ * This code was submitted to commons-email under the Apache 2.0 license, see
+ * https://issues.apache.org/jira/browse/EMAIL-92
+ *
+ */
+public class ImageHtmlEmail extends HtmlEmail
+{
+    /**
+     * Regular Expression to find all <IMG SRC="..."> entries in an HTML
+     * document.
+     *
+     * It needs to cater for various things, like more whitespaces including
+     * newlines on any place, HTML is not case sensitive and there can be
+     * arbitrary text between "IMG" and "SRC" like IDs and other things.
+     */
+    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
+
+    public static final String REGEX_SCRIPT_SRC = "(<[Ss][Cc][Rr][Ii][Pp][Tt]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
+
+    // this pattern looks for the HTML-img tag which indicates embedded images,
+    // the grouping is necessary to allow to replace the element with the CID
+    protected static final Pattern pattern = Pattern.compile(REGEX_IMG_SRC);
+
+    protected static final Pattern scriptPattern = Pattern.compile(REGEX_SCRIPT_SRC);
+
+    /**
+     * 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)
+            throws EmailException
+    {
+        URL currentWorkingDirectoryUrl;
+
+        try
+        {
+            currentWorkingDirectoryUrl = new File("").toURI().toURL();
+        }
+        catch (MalformedURLException e)
+        {
+            throw new EmailException("Unable to create URL for current working directory", e);
+        }
+
+        return setHtmlMsg(htmlMessage, currentWorkingDirectoryUrl);
+    }
+
+    /**
+     * Set the HTML content and try to add any image that is linked in the HTML
+     * source.  The 'baseUrl' is either a "http://..." or a "file://" in order
+     * to resolve relative image resources.
+     *
+     * @param htmlMessage the HTML message.
+     * @param baseUrl An base URL that is used as starting point for resolving images that are embedded in the HTML
+     * @return An HtmlEmail
+     * @throws EmailException creating the email failed
+     */
+    public HtmlEmail setHtmlMsg(final String htmlMessage, final URL baseUrl)
+            throws EmailException
+    {
+        // if there is no useful HTML then simply route it through to the super class
+        if (htmlMessage == null || htmlMessage.isEmpty())
+        {
+            return super.setHtmlMsg(htmlMessage);
+        }
+
+        // replace images
+        String temp = replacePattern(htmlMessage, pattern, baseUrl);
+
+        // replace scripts
+        temp = replacePattern(temp, scriptPattern, baseUrl);
+
+        // finally set the resulting HTML with all images replaced if possible
+        return super.setHtmlMsg(temp);
+    }
+
+    /**
+     * Replace the regexp matching resource locations with "cid:..." references.
+     *
+     * @param htmlMessage the HTML message to analyze
+     * @param pattern the repexp to find resources
+     * @param baseUrl the starting point for resolving relative resource paths
+     * @return the HTML message containing "cid" references
+     * @throws EmailException creating the email failed
+     */
+    private String replacePattern(final String htmlMessage, final Pattern pattern, final URL baseUrl)
+            throws EmailException
+    {
+        StringBuffer myStringBuffer = new StringBuffer();
+
+        // in the String, replace all "img src" with a CID and embed the related
+        // image file if we find it.
+        Matcher matcher = pattern.matcher(htmlMessage);
+
+        // the matcher returns all instances one by one
+        while (matcher.find())
+        {
+            // in the RegEx we have the src-element as second "group"
+            String image = matcher.group(2);
+
+            DataSource imageDataSource = resolve(baseUrl, image);
+
+            if (imageDataSource != null)
+            {
+                if(!this.inlineEmbeds.containsKey(imageDataSource.getName()))
+                {
+                    String cid = embed(imageDataSource, imageDataSource.getName());
+
+                    // if we embedded something, then we need to replace the URL with
+                    // the CID, otherwise the Matcher takes care of adding the
+                    // non-replaced text afterwards, so no else is necessary here!
+                    matcher.appendReplacement(myStringBuffer, matcher.group(1) + "cid:" + cid + matcher.group(3));
+                }
+            }
+        }
+
+        // append the remaining items...
+        matcher.appendTail(myStringBuffer);
+
+        return myStringBuffer.toString();
+    }
+
+
+    /**
+     * Resolve a resource location to be embedded into the email.
+     *
+     * @param baseUrl the base url of the resourceLocation
+     * @param resourceLocation the location of the resource
+     * @return the data source containing the resource.
+     * @throws EmailException resolving the resource failed
+     */
+    protected DataSource resolve(final URL baseUrl, final String resourceLocation)
+            throws EmailException 
+    {
+        DataSource result = null;
+
+        try
+        {
+            if (!resourceLocation.startsWith("cid:"))
+            {
+                URL url = URLFactory.createUrl(baseUrl, resourceLocation);
+                result = new URLDataSource(url);
+            }
+
+            return result;
+        }
+        catch (IOException e)
+        {
+            throw new EmailException("Resolving the resourceLocation failed", e);
+        }
+    }
+}

Added: commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/URLFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/URLFactory.java?rev=961524&view=auto
==============================================================================
--- commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/URLFactory.java (added)
+++ commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/URLFactory.java Wed Jul  7 22:26:19 2010
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.mail.impl;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Create an URL for embedding a resource.
+ */
+public final class URLFactory
+{
+    /**
+     * Instances should NOT be constructed in standard programming.
+     */
+    private URLFactory()
+    {
+        super();
+    }
+
+    /**
+     * Create an file-based  URL.
+     *
+     * @param baseUrl an optional base URL
+     * @param resource a resource location
+     * @return the corresponding URL
+     * @throws java.net.MalformedURLException creating the URL failed
+     */
+    public static URL createUrl(final URL baseUrl, final String resource) throws MalformedURLException
+    {
+        // if we get an non-existing base url than the resource can
+        // be directly used to create an URL
+        if(baseUrl == null)
+        {
+            return new URL(resource);
+        }
+
+        // if we get an non-existing location than use the base url alone
+        if(resource == null)
+        {
+            return baseUrl;
+        }
+
+        // if we get a stand-alone resource than ignore the base url
+        if(isFileUrl(resource) || isHttpUrl(resource))
+        {
+            return new URL(resource);
+        }
+
+        // crate a file URL
+        String baseUrlString = baseUrl.toExternalForm();               
+        if(isFileUrl(baseUrlString))
+        {
+            return new File(toFile(baseUrl), resource).toURI().toURL();
+        }
+        else
+        {
+            return new URL(baseUrl, resource.replaceAll("&amp;", "&")) ;
+        }        
+    }
+
+    private static boolean isFileUrl(String urlString)
+    {
+        return urlString.startsWith("file://");
+    }
+
+    private static boolean isHttpUrl(String urlString)
+    {
+        return urlString.startsWith("http://") || urlString.startsWith("https://");
+    }
+
+    /**
+     * Convert from a <code>URL</code> to a <code>File</code>.
+     * <p>
+     * From version 1.1 this method will decode the URL.
+     * Syntax such as <code>file:///my%20docs/file.txt</code> will be
+     * correctly decoded to <code>/my docs/file.txt</code>.
+     *
+     * @param url  the file URL to convert, <code>null</code> returns <code>null</code>
+     * @return the equivalent <code>File</code> object, or <code>null</code>
+     *  if the URL's protocol is not <code>file</code>
+     * @throws IllegalArgumentException if the file is incorrectly encoded
+     */
+    private static File toFile(URL url)
+    {
+        if (url == null || !url.getProtocol().equals("file"))
+        {
+            return null;
+        }
+        else
+        {
+            String filename = url.getFile().replace('/', File.separatorChar);
+            int pos =0;
+            while ((pos = filename.indexOf('%', pos)) >= 0)
+            {
+                if (pos + 2 < filename.length())
+                {
+                    String hexStr = filename.substring(pos + 1, pos + 3);
+                    char ch = (char) Integer.parseInt(hexStr, 16);
+                    filename = filename.substring(0, pos) + ch + filename.substring(pos + 3);
+                }
+            }
+            return new File(filename);
+        }
+    }
+}

Copied: commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/package.html (from r960092, commons/proper/email/trunk/src/java/org/apache/commons/mail/package.html)
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/package.html?p2=commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/package.html&p1=commons/proper/email/trunk/src/java/org/apache/commons/mail/package.html&r1=960092&r2=961524&rev=961524&view=diff
==============================================================================
--- commons/proper/email/trunk/src/java/org/apache/commons/mail/package.html (original)
+++ commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/package.html Wed Jul  7 22:26:19 2010
@@ -17,9 +17,8 @@
 <html>
 <body>
 <p>
-Commons-Email aims to provide a API for sending email.
-It is built on top of the Java Mail API, which it aims to simplify.
-All help is gratefully received.
+The content of this package is depending on the current implementation
+and might unexpectedly change.
 </p>
 </body>
 </html>

Added: 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=961524&view=auto
==============================================================================
--- commons/proper/email/trunk/src/test/attachments/download_email.cgi.html (added)
+++ commons/proper/email/trunk/src/test/attachments/download_email.cgi.html Wed Jul  7 22:26:19 2010
@@ -0,0 +1,779 @@
+	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html>
+ <head>
+
+ <title>
+ Apache Commons -
+ Email Downloads
+ </title>
+
+ <style type="text/css" media="all">
+ @import url("../style/tigris.css");
+ @import url("../style/maven.css");
+ @import url("../style/project.css");
+ </style>
+ <link rel="stylesheet" href="../style/print.css" type="text/css" media="print"></link>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta>
+
+ </head>
+ <body class="composite">
+ <div id="banner">
+ <table border="0" width="100%" cellpadding="8" cellspacing="0">
+ <tr>
+
+ <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"/>
+ </a>
+
+ </td>
+
+ <td>
+ <div id="login" align="right">
+
+
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+<script type="text/javascript">
+<!--
+ var myWidth = 0, myHeight = 0;
+ if( typeof( window.innerWidth ) == 'number' ) {
+ //Non-IE
+ myWidth = window.innerWidth;
+ myHeight = window.innerHeight;
+ } else if( document.documentElement &&
+ ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
+ //IE 6+ in 'standards compliant mode'
+ myWidth = document.documentElement.clientWidth;
+ myHeight = document.documentElement.clientHeight;
+ } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
+ //IE 4 compatible
+ myWidth = document.body.clientWidth;
+ myHeight = document.body.clientHeight;
+ }
+ // window.alert( 'Width = ' + myWidth );
+ if (myWidth < 850) {
+ document['organization-logo'].src='http://jakarta.apache.org/images/original-jakarta-logo.gif';
+ }
+// -->
+</script>
+ <div id="breadcrumbs">
+ <table border="0" width="100%" cellpadding="4" cellspacing="0">
+ <tr>
+
+
+ <td>Last published: Nov 20, 2009
+
+ </td>
+
+ <td>
+ <div align="right">
+
+
+
+
+
+
+
+
+
+ <a href="http://www.apache.org" class="externalLink" title="External Link">Apache</a>
+
+
+
+
+
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <table border="0" width="100%" cellpadding="8" cellspacing="0">
+ <tr valign="top">
+ <td width="20%" id="leftcol">
+ <div id="navcolumn">
+
+
+ <div>
+ <strong>About Us</strong>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/">Home</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/contributors.html">Contributors</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/license.html">License</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="../components.html">Components</a>
+
+ </small>
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="../sandbox/index.html">Sandbox</a>
+
+ </small>
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="../dormant/index.html">Dormant</a>
+
+ </small>
+
+ </div>
+
+ </div>
+
+
+ <div>
+ <strong>Download</strong>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/downloads/index.html">Releases?(mirrored)</a>
+
+ </small>
+
+
+
+ </div>
+
+ </div>
+
+ <div>
+ <strong>View Source Code Repository</strong>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/svninfo.html">General Information</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://svn.apache.org/viewvc/commons/proper/" class="externalLink" title="External Link">Components</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://svn.apache.org/viewvc/commons/sandbox/" class="externalLink" title="External Link">Sandbox</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://svn.apache.org/viewvc/commons/dormant/" class="externalLink" title="External Link">Dormant</a>
+
+ </small>
+
+
+
+ </div>
+
+ </div>
+
+ <div>
+ <strong>Support</strong>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/mail-lists.html">Mailing Lists</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/bugs.html">Bug Database</a>
+
+ </small>
+
+
+
+ </div>
+
+ </div>
+
+
+
+ <div>
+ <strong>General Information</strong>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/charter.html">Charter</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/volunteering.html">Volunteering</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/patches.html">Contributing Patches</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/building.html">Building Components</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://commons.apache.org/releases/index.html">Releasing Components</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://wiki.apache.org/commons/FrontPage" class="externalLink" title="External Link">Wiki</a>
+
+ </small>
+
+
+
+ </div>
+
+ </div>
+
+ <div>
+ <strong>About Apache</strong>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://www.apache.org/foundation/how-it-works.html" class="externalLink" title="External Link">How the ASF works</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://www.apache.org/foundation/getinvolved.html" class="externalLink" title="External Link">Get Involved</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://www.apache.org/dev/" class="externalLink" title="External Link">Developer Resources</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="External Link">Sponsors of the ASF</a>
+
+ </small>
+
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
+
+ <div>
+ <small>
+
+
+ <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="External Link">Sponsorship program</a>
+
+ </small>
+
+
+
+ </div>
+
+ </div>
+
+
+
+
+
+
+
+ <div style="margin-top: 20px; width: 100%; text-align: center;">
+ <a href="http://maven.apache.org/" title="Built by Maven"><img style="border: 1px solid black" alt="Built by Maven" src="../images/logos/maven-feather.png"></img></a>
+ </div>
+
+
+
+ </div>
+ </td>
+ <td rowspan="2">
+ <div id="bodycol">
+
+ <div class="app">
+
+
+ <div class="h3">
+
+
+ <h3>
+ <a name="Email Downloads">Email Downloads</a>
+ </h3>
+
+ <p>We recommend you use a mirror to download our release
+ builds, but you <strong>must</strong> verify the integrity of
+ the downloaded files using signatures downloaded from our main
+ distribution directories. Recent releases (48 hours) may not yet be available from the mirrors. </p><p>You are currently using <b>http://mirror.deri.at/apache</b>. If you
+ encounter a problem with this mirror, please select another
+ mirror. If all mirrors are failing, there are <i>backup</i>
+ mirrors (at the end of the mirrors list) that should be
+ available.<br></br><a href="http://www.deri.at/"></a></p><p><form action="/downloads/download_email.cgi" method="get" id="SelectMirror">
+ Other mirrors: <select name="Preferred">
+
+ <option value="http://mirror.deri.at/apache">http://mirror.deri.at/apache</option>
+
+
+ <option value="ftp://gd.tuwien.ac.at/pub/infosys/servers/http/apache/dist">ftp://gd.tuwien.ac.at/pub/infosys/servers/http/apache/dist</option>
+
+
+ <option value="http://www.apache.org/dist">http://www.apache.org/dist (backup)</option><option value="http://www.eu.apache.org/dist">http://www.eu.apache.org/dist (backup)</option>
+
+ </select><input type="submit" value="Change"></input></form></p><p>
+ The <code>KEYS</code> link links to the code signing keys used to sign the product. The <code>PGP</code> link downloads the OpenPGP compatible signature from our main site.
+
+ The <code>MD5</code> link downloads the checksum from the main site.
+ </p><p>For more information concerning Email, see the <a href="http://commons.apache.org/email/" class="name">Email</a> site. </p><div class="links"><span class="link"><a href="http://www.apache.org/dist/commons/KEYS">KEYS</a></span></div><ul class="downloads"><li class="group"><div class="links"><span class="label"></span><span class="link"><a href="http://commons.apache.org/email/changes-report.html">Changes Report</a></span></div><ul></ul></li><li class="group"><div class="links"><span class="label">Binary</span></div><ul><li class="download"><a href="http://mirror.deri.at/apache/commons/email/binaries/commons-email-1.2-bin.tar.gz">1.2.tar.gz</a><ul class="attributes"><li><span class="md5">[<a href="http://www.apache.org/dist/commons/email/binaries/commons-email-1.2-bin.tar.gz.md5">md5</a>]</span><span class="pgp">[<a href="http://www.apache.org/dist/commons/email/binaries/commons-email-1.2-bin.tar.gz.asc">pgp</a>]</span></li></ul></li><li class="download"><a href="http:
 //mirror.deri.at/apache/commons/email/binaries/commons-email-1.2-bin.zip">1.2.zip</a><ul class="attributes"><li><span class="md5">[<a href="http://www.apache.org/dist/commons/email/binaries/commons-email-1.2-bin.zip.md5">md5</a>]</span><span class="pgp">[<a href="http://www.apache.org/dist/commons/email/binaries/commons-email-1.2-bin.zip.asc">pgp</a>]</span></li></ul></li></ul></li><li class="group"><div class="links"><span class="label">Source</span></div><ul><li class="download"><a href="http://mirror.deri.at/apache/commons/email/source/commons-email-1.2-src.tar.gz">1.2.tar.gz</a><ul class="attributes"><li><span class="md5">[<a href="http://www.apache.org/dist/commons/email/source/commons-email-1.2-src.tar.gz.md5">md5</a>]</span><span class="pgp">[<a href="http://www.apache.org/dist/commons/email/source/commons-email-1.2-src.tar.gz.asc">pgp</a>]</span></li></ul></li><li class="download"><a href="http://mirror.deri.at/apache/commons/email/source/commons-email-1.2-src.zip">1
 .2.zip</a><ul class="attributes"><li><span class="md5">[<a href="http://www.apache.org/dist/commons/email/source/commons-email-1.2-src.zip.md5">md5</a>]</span><span class="pgp">[<a href="http://www.apache.org/dist/commons/email/source/commons-email-1.2-src.zip.asc">pgp</a>]</span></li></ul></li></ul></li><li class="download"><a href="http://mirror.deri.at/apache/commons/email/">browse download area</a></li><li><a href="http://archive.apache.org/dist/commons/email/">archives...</a></li></ul>
+ </div>
+
+
+
+
+
+
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+ <div id="footer">
+ <table border="0" style="width:100%" cellpadding="4" cellspacing="0">
+
+ <tr>
+ <td>
+
+
+
+
+ ? 2001-2009, The Apache Software Foundation
+
+
+
+
+
+ </td>
+
+ </tr>
+ </table>
+ </div>
+ </body>
+ </html>

Added: 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=961524&view=auto
==============================================================================
--- commons/proper/email/trunk/src/test/html/www.apache.org.html (added)
+++ commons/proper/email/trunk/src/test/html/www.apache.org.html Wed Jul  7 22:26:19 2010
@@ -0,0 +1,277 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License. 
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+   <!--
+      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+            This file is generated from XML source: DO NOT EDIT!
+      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+   -->
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+	<link rel="stylesheet" href="./style/compressed.css" type="text/css" media="screen, projection"/>
+	<link rel="stylesheet" href="./style/style.css" type="text/css" media="screen, projection"/>
+	<!--[if IE]><link rel="stylesheet" href="./style/ie.css" type="text/css" media="screen, projection"/><![endif]-->
+<link rel="alternate" title="announce@apache.org Archives" type="application/atom+xml" href="http://mail-archives.apache.org/mod_mbox/www-announce/?format=atom" />
+     <meta name="author" content="The Apache Software Foundation" /><meta name="email" content="apache.AT.apache.DOT.org" />
+    <title>Welcome! - The Apache Software Foundation</title>
+  
+ </head>
+ <body>
+ 	<div class="navigation">
+		<ul>
+			<li><a href="./foundation" title="About the Foundation">Foundation</a></li>
+			<li><a href="http://projects.apache.org" title="Apache Projects">Projects</a></li>
+			<li><a href="http://people.apache.org" title="Apache People">People</a></li>
+			<li><a href="./foundation/getinvolved.html" title="Get involved in Apache">Get Involved</a></li>
+			<li><a href="./foundation/support-apache.html" title="Support the mission of Apache">Support Apache</a></li>			
+			<li class="dlink"><a href="./dyn/closer.cgi" title="Download Apache projects">Download</a></li>
+			<li><a href="http://blogs.apache.org/foundation/" title="Foundation Blog">ASF Blog</a></li>
+		</ul>
+	</div>
+	<div class="container">
+	<hr class="space col"/>
+	<div class="block">
+		<div class="column span-24">
+      <div id="header">
+                          <h1>The Apache Software Foundation<br />
+  <span class="alt"><small>Celebrating a Decade of Open Source Leadership.</small></span></h1><p class="blurb">The Apache Software Foundation provides support for the Apache community of open-source software projects.  The <a href="http://projects.apache.org/">Apache projects</a> are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field.</p><p class="highlight">We are more than a group of projects sharing a server, we are a <em>community</em> of developers and users.</p>
+               </div>
+      </div>
+	</div>
+	<hr/>
+	<div class="block">
+    		<div class="column span-15 first append-1">
+			<h3>
+                          Want to speak at ApacheCon NA 2010?
+              </h3>
+		</div>
+		<div class="column span-8 las search">
+    			<form action="http://www.google.com/search" method="get">
+		         <input value="*.apache.org" name="sitesearch" type="hidden"/>
+		         <input size="10" name="q" id="query" type="text"/>
+		         <input name="Search" value="Go" type="submit"/>
+	       </form>
+		</div>
+	</div>
+	<div class="block content">
+		<div class="column span-15 colborder">
+                       
+<div class="section-content">
+<p><a href="http://na.apachecon.com/c/acna2010/">ApacheCon NA 2010</a> returns to Atlanta this year on 1-5 November, and the 
+<a href="http://blogs.apache.org/conferences/date/20100428">Call for Participation for technical talks</a> is now open!
+We're looking to have a better conference than ever, including tracks planned by our PMCs as well 
+as your technical session submissions.  CFP ends 28-May!</p>
+</div>
+                 
+<h4 id="news">
+   Latest News
+</h4>
+<div class="section-content">
+<p><em>If you would like to keep up with news and announcements from the foundation and all its projects, you can subscribe to the <a href="foundation/mailinglists.html#foundation-announce">Apache Announcements List</a> or you can visit <a href="https://blogs.apache.org/foundation/">our foundation blog</a></em>. Latest blog entries:</p>
+<div id="latestnews">
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces5">The Apache Software Foundation Announces Apache Tomcat Version 7.0</a>
+<br /><i>Posted at: 1:16 PM Jun 29, 2010</i></p>
+
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces4">The Apache Software Foundation Announces New Top-Level Projects</a>
+<br /><i>Posted at: 12:09 PM May 4, 2010</i></p>
+
+<p>
+<a href="https://blogs.apache.org/foundation/entry/call_for_participation_technical_talks">Call for Participation: Technical Talks -- ApacheCon North America 2010</a>
+<br /><i>Posted at: 5:52 PM Apr 28, 2010</i></p>
+
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces3">The Apache Software Foundation Announces Apache Cassandra Release 0.6</a>
+<br /><i>Posted at: 1:05 PM Apr 13, 2010</i></p>
+
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_receives">The Apache Software Foundation Receives Approval for Sale to Oracle Corporation</a>
+<br /><i>Posted at: 11:59 AM Apr 1, 2010</i></p>
+</div>
+</div>
+         </div>
+    <div class="column span-8 last">
+      <div class="block">
+        <div class="nav column span-11">
+          <div>
+               <div class="menuheader"><a 
+href="http://projects.apache.org/">Apache Projects</a></div> 
+  <ul>
+          <li><a href="http://httpd.apache.org/" title="Apache Web Server (httpd)">HTTP Server</a></li> 
+          <li><a href="http://abdera.apache.org/" title="Atom Publishing Protocol Implementation">Abdera</a></li> 
+          <li><a href="http://activemq.apache.org/" title="Distributed Messaging System">ActiveMQ</a></li> 
+          <li><a href="http://ant.apache.org/" title="Java-based build tool">Ant</a></li> 
+          <li><a href="http://apr.apache.org/" title="Apache Portable Runtime libraries">APR</a></li> 
+          <li><a href="http://archiva.apache.org/" title="Build Artifact Repository Manager">Archiva</a></li> 
+          <li><a href="http://avro.apache.org/" title="A Serialization System">Avro</a></li> 
+          <li><a href="http://buildr.apache.org/" title="Simple and intuitive build system for Java applications">Buildr</a></li> 
+          <li><a href="http://camel.apache.org/" title="Spring based Integration Framework which implements the Enterprise Integration Patterns">Camel</a></li> 
+          <li><a href="http://cassandra.apache.org/" title="Highly scalable second-generation distributed database">Cassandra</a></li> 
+          <li><a href="http://cayenne.apache.org/" title="User-friendly Java ORM with Tools">Cayenne</a></li> 
+          <li><a href="http://click.apache.org/" title="User-friendly page and component oriented web framework">Click</a></li> 
+          <li><a href="http://cocoon.apache.org/" title="Web development framework: separation of concerns, component-based">Cocoon</a></li> 
+          <li><a href="http://commons.apache.org/" title="Reusable Java components">Commons</a></li> 
+          <li><a href="http://continuum.apache.org/" title="Continuous Integration and Build Server">Continuum</a></li> 
+          <li><a href="http://couchdb.apache.org/" title="RESTful document database">CouchDB</a></li> 
+          <li><a href="http://cxf.apache.org/" title="Service Framework">CXF</a></li> 
+          <li><a href="http://db.apache.org/" title="Database access">DB</a></li> 
+          <li><a href="http://directory.apache.org/" title="Apache Directory Server">Directory</a></li> 
+          <li><a href="http://excalibur.apache.org/" title="Embeddable software libraries related to component and service management access">Excalibur</a></li> 
+          <li><a href="http://felix.apache.org/" title="OSGi Framework and components.">Felix</a></li> 
+          <li><a href="http://forrest.apache.org/" title="Aggregated multi-channel documentation, separation of concerns">Forrest</a></li> 
+          <li><a href="http://geronimo.apache.org/" title="Java2, Enterprise Edition (J2EE) container">Geronimo</a></li> 
+          <li><a href="http://gump.apache.org/" title="Continuous integration of open source projects">Gump</a></li> 
+          <li><a href="http://hadoop.apache.org/" title="Distributed computing platform">Hadoop</a></li> 
+          <li><a href="http://harmony.apache.org/" title="Open source implementation of Java SE">Harmony</a></li> 
+          <li><a href="http://hbase.apache.org/" title="Hadoop Database">HBase</a></li> 
+          <li><a href="http://hc.apache.org/" title="Java toolset of low level HTTP components">HttpComponents</a></li> 
+          <li><a href="http://jackrabbit.apache.org/" title="Content Repository for Java">Jackrabbit</a></li> 
+          <li><a href="http://jakarta.apache.org/" title="Server-side Java">Jakarta</a></li> 
+          <li><a href="http://james.apache.org/" title="Java Apache Mail Enterprise Server">James</a></li> 
+          <li><a href="http://lenya.apache.org/" title="Content Management System">Lenya</a></li> 
+          <li><a href="http://logging.apache.org/" title="Cross-language logging services">Logging</a></li> 
+          <li><a href="http://lucene.apache.org/" title="Search engine library">Lucene</a></li> 
+          <li><a href="http://mahout.apache.org/" title="Scalable machine learning library">Mahout</a></li> 
+          <li><a href="http://maven.apache.org/" title="Java project management and comprehension tools">Maven</a></li> 
+          <li><a href="http://mina.apache.org/" title="Multipurpose Infrastructure for Network Application">Mina</a></li> 
+          <li><a href="http://myfaces.apache.org/" title="JavaServer(tm) Faces implementation and components">MyFaces</a></li> 
+          <li><a href="http://nutch.apache.org/" title="Open Source Web Search Software">Nutch</a></li> 
+          <li><a href="http://ode.apache.org/" title="Orchestration Director Engine: Business Process Management (BPM), Process Orchestration and Workflow through service compositioni.">ODE</a></li> 
+          <li><a href="http://ofbiz.apache.org/" title="Open for Business: enterprise automation software">OFBiz</a></li> 
+          <li><a href="http://openejb.apache.org/" title="OpenEJB: a modular, configurable, and extendable EJB Container System and Server">OpenEJB</a></li> 
+          <li><a href="http://openjpa.apache.org/" title="OpenJPA: Object Relational Mapping for Java">OpenJPA</a></li> 
+          <li><a href="http://openwebbeans.apache.org/" title="OpenWebBeans: JSR-299 Context and Dependency Injection for Java EE Platform Implementation">OpenWebBeans</a></li> 
+          <li><a href="http://pdfbox.apache.org/" title="Java library for working with PDF documents">PDFBox</a></li> 
+          <li><a href="http://perl.apache.org/" title="Dynamic websites using Perl">Perl</a></li> 
+          <li><a href="http://pivot.apache.org/" title="Rich Internet applications in Java">Pivot</a></li> 
+          <li><a href="http://poi.apache.org/" title="Java API for OLE 2 Compound Documents">POI</a></li> 
+          <li><a href="http://portals.apache.org/" title="Portal technology">Portals</a></li> 
+          <li><a href="http://qpid.apache.org/" title="Multiple language implementation of the latest Advanced Message Queuing Protocol (AMQP)">Qpid</a></li> 
+          <li><a href="http://roller.apache.org/" title="Java blog server">Roller</a></li> 
+          <li><a href="http://santuario.apache.org/" title="XML Security in Java and C++">Santuario</a></li> 
+          <li><a href="http://servicemix.apache.org/" title="Enterprise Service Bus">ServiceMix</a></li> 
+          <li><a href="http://shindig.apache.org/" title="Opensocial Reference Implementation">Shindig</a></li> 
+          <li><a href="http://sling.apache.org/" title="Web Framework for JCR Content Repositories">Sling</a></li> 
+          <li><a href="http://spamassassin.apache.org/" title="Mail filter to identify spam">SpamAssassin</a></li> 
+          <li><a href="http://stdcxx.apache.org/" title="Apache C++ Standard Library">STDCXX</a></li> 
+          <li><a href="http://struts.apache.org/" title="Model 2 framework for building Java web applications">Struts</a></li> 
+          <li><a href="http://subversion.apache.org/" title="Version Control">Subversion</a></li> 
+          <li><a href="http://synapse.apache.org/" title="Enterprise Service Bus and Mediation Framework">Synapse</a></li> 
+          <li><a href="http://tapestry.apache.org/" title="Component-based Java Web Application Framework">Tapestry</a></li> 
+          <li><a href="http://tika.apache.org" title="Content Analysis and Detection Toolkit">Tika</a></li> 
+          <li><a href="http://tcl.apache.org/" title="Dynamic websites using TCL">TCL</a></li> 
+          <li><a href="http://tiles.apache.org/" title="A templating framework for web application user interfaces">Tiles</a></li> 
+          <li><a href="http://tomcat.apache.org/" title="A Java Servlet and JSP Container">Tomcat</a></li> 
+          <li><a href="http://trafficserver.apache.org/" title="A fast, scalable and extensible HTTP/1.1 compliant caching proxy server">TrafficServer</a></li> 
+          <li><a href="http://turbine.apache.org/" title="A Java Servlet Web Application Framework and associated component library">Turbine</a></li> 
+          <li><a href="http://tuscany.apache.org/" title="An SCA based Service Composition Framework">Tuscany</a></li> 
+          <li><a href="http://uima.apache.org/" title="Framework and annotators for unstructured information analysis">UIMA</a></li> 
+          <li><a href="http://velocity.apache.org/" title="A Java Templating Engine">Velocity</a></li> 
+          <li><a href="http://wicket.apache.org/" title="Component-based Java Web Application Framework.">Wicket</a></li> 
+          <li><a href="http://ws.apache.org/">Web Services</a></li> 
+          <li><a href="http://xalan.apache.org/" title="XSLT processors in Java and C++">Xalan</a></li> 
+          <li><a href="http://xerces.apache.org/" title="XML parsers in Java, C++ and Perl">Xerces</a></li> 
+          <li><a href="http://xml.apache.org/" title="XML solutions focused on the web">XML</a></li> 
+          <li><a href="http://xmlbeans.apache.org/" title="XML-Java binding tool">XMLBeans</a></li> 
+          <li><a href="http://xmlgraphics.apache.org/" title="Conversion from XML to graphical output">XML Graphics</a></li> 
+      </ul>
+          </div>
+        </div>
+        <div class="nav column prepend-1 span-12 last">
+               <h6><a 
+href="/foundation/">Foundation</a></h6>
+  <ul>
+          <li><a href="/foundation/faq.html">FAQ</a></li> 
+          <li><a href="/licenses/">Licenses</a></li> 
+          <li><a href="/foundation/news.html">News</a></li> 
+          <li><a href="http://blogs.apache.org/foundation/">Blog</a></li> 
+          <li><a href="/foundation/records/">Public Records</a></li> 
+          <li><a href="/press/">Press Inquiries</a></li> 
+          <li><a href="/foundation/contact.html">Contact</a></li> 
+      </ul>
+      <h6><a 
+href="/foundation/support-apache.html">Support Apache</a></h6>
+  <ul>
+          <li><a href="/foundation/sponsorship.html">Sponsorship</a></li> 
+          <li><a href="/foundation/contributing.html">Donations</a></li> 
+          <li><a href="/foundation/buy_stuff.html">Buy Stuff</a></li> 
+          <li><a href="/foundation/thanks.html">Thanks</a></li> 
+      </ul>
+      <h6><a 
+href="/foundation/foundation-projects.html">Foundation Projects</a></h6>
+  <ul>
+          <li><a href="http://attic.apache.org/" title="Inactive project repository">Attic</a></li> 
+          <li><a href="/foundation/conferences.html" title="Meetings of developers and users">Conferences</a></li> 
+          <li><a href="http://community.apache.org/" title="Helping newcomers to the ASF">Community Development</a></li> 
+          <li><a href="http://incubator.apache.org/" title="Shepherd for new projects">Incubator</a></li> 
+          <li><a href="/dev/infrastructure.html" title="Upholding the Foundation">Infrastructure</a></li> 
+          <li><a href="/jcp/" title="Apache and the Java Community Process">JCP</a></li> 
+          <li><a href="http://labs.apache.org/" title="The Innovation Laboratories of the Apache Software Foundation">Labs</a></li> 
+          <li><a href="/legal/" title="Legal Affairs">Legal Affairs</a></li> 
+          <li><a href="/security/" title="Security">Security</a></li> 
+          <li><a href="/travel/" title="Travel Assistance">Travel Assistance</a></li> 
+      </ul>
+      <h6>How it works</h6>
+  <ul>
+          <li><a href="/foundation/how-it-works.html">Introduction</a></li> 
+          <li><a href="/foundation/how-it-works.html#meritocracy">Meritocracy</a></li> 
+          <li><a href="/foundation/how-it-works.html#structure">Structure</a></li> 
+          <li><a href="/foundation/how-it-works.html#roles">Roles</a></li> 
+          <li><a href="/foundation/how-it-works.html#management">Collaboration</a></li> 
+          <li><a href="/foundation/how-it-works.html#incubator">Incubator</a></li> 
+          <li><a href="/foundation/how-it-works.html#other">Other entities</a></li> 
+          <li><a href="/foundation/glossary.html">Glossary</a></li> 
+          <li><a href="/foundation/voting.html">Voting</a></li> 
+      </ul>
+      <h6><a 
+href="/foundation/getinvolved.html">Get Involved</a></h6>
+  <ul>
+          <li><a href="/dyn/closer.cgi">Download</a></li> 
+          <li><a href="/foundation/mailinglists.html">Mailing Lists</a></li> 
+          <li><a href="/dev/version-control.html">Version Control</a></li> 
+          <li><a href="/dev/" title="Operations and howto documents for PMCs and contributors">Developer Info</a></li> 
+      </ul>
+      <h6>Community</h6>
+  <ul>
+          <li><a href="http://people.apache.org/">People</a></li> 
+          <li><a href="/memorials/">Memorials</a></li> 
+          <li><a href="http://feathercast.org/" title="Apache Podcasts">Feathercast</a></li> 
+          <li><a href="http://blogs.apache.org/" title="Apache Project Blogs">Project Blogs</a></li> 
+          <li><a href="http://planet.apache.org/committers/" title="Apache Committers' Blogs">PlanetApache</a></li> 
+      </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>
+    </div>
+    <div class="column span-24 footer">
+      <hr/>
+        <p>Copyright &#169; 2010 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.<br/>
+        Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
+      </div>
+    </div>
+  </div>
+</body>
+</html>
+

Added: commons/proper/email/trunk/src/test/images/logos/maven-feather.png
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/images/logos/maven-feather.png?rev=961524&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/email/trunk/src/test/images/logos/maven-feather.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailLiveTest.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailLiveTest.java?rev=961524&r1=961523&r2=961524&view=diff
==============================================================================
--- commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailLiveTest.java (original)
+++ commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailLiveTest.java Wed Jul  7 22:26:19 2010
@@ -16,15 +16,19 @@
  */
 package org.apache.commons.mail;
 
-import java.io.File;
+import java.io.*;
 import java.net.URL;
 import java.util.Properties;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import javax.activation.DataSource;
+import javax.activation.URLDataSource;
 import javax.mail.Session;
 import javax.mail.internet.InternetAddress;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.mail.settings.EmailConfiguration;
 
 /**
@@ -35,6 +39,12 @@ import org.apache.commons.mail.settings.
 
 public class EmailLiveTest extends BaseEmailTestCase
 {
+    /** the mail session */
+    private Session session;
+
+    /** the recipients of the test emails */
+    private Collection toList;
+
     /**
      * @param name name
      */
@@ -48,8 +58,57 @@ public class EmailLiveTest extends BaseE
     protected void setUp() throws Exception
     {
         super.setUp();
-    }    
 
+        // prepare a mail session
+
+        Properties properties = new Properties();
+        properties.setProperty(Email.MAIL_DEBUG, "" + EmailConfiguration.MAIL_DEBUG);
+        properties.setProperty(Email.MAIL_PORT,  "" + EmailConfiguration.MAIL_SERVER_PORT);
+        properties.setProperty(Email.MAIL_HOST, EmailConfiguration.MAIL_SERVER);
+        properties.setProperty(Email.MAIL_SMTP_AUTH, "true");
+        DefaultAuthenticator authenticator = new DefaultAuthenticator( EmailConfiguration.TEST_USER, EmailConfiguration.TEST_PASSWD);
+        this.session = Session.getInstance(properties, authenticator);
+
+        // prepare recipient list
+
+        this.toList = new ArrayList();
+        this.toList.add( new InternetAddress( EmailConfiguration.TEST_TO) );
+
+    }
+
+    protected Session getSession() {
+        return session;
+    }
+
+    public Collection getToList() {
+        return toList;
+    }
+
+    protected Email send(Email email) throws EmailException {
+
+        if( EmailConfiguration.MAIL_FORCE_SEND ) {
+            email.send();
+        }
+        else {
+            email.buildMimeMessage();
+        }
+
+        return email;
+    }
+
+    protected String getFromUrl(URL url) throws Exception {
+
+        URLDataSource dataSource = new URLDataSource(url);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        IOUtils.copy(dataSource.getInputStream(), baos);
+        return new String(baos.toByteArray(), "UTF-8");
+    }
+
+
+    // ======================================================================
+    // Start of Tests
+    // ======================================================================
+        
     /**
      * This test checks the various options of building a HTML email.
      *
@@ -61,12 +120,6 @@ public class EmailLiveTest extends BaseE
     {
         String textMsg;
         String htmlMsg;
-        Collection toList;
-
-        // prepare recipient list
-
-        toList = new ArrayList();
-        toList.add( new InternetAddress( EmailConfiguration.TEST_TO) );
 
         // prepare attachments
 
@@ -81,16 +134,6 @@ public class EmailLiveTest extends BaseE
         attachment.setDescription("The official Apache logo");
         attachment.setPath(attachmentFile.getAbsolutePath());
 
-        // prepare a mail session
-
-        Properties properties = new Properties();
-        properties.setProperty(Email.MAIL_DEBUG, "" + EmailConfiguration.MAIL_DEBUG);
-        properties.setProperty(Email.MAIL_PORT,  "" + EmailConfiguration.MAIL_SERVER_PORT);
-        properties.setProperty(Email.MAIL_HOST, EmailConfiguration.MAIL_SERVER);
-        properties.setProperty(Email.MAIL_SMTP_AUTH, "true");
-        DefaultAuthenticator authenticator = new DefaultAuthenticator( EmailConfiguration.TEST_USER, EmailConfiguration.TEST_PASSWD);
-        Session session = Session.getInstance(properties, authenticator);
-
         // 1) text + html content
 
         HtmlEmail htmlEmail1 = new HtmlEmail();
@@ -99,19 +142,12 @@ public class EmailLiveTest extends BaseE
 
         htmlEmail1.setSubject( "[email] 1.Test: text + html content");
         htmlEmail1.setFrom(EmailConfiguration.TEST_FROM);
-        htmlEmail1.setTo(toList);
+        htmlEmail1.setTo(getToList());
         htmlEmail1.setTextMsg(textMsg);
         htmlEmail1.setHtmlMsg(htmlMsg);
-        htmlEmail1.setMailSession( session );
+        htmlEmail1.setMailSession(getSession());
 
-        if( EmailConfiguration.MAIL_FORCE_SEND ) {
-            htmlEmail1.send();
-        }
-        else {
-            htmlEmail1.buildMimeMessage();
-        }
-
-        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail1.eml"), htmlEmail1.getMimeMessage());
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemai12.eml"), send(htmlEmail1).getMimeMessage());
 
         // 2) text + html content + image as attachment
 
@@ -121,20 +157,13 @@ public class EmailLiveTest extends BaseE
 
         htmlEmail2.setSubject( "[email] 2.Test: text + html content + image as attachment");
         htmlEmail2.setFrom(EmailConfiguration.TEST_FROM);
-        htmlEmail2.setTo( toList );
+        htmlEmail2.setTo(getToList());
         htmlEmail2.setTextMsg(textMsg);
         htmlEmail2.setHtmlMsg(htmlMsg);
         htmlEmail2.attach(url, "Apache Logo", "The official Apache logo" );
-        htmlEmail2.setMailSession( session );
-
-        if( EmailConfiguration.MAIL_FORCE_SEND ) {
-            htmlEmail2.send();
-        }
-        else {
-            htmlEmail2.buildMimeMessage();
-        }
+        htmlEmail2.setMailSession( getSession() );
 
-        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail2.eml"), htmlEmail2.getMimeMessage());
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail2.eml"), send(htmlEmail2).getMimeMessage());
 
         // 3) text + html content + inline image
 
@@ -147,19 +176,12 @@ public class EmailLiveTest extends BaseE
 
         htmlEmail3.setSubject( "[email] 3.Test: text + html content + inline image");
         htmlEmail3.setFrom(EmailConfiguration.TEST_FROM);
-        htmlEmail3.setTo(toList);
+        htmlEmail3.setTo(getToList());
         htmlEmail3.setTextMsg(textMsg);
         htmlEmail3.setHtmlMsg(htmlMsg);
-        htmlEmail3.setMailSession( session );
+        htmlEmail3.setMailSession(getSession());
 
-        if( EmailConfiguration.MAIL_FORCE_SEND ) {
-            htmlEmail3.send();
-        }
-        else {
-            htmlEmail3.buildMimeMessage();
-        }
-
-        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail3.eml"), htmlEmail3.getMimeMessage());
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail3.eml"), send(htmlEmail3).getMimeMessage());
 
         // 4) text + html content + inline image + attachment
 
@@ -170,20 +192,13 @@ public class EmailLiveTest extends BaseE
 
         htmlEmail4.setSubject( "[email] 4.Test: text + html content + inline image + attachment");
         htmlEmail4.setFrom(EmailConfiguration.TEST_FROM);
-        htmlEmail4.setTo(toList);
+        htmlEmail4.setTo(getToList());
         htmlEmail4.setTextMsg(textMsg);
         htmlEmail4.setHtmlMsg(htmlMsg);
         htmlEmail4.attach(attachment);
-        htmlEmail4.setMailSession( session );
+        htmlEmail4.setMailSession(getSession());
 
-        if( EmailConfiguration.MAIL_FORCE_SEND ) {
-            htmlEmail4.send();
-        }
-        else {
-            htmlEmail4.buildMimeMessage();
-        }
-
-        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail4.eml"), htmlEmail4.getMimeMessage());
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/htmlemail4.eml"), send(htmlEmail4).getMimeMessage());        
     }
 
     /**
@@ -202,8 +217,9 @@ public class EmailLiveTest extends BaseE
 
         final String subject = "[email] 5.Test: Subject with three greek UTF-8 characters : \u03B1\u03B2\u03B3";
         final String textMsg = "My test body with with three greek UTF-8 characters : \u03B1\u03B2\u03B3";
+        final String attachmentName = "\u03B1\u03B2\u03B3.txt";
 
-        SimpleEmail email = new SimpleEmail();
+        MultiPartEmail email = new MultiPartEmail();
         email.setDebug(true);
         email.setAuthenticator(new DefaultAuthenticator(EmailConfiguration.TEST_USER, EmailConfiguration.TEST_PASSWD));
         email.setHostName(EmailConfiguration.MAIL_SERVER);
@@ -214,22 +230,61 @@ public class EmailLiveTest extends BaseE
         email.setMsg(textMsg);
         email.setCharset("utf-8");
 
-        if( EmailConfiguration.MAIL_FORCE_SEND ) {
-            email.send();
-        }
-        else {
-            email.buildMimeMessage();
-        }
-
-        EmailUtils.writeMimeMessage( new File("./target/test-emails/correct-encoding.eml"), email.getMimeMessage());
+        // attachment in Greek
+        DataSource attachment = new ByteArrayDataSource(textMsg, "text/plain");
+        email.attach(attachment, attachmentName, "Attachment in Greek");
+        
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/correct-encoding.eml"), send(email).getMimeMessage());
 
         System.out.println("Encoding: " + email.getMimeMessage().getEncoding());
         System.out.println("Type: " + email.getMimeMessage().getContentType());
 
         if( EmailConfiguration.MAIL_FORCE_SEND ) {
-          // the encoding is only set when sending the email
+          // the encoding is only set when sending the email!!
           assertEquals(email.getMimeMessage().getEncoding(), "quoted-printable");
           assertEquals(email.getMimeMessage().getContentType(), "text/plain; charset=UTF-8");
         }
     }
+
+    /**
+     * Test sending a image HTML mail bases on a local HTML page.
+     *
+     * @throws Exception the test failed                               
+     */
+    public void testImageHtmlEmailLocal() throws Exception {
+
+        // use a simple HTML page with one image - please note that the Apache logo
+        // is defined in CSS and not in HTML.
+
+        String htmlMsg1 = FileUtils.readFileToString(new File("./src/test/html/www.apache.org.html"));
+
+        ImageHtmlEmail email = new ImageHtmlEmail();
+        email.setSubject( "[testImageHtmlEmail] 1.Test: simple html content");
+        email.setFrom(EmailConfiguration.TEST_FROM);
+        email.setTo(getToList());
+        email.setHtmlMsg(htmlMsg1);
+        email.setMailSession(getSession());
+
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/testImageHtmlEmailLocal.eml"), send(email).getMimeMessage());
+    }
+
+    /**
+     * Test sending a image HTML mail based on a complex real world website.
+     *
+     * @throws Exception the test failed
+     */
+    public void testImageHtmlEmailRemote() throws Exception {
+
+        URL url = new URL("http://www.theserverside.com");
+        String htmlMsg = getFromUrl(url);
+
+        ImageHtmlEmail email = new ImageHtmlEmail();
+        email.setSubject( "[testImageHtmlEmail] 2.Test: complex html content");
+        email.setFrom(EmailConfiguration.TEST_FROM);
+        email.setTo(getToList());
+        email.setHtmlMsg(htmlMsg, url);
+        email.setMailSession(getSession());
+
+        EmailUtils.writeMimeMessage( new File("./target/test-emails/testImageHtmlEmailRemote.eml"), send(email).getMimeMessage());
+    }
 }
\ No newline at end of file

Added: 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=961524&view=auto
==============================================================================
--- commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java (added)
+++ commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java Wed Jul  7 22:26:19 2010
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.mail;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.activation.DataHandler;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.mail.mocks.MockImageHtmlEmailConcrete;
+import org.subethamail.wiser.WiserMessage;
+
+public class ImageHtmlEmailTest extends HtmlEmailTest {
+
+    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");
+
+    public ImageHtmlEmailTest(String name) throws IOException {
+		super(name);
+	}
+
+	/** */
+	private MockImageHtmlEmailConcrete email;
+
+	/**
+	 * @throws Exception
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		// reusable objects to be used across multiple tests
+		email = new MockImageHtmlEmailConcrete();
+	}
+
+	public void testSendHTML() throws Exception {
+
+		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
+
+		// Create the email message
+		getMailServer();
+
+		String strSubject = "Test HTML Send default";
+
+		email = new MockImageHtmlEmailConcrete();
+		email.setHostName(strTestMailServer);
+		email.setSmtpPort(getMailServerPort());
+		email.setFrom(strTestMailFrom);
+		email.addTo(strTestMailTo);
+		email.setSubject(strSubject);
+
+		URL url = TEST_HTML_URL;
+		InputStream stream = url.openStream();
+		StringBuilder str = new StringBuilder();
+		try {
+			List lines = IOUtils.readLines(stream);
+			for(int i=0;i<lines.size();i++) {
+                String line = (String) lines.get(i);
+				str.append(line).append("\n");
+			}
+		} finally {
+			stream.close();
+		}
+		String html = str.toString();
+
+		// set the html message
+		email.setHtmlMsg(html, TEST_IMAGE_DIR.toURI().toURL());
+
+		// set the alternative message
+		//email.setTextMsg("Your email client does not support HTML messages");
+
+		// send the email
+		email.send();
+
+		fakeMailServer.stop();
+
+		// Cannot validate as the HTML is changed during inclusion
+		// validate html message
+		//validateSend(fakeMailServer, strSubject, email.getHtmlMsg(),
+		//		email.getFromAddress(), email.getToAddresses(),
+		//		email.getCcAddresses(), email.getBccAddresses(), false);
+		assertEquals(1, fakeMailServer.getMessages().size());
+		MimeMessage mimeMessage = ((WiserMessage) fakeMailServer.getMessages().get(0)).getMimeMessage();
+
+		DataHandler dataHandler = mimeMessage.getDataHandler();
+		ByteArrayOutputStream byteArrayOutStream = new ByteArrayOutputStream();
+		BufferedOutputStream buffOs = new BufferedOutputStream(byteArrayOutStream);
+		dataHandler.writeTo(buffOs);
+		buffOs.flush();
+
+		String msg = new String(byteArrayOutStream.toByteArray());
+		// the mail should contain Content-ID-Entries
+		assertTrue(msg, msg.contains("\"cid:"));
+		// at least the logo that we store locally should be replaced by an included cid now
+		assertFalse(msg, msg.contains("\"asf_logo_wide.gif\""));
+	}
+
+	public void testSendEmptyHTML() throws Exception {
+		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
+
+		// Create the email message
+		ImageHtmlEmail email = new ImageHtmlEmail();
+
+		// set the html message
+		try {
+			email.setHtmlMsg(null, new File("/tmp").toURI().toURL());
+			fail("Should fail here!");
+		} catch (EmailException e) {
+			assertTrue(e.getMessage(), e.getMessage().contains(
+					"Invalid message supplied"));
+		}
+	}
+
+	public void testSendEmptyHTML2() throws Exception {
+		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
+
+		// Create the email message
+		ImageHtmlEmail email = new ImageHtmlEmail();
+
+		// set the html message
+		try {
+			email.setHtmlMsg("", new File("/tmp").toURI().toURL());
+			fail("Should fail here!");
+		} catch (EmailException e) {
+			assertTrue(e.getMessage(), e.getMessage().contains(
+					"Invalid message supplied"));
+		}
+
+	}
+
+	public void testSendHTMLURL() throws Exception {
+		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
+
+		getMailServer();
+
+		String strSubject = "Test HTML Send default with URL";
+
+		// Create the email message
+		email = new MockImageHtmlEmailConcrete();
+		email.setHostName(strTestMailServer);
+		email.setSmtpPort(getMailServerPort());
+		email.setFrom(strTestMailFrom);
+		email.addTo(strTestMailTo);
+		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>");
+
+		// send the email
+		email.send();
+
+		fakeMailServer.stop();
+		// validate txt message
+		validateSend(fakeMailServer, strSubject, email.getHtmlMsg(),
+				email.getFromAddress(), email.getToAddresses(),
+				email.getCcAddresses(), email.getBccAddresses(), true);
+	}
+
+	public void testSendHTMLAbsoluteLocalFile() throws Exception {
+		Logger.getLogger(ImageHtmlEmail.class.getName()).setLevel(Level.FINEST);
+
+		// Create the email message
+		getMailServer();
+
+		String strSubject = "Test HTML Send default with absolute local path";
+
+		// Create the email message
+		email = new MockImageHtmlEmailConcrete();
+		email.setHostName(strTestMailServer);
+		email.setSmtpPort(getMailServerPort());
+		email.setFrom(strTestMailFrom);
+		email.addTo(strTestMailTo);
+		email.setSubject(strSubject);
+
+		File file = File.createTempFile("emailtest", ".tst");
+		FileUtils.writeStringToFile(file,
+				"just some silly data that we won't be able to display anyway");
+
+		// set the html message
+		email.setHtmlMsg("<html><body><img src=\"" + file.getAbsolutePath()
+				+ "\"/></body></html>", new File("").toURI().toURL());
+
+		// send the email
+		email.send();
+
+		fakeMailServer.stop();
+		// validate txt message
+		validateSend(fakeMailServer, strSubject, email.getHtmlMsg(),
+				email.getFromAddress(), email.getToAddresses(),
+				email.getCcAddresses(), email.getBccAddresses(), true);
+	}
+
+	public void testRegex() {
+		Pattern pattern = Pattern.compile(ImageHtmlEmail.REGEX_IMG_SRC);
+
+		// ensure that the regex that we use is catching the cases correctly
+		Matcher matcher = pattern
+				.matcher("<html><body><img src=\"h\"/></body></html>");
+		assertTrue(matcher.find());
+		assertEquals("h", matcher.group(2));
+
+		matcher = pattern
+				.matcher("<html><body><img id=\"laskdasdkj\" src=\"h\"/></body></html>");
+		assertTrue(matcher.find());
+		assertEquals("h", matcher.group(2));
+
+		// uppercase
+		matcher = pattern
+				.matcher("<html><body><IMG id=\"laskdasdkj\" SRC=\"h\"/></body></html>");
+		assertTrue(matcher.find());
+		assertEquals("h", matcher.group(2));
+
+		// matches twice
+		matcher = pattern
+				.matcher("<html><body><img id=\"laskdasdkj\" src=\"http://dstadler1.org/\"/><img id=\"laskdasdkj\" src=\"http://dstadler2.org/\"/></body></html>");
+		assertTrue(matcher.find());
+		assertEquals("http://dstadler1.org/", matcher.group(2));
+		assertTrue(matcher.find());
+		assertEquals("http://dstadler2.org/", matcher.group(2));
+
+		// what about newlines
+		matcher = pattern
+				.matcher("<html><body><img\n \rid=\"laskdasdkj\"\n \rsrc=\"http://dstadler1.org/\"/><img id=\"laskdasdkj\" src=\"http://dstadler2.org/\"/></body></html>");
+		assertTrue(matcher.find());
+		assertEquals("http://dstadler1.org/", matcher.group(2));
+		assertTrue(matcher.find());
+		assertEquals("http://dstadler2.org/", matcher.group(2));
+
+		// what about newlines and other whitespaces
+		matcher = pattern
+				.matcher("<html><body><img\n \t\rid=\"laskdasdkj\"\n \rsrc \n =\r  \"http://dstadler1.org/\"/><img  \r  id=\" laskdasdkj\"    src    =   \"http://dstadler2.org/\"/></body></html>");
+		assertTrue(matcher.find());
+		assertEquals("http://dstadler1.org/", matcher.group(2));
+		assertTrue(matcher.find());
+		assertEquals("http://dstadler2.org/", matcher.group(2));
+
+        // what about real markup
+        matcher = pattern.matcher("<img alt=\"Chart?ck=xradar&amp;w=120&amp;h=120&amp;c=7fff00|7fff00&amp;m=4&amp;g=0\" src=\"/chart?ck=xradar&amp;w=120&amp;h=120&amp;c=7fff00|7fff00&amp;m=4&amp;g=0.2&amp;l=A,C,S,T&amp;v=3.0,3.0,2.0,2.0\"");
+        assertTrue(matcher.find());
+        // assertEquals("/chart?ck=xradar&w=120&h=120&c=7fff00|7fff00&m=4&g=0.2&l=A,C,S,T&v=3.0,3.0,2.0,2.0", matcher.group(2));
+	}
+}

Added: commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java?rev=961524&view=auto
==============================================================================
--- commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java (added)
+++ commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java Wed Jul  7 22:26:19 2010
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.mail.mocks;
+
+import org.apache.commons.mail.ImageHtmlEmail;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.mail.MessagingException;
+
+/**
+ * Extension of the ImageHtmlEmail Class
+ * (used to allow testing only)
+ *
+ */
+public class MockImageHtmlEmailConcrete extends ImageHtmlEmail
+{
+    /**
+     * Retrieve the message content
+     * @return Message Content
+     */
+    public String getMsg()
+    {
+        try
+        {
+            return this.getPrimaryBodyPart().getContent().toString();
+        }
+        catch (IOException ioE)
+        {
+            return null;
+        }
+        catch (MessagingException msgE)
+        {
+            return null;
+        }
+    }
+
+    /**
+     * Retrieve the text msg
+     * @return Message Content
+     */
+    public String getTextMsg()
+    {
+        return this.text;
+    }
+
+    /**
+     * Retrieve the html msg
+     * @return Message Content
+     */
+    public String getHtmlMsg()
+    {
+        return this.html;
+    }
+
+    /**
+     * @return inlineEmbeds
+     */
+	public Map getInlineEmbeds()
+    {
+        return inlineEmbeds;
+    }
+}



Mime
View raw message