You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by sg...@apache.org on 2010/07/30 20:13:57 UTC

svn commit: r980903 - in /turbine/fulcrum/trunk/commonsemail: ./ src/java/ src/java/org/apache/fulcrum/commonsemail/ src/java/org/apache/fulcrum/commonsemail/impl/ src/test/org/apache/fulcrum/commonsemail/ xdocs/

Author: sgoeschl
Date: Fri Jul 30 18:13:56 2010
New Revision: 980903

URL: http://svn.apache.org/viewvc?rev=980903&view=rev
Log:
Syncing with production code

Added:
    turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/NullOutputStream.java
Modified:
    turbine/fulcrum/trunk/commonsemail/pom.xml
    turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties
    turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java
    turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/SendDeliveryStatus.java
    turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailDomainEntry.java
    turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailUtils.java
    turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/SendDeliveryStatusImpl.java
    turbine/fulcrum/trunk/commonsemail/src/test/org/apache/fulcrum/commonsemail/CommonsEmailServiceTest.java
    turbine/fulcrum/trunk/commonsemail/xdocs/changes.xml
    turbine/fulcrum/trunk/commonsemail/xdocs/configuration.xml

Modified: turbine/fulcrum/trunk/commonsemail/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/pom.xml?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/pom.xml (original)
+++ turbine/fulcrum/trunk/commonsemail/pom.xml Fri Jul 30 18:13:56 2010
@@ -66,25 +66,9 @@
       <version>4.3.1</version>
     </dependency>
     <dependency>
-      <groupId>javax.activation</groupId>
-      <artifactId>activation</artifactId>
-      <version>1.1</version>
-    </dependency>
-    <dependency>
       <groupId>commons-email</groupId>
       <artifactId>commons-email</artifactId>
-      <version>1.0</version>
-      <exclusions>
-        <exclusion>
-          <groupId>dumbster</groupId>
-          <artifactId>dumbster</artifactId>
-        </exclusion>
-      </exclusions>      
-    </dependency>
-    <dependency>
-      <groupId>javax.mail</groupId>
-      <artifactId>mail</artifactId>
-      <version>1.4.1</version>
+      <version>1.2</version>
     </dependency>
     <!-- testing dependencies -->
     <dependency>

Modified: turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties (original)
+++ turbine/fulcrum/trunk/commonsemail/src/java/log4j.properties Fri Jul 30 18:13:56 2010
@@ -27,9 +27,3 @@ log4j.rootLogger=debug, stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
-
-#
-# Supress messages
-#
-
-log4j.logger.org.pdfbox=WARN

Modified: turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java (original)
+++ turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/CommonsEmailService.java Fri Jul 30 18:13:56 2010
@@ -158,8 +158,15 @@ public interface CommonsEmailService
     
     /**
      * Sends an email using the service instead of calling send()
-     * directly on the Email. The implementation uses the
-     * the from email address as domain name.
+     * directly on the Email.
+     *
+     * The implementation uses the the following mechanism to obtain
+     * the domain configuration
+     * <ul>
+     *   <li>use the email from address, e.g. "siegfried.goeschl@it20one.at"</li>
+     *   <li>use the email domain, e.g. "it20one.at" </li>
+     *   <li>use the configured default domain</li>
+     * </ul>
      * 
      * @param email the email to be sent
      * @return the MimeMessage being sent
@@ -213,8 +220,10 @@ public interface CommonsEmailService
     	throws MessagingException;
 
     /**
-     * Get the delivery status of the previously sent email. This
-     * allows to do something sensible if email delivery failed.
+     * Get the delivery status of the previously sent email. The mail
+     * implementation provides hook to get notification from the mail
+     * server regarding message delivery, e.g. a mail server might report
+     * that a message will not be relayed to the recipient
      *
      * @param mimeMessage the email sent
      * @return the delivery status

Modified: turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/SendDeliveryStatus.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/SendDeliveryStatus.java?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/SendDeliveryStatus.java (original)
+++ turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/SendDeliveryStatus.java Fri Jul 30 18:13:56 2010
@@ -28,6 +28,13 @@ import javax.mail.Address;
 public interface SendDeliveryStatus
 {
     /**
+     * Returns the message of of the corresponding email.
+     *
+     * @return mime message id
+     */
+    String getMessageId();
+
+    /**
      * Returns true only if ALL recipients were accepted by the
      * mailserver, i.e. everything is okay.
      *
@@ -36,6 +43,13 @@ public interface SendDeliveryStatus
     boolean hasSucceeded();
 
     /**
+     * Get all of the original recipients from the mime message.
+     *
+     * @return list of email addresses
+     */
+    Address[] getAllRecipients();
+
+    /**
      * The list of mail addresses accepted by the mailserver.
      *
      * @return list of email addresses
@@ -55,4 +69,11 @@ public interface SendDeliveryStatus
      * @return list of email addresses
      */        
     Address[] getInvalidAddresses();
+
+    /**
+     * Return the number of all recipients.
+     *
+     * @return overall number of recipients
+     */
+    int size();
 }
\ No newline at end of file

Modified: turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailDomainEntry.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailDomainEntry.java?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailDomainEntry.java (original)
+++ turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailDomainEntry.java Fri Jul 30 18:13:56 2010
@@ -543,14 +543,7 @@ public class CommonsEmailDomainEntry
      */
     public boolean hasAuthentication()
     {
-        if( this.authType.equals(AUTH_NONE) )
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
+        return !this.authType.equals( AUTH_NONE );
     }
 
     /**
@@ -558,14 +551,7 @@ public class CommonsEmailDomainEntry
      */
     public boolean hasSmtpAuthentication()
     {
-        if( this.authType.equals(AUTH_SMTP) )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
+        return this.authType.equals( AUTH_SMTP );
     }
 
     /**
@@ -573,14 +559,7 @@ public class CommonsEmailDomainEntry
      */
     public boolean hasPopBeforeSmtpAuthentication()
     {
-        if( this.authType.equals(AUTH_POPBEFORESMTP) )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
+        return this.authType.equals( AUTH_POPBEFORESMTP );
     }
     
     /**

Modified: turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailUtils.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailUtils.java?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailUtils.java (original)
+++ turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/CommonsEmailUtils.java Fri Jul 30 18:13:56 2010
@@ -19,10 +19,15 @@ package org.apache.fulcrum.commonsemail.
  * under the License.
  */
 
+import org.omg.CORBA_2_3.portable.InputStream;
+
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
 
 import javax.mail.internet.MimeMessage;
+import javax.mail.Session;
 
 /**
  * Static helper methods.
@@ -65,7 +70,6 @@ public class CommonsEmailUtils
                 try
                 {
                     fos.close();
-                    fos = null;
                 }
                 catch( Exception e )
                 {
@@ -74,4 +78,54 @@ public class CommonsEmailUtils
             }
         }
     }
+
+    /**
+     * Convinience method to read a MimeMessage from a source.
+     *
+     * @param session the mail session
+     * @param source the source of the MimeMessage
+     * @throws Exception reading the MimeMessage failed
+     * @return the MimeMessage
+     */
+    public static MimeMessage readMimeMessage(Session session, Object source) throws Exception
+    {
+
+        MimeMessage result = null;
+
+        if(source instanceof InputStream)
+        {
+            result = new MimeMessage(session, (InputStream) source);
+        }
+        else if(source instanceof byte[])
+        {
+            ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) source);
+            result = new MimeMessage(session, bais);
+            bais.close();
+        }
+        else if(source instanceof File)
+        {
+            FileInputStream fis = null;
+
+            try
+            {
+                fis = new FileInputStream((File) source);
+                result = new MimeMessage(session, fis);
+                fis.close();
+            }
+            catch(Exception e)
+            {
+                if(fis != null)
+                {
+                    fis.close();
+                }
+            }
+        }
+        else
+        {
+            String msg = "Failed to read message from " + source.getClass().getName();
+            throw new IllegalArgumentException(msg);
+        }
+
+        return result;
+    }
 }

Added: turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/NullOutputStream.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/NullOutputStream.java?rev=980903&view=auto
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/NullOutputStream.java (added)
+++ turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/NullOutputStream.java Fri Jul 30 18:13:56 2010
@@ -0,0 +1,104 @@
+package org.apache.fulcrum.commonsemail.impl;
+
+/*
+ * 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.
+ */
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * An output stream doing nothing with the written data.
+ */
+public class NullOutputStream extends OutputStream
+{
+    /**
+     * Creates a new byte array output stream. The buffer capacity is
+     * initially 32 bytes, though its size increases if necessary.
+     */
+    public NullOutputStream()
+    {
+    }
+
+    /**
+     * Writes the specified byte to this byte array output stream.
+     *
+     * @param b the byte to be written.
+     */
+    public synchronized void write( int b )
+    {
+    }
+
+    /**
+     * Writes <code>len</code> bytes from the specified byte array
+     * starting at offset <code>off</code> to this byte array output stream.
+     *
+     * @param b the data.
+     * @param off the start offset in the data.
+     * @param len the number of bytes to write.
+     */
+    public synchronized void write( byte b[], int off, int len )
+    {
+    }
+
+    /**
+     * Resets the <code>count</code> field of this byte array output
+     * stream to zero, so that all currently accumulated output in the
+     * ouput stream is discarded. The output stream can be used again,
+     * reusing the already allocated buffer space.
+     *
+     * @see java.io.ByteArrayInputStream#count
+     */
+    public synchronized void reset()
+    {
+    }
+
+    /**
+     * Returns the current size of the buffer.
+     *
+     * @return the value of the <code>count</code> field, which is the number
+     *         of valid bytes in this output stream.
+     * @see java.io.ByteArrayOutputStream#count
+     */
+    public int size()
+    {
+        return 0;
+    }
+
+    /**
+     * Converts the buffer's contents into a string, translating bytes into
+     * characters according to the platform's default character encoding.
+     *
+     * @return String translated from the buffer's contents.
+     * @since JDK1.1
+     */
+    public String toString()
+    {
+        return new String();
+    }
+
+    /**
+     * Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in
+     * this class can be called after the stream has been closed without
+     * generating an <tt>IOException</tt>.
+     * <p/>
+     */
+    public void close() throws IOException
+    {
+    }
+}

Modified: turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/SendDeliveryStatusImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/SendDeliveryStatusImpl.java?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/SendDeliveryStatusImpl.java (original)
+++ turbine/fulcrum/trunk/commonsemail/src/java/org/apache/fulcrum/commonsemail/impl/SendDeliveryStatusImpl.java Fri Jul 30 18:13:56 2010
@@ -23,37 +23,54 @@ import org.apache.fulcrum.commonsemail.S
 
 import javax.mail.Address;
 import javax.mail.event.TransportEvent;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
- * Keep track of the delivery status of a single email.
+ * Keep track of the delivery status of a single email. Please note
+ * that using a set is a deliberate decision - assuming that the same
+ * address shows up in 'to' and 'cc' the email would be sent only
+ * once.
  *
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
 
 public class SendDeliveryStatusImpl implements SendDeliveryStatus
 {
-    private List validSentAddressList;
-    private List validUnsentAddressList;
-    private List invalidAddressList;
+    /** the message id from the email */
+    private String messageId;
+
+    /** the original list of recipients */
+    private HashSet allRecipients;
+
+    /** the list of valid addresses where an email is going to be delivered */
+    private Set validSentAddressList;
+
+    /** the list of valid addresses where an email is NOT going to be delivered */
+    private Set validUnsentAddressList;
+
+    /** the list of invalid addresses */
+    private Set invalidAddressList;
 
     /**
      * Constructor.
+     *
+     * @param allRecipients the list of all recipients
      */
-    SendDeliveryStatusImpl()
+    SendDeliveryStatusImpl(Address[] allRecipients)
     {
-        this.validSentAddressList = new ArrayList();
-        this.validUnsentAddressList = new ArrayList();
-        this.invalidAddressList = new ArrayList();        
+        this.allRecipients = new HashSet();
+        this.addAddresses( this.allRecipients, allRecipients );
+        
+        this.validSentAddressList = new HashSet();
+        this.validUnsentAddressList = new HashSet();
+        this.invalidAddressList = new HashSet();
     }
 
     /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#hasSucceeded()  */
     public boolean hasSucceeded()
     {
-        if((this.validSentAddressList.size() > 0) &&
-           (this.validUnsentAddressList.size() == 0) &&
-           (this.invalidAddressList.size() == 0 ))
+        if(this.allRecipients.equals(this.validSentAddressList))
         {
             return true;
         }
@@ -66,24 +83,42 @@ public class SendDeliveryStatusImpl impl
     /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#getValidSentAddresses()  */
     public Address[] getValidSentAddresses()
     {
-        List currList = this.validSentAddressList;
+        Set currList = this.validSentAddressList;
         return (Address[]) currList.toArray(new Address[currList.size()]);
     }
 
     /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#getValidUnsentAddresses()  */
     public Address[] getValidUnsentAddresses()
     {
-        List currList = this.validUnsentAddressList; 
+        Set currList = this.validUnsentAddressList;
         return (Address[]) currList.toArray(new Address[currList.size()]);
     }
 
     /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#getInvalidAddresses()  */
     public Address[] getInvalidAddresses()
     {
-        List currList = this.invalidAddressList; 
+        Set currList = this.invalidAddressList; 
         return (Address[]) currList.toArray(new Address[currList.size()]);
     }
 
+    /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#getAllRecipients() */
+    public Address[] getAllRecipients()
+    {
+        return (Address[]) this.allRecipients.toArray(new Address[this.allRecipients.size()]);
+    }
+
+    /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#size()  */
+    public int size()
+    {
+        return this.allRecipients.size();
+    }
+
+    /** @see org.apache.fulcrum.commonsemail.SendDeliveryStatus#getMessageId()  */    
+    public String getMessageId()
+    {
+        return messageId;
+    }
+
     /** @see Object#toString() */
     public String toString()
     {
@@ -92,6 +127,9 @@ public class SendDeliveryStatusImpl impl
         result.append('@');
         result.append(Integer.toHexString(this.hashCode()));
         result.append(' ');
+        result.append("allRecipients:");
+        result.append(this.allRecipients.size());
+        result.append(',');
         result.append("validSentAddresses:");
         result.append(this.validSentAddressList.size());
         result.append(',');
@@ -126,12 +164,22 @@ public class SendDeliveryStatusImpl impl
     }
 
     /**
+     * The message id of the corresponding email
+     *
+     * @param messageId the message id
+     */
+    void setMessageId(String messageId)
+    {
+        this.messageId = messageId;    
+    }
+
+    /**
      * Add a list of addresses to the given target list
      *
      * @param target the target list
      * @param addressList the address list
      */
-    private void addAddresses(List target, Address[] addressList)
+    private void addAddresses(Set target, Address[] addressList)
     {
         if((addressList != null) && (addressList.length > 0))
         {

Modified: turbine/fulcrum/trunk/commonsemail/src/test/org/apache/fulcrum/commonsemail/CommonsEmailServiceTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/src/test/org/apache/fulcrum/commonsemail/CommonsEmailServiceTest.java?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/src/test/org/apache/fulcrum/commonsemail/CommonsEmailServiceTest.java (original)
+++ turbine/fulcrum/trunk/commonsemail/src/test/org/apache/fulcrum/commonsemail/CommonsEmailServiceTest.java Fri Jul 30 18:13:56 2010
@@ -114,7 +114,9 @@ public class CommonsEmailServiceTest ext
         {            
             try
             {
-                File resultFile = new File( new File("temp"), this.getName()+".eml" );
+                File resultDirectory = new File("./target/temp");
+                resultDirectory.mkdirs();
+                File resultFile = new File( resultDirectory, this.getName()+".eml" );
                 FileOutputStream fos = new FileOutputStream(resultFile);
                 this.result.writeTo(fos);
                 fos.flush();
@@ -131,7 +133,9 @@ public class CommonsEmailServiceTest ext
     }
     
     /**
-     * Add all of our test suites
+     * Add all of our test suites.
+     *
+     * @return the tests to execute
      */
     public static Test suite()
     {
@@ -210,7 +214,9 @@ public class CommonsEmailServiceTest ext
     /////////////////////////////////////////////////////////////////////////
 
     /**
-     * Create a simple email and send it. 
+     * Create a simple email and send it.
+     *
+     * @throws Exception the test failed 
      */
     public void testSimpleEmail() throws Exception
     {
@@ -224,7 +230,9 @@ public class CommonsEmailServiceTest ext
     }
 
     /**
-     * Create a HTML email and send it. 
+     * Create a HTML email and send it.
+     *
+     * @throws Exception the test failed 
      */
     public void testHtmlEmail() throws Exception
     {
@@ -239,7 +247,9 @@ public class CommonsEmailServiceTest ext
     }
     
     /**
-     * Create a MultiPart email and send it. 
+     * Create a MultiPart email and send it.
+     *
+     * @throws Exception the test failed 
      */
     public void testMultiPartEmail() throws Exception
     {
@@ -257,7 +267,7 @@ public class CommonsEmailServiceTest ext
     /**
      * Use an undefined domain therefore reverting to the default domain.
      * 
-     * @throws Exception
+     * @throws Exception the test failed
      */
     public void testDefaultDomain() throws Exception
     {
@@ -273,7 +283,7 @@ public class CommonsEmailServiceTest ext
     /**
      * We pass "demo@it20one.at" therefore we should get the "it20one.at" domain
      * 
-     * @throws Exception
+     * @throws Exception the test failed
      */
     public void testDerivedDomain() throws Exception
     {
@@ -290,7 +300,7 @@ public class CommonsEmailServiceTest ext
     /**
      * Create a HTML email using a Hashtable as input.
      * 
-     * @throws Exception
+     * @throws Exception the test failed
      */
     public void testHtmlEmailWithHashtable() throws Exception
     {
@@ -317,7 +327,7 @@ public class CommonsEmailServiceTest ext
     /**
      * Create a simple email using a Hashtable as input.
      * 
-     * @throws Exception
+     * @throws Exception the test failed
      */
     public void testSimpleEmailWithHashtable() throws Exception
     {
@@ -340,6 +350,8 @@ public class CommonsEmailServiceTest ext
      * resulting in an EmailException. For this test we
      * overwrite the SMTP server and port taken from the
      * domain configuration.
+     *
+     * @throws Exception the test failed
      */
     public void testSendEmailToUnknownServer() throws Exception
     {
@@ -372,12 +384,13 @@ public class CommonsEmailServiceTest ext
     }
     
     /**
-     * Create a mail session and simple MimeMessage and sent it 
+     * Create a mail session and simple MimeMessage and sent it.
+     *  
      * @throws Exception the test failed
      */
     public void testCreateMimeMessageWithSession() throws Exception
     {
-        MimeMessage mimeMessage = null;
+        MimeMessage mimeMessage;
         Session session = this.getService().createSmtpSession("test","foo","bar");
         
         mimeMessage = new MimeMessage(session);
@@ -386,19 +399,22 @@ public class CommonsEmailServiceTest ext
         mimeMessage.setText(PLAIN_CONTENT);
         mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(this.mailTo));
 
-        this. result = this.getService().send(
+        this.result = this.getService().send(
             session,
             mimeMessage
             );
+
+        assertNotNull( this.result.getMessageID() );
     }
+    
     /**
-     * Use commons-email to build a MimeMessage and send it directly
+     * Use commons-email to build a MimeMessage and send it directly.
      * 
-     * @throws Exception
+     * @throws Exception the test failed
      */
     public void testSendMimeMessage() throws Exception
     {
-        MimeMessage mimeMessage = null;
+        MimeMessage mimeMessage;
         SimpleEmail email = this.getService().createSimpleEmail(this.getDomain());
         
         email.setSubject(this.getSubject());        
@@ -408,14 +424,39 @@ public class CommonsEmailServiceTest ext
         email.buildMimeMessage();
         mimeMessage = email.getMimeMessage();
         
-        this. result = this.getService().send(
+        this.result = this.getService().send(
             email.getMailSession(),
             mimeMessage
             );
+
+        assertNotNull( this.result.getMessageID() );
+    }
+
+    /**
+     * Use commons-email to build a MimeMessage and send it directly but
+     * without specifying a domain.
+     *
+     * @throws Exception the test failed
+     */
+    public void testSendMimeMessageWithoutDomain() throws Exception
+    {
+        SimpleEmail email = this.getService().createSimpleEmail("siegfried.goeschl@it20one.at");
+
+        email.setSubject(this.getSubject());
+        email.setMsg(PLAIN_CONTENT);
+        email.addTo(this.getMailTo());
+
+        this.result = this.getService().send(
+            email
+            );
+
+        assertNotNull( this.result.getMessageID() );
     }
 
     /**
-     * Create a simple email, send it and verify deliver status
+     * Create a simple email, send it and verify deliver status.
+     *
+     * @throws Exception the test failed
      */
     public void testGetSendDeliveryStatus() throws Exception
     {
@@ -432,65 +473,44 @@ public class CommonsEmailServiceTest ext
         SendDeliveryStatus sendDeliveryStatus = this.getService().getSendDeliveryStatus( this.result );
         assertTrue( sendDeliveryStatus.hasSucceeded() );
         assertTrue( sendDeliveryStatus.getValidSentAddresses().length >= 1);
+        assertTrue( sendDeliveryStatus.size() >= 0);
     }
 
     /**
-     * A manual test for a failed email delivery. The result depends heavily on
-     * you mail server setup ... :-(
+     * A test for a failed email delivery. The result depends heavily on
+     * you mail server setup so there is no way to check for success ... :-(
+     *
+     * @throws Exception the test failed
      */
-    public void _testGetSendDeliveryStatusFailure() throws Exception
+    public void testGetSendDeliveryStatusFailure() throws Exception
     {
+        MimeMessage mimeMessage;
         SimpleEmail email = this.getService().createSimpleEmail(this.getDomain());
 
         email.setSubject(this.getSubject());
         email.setMsg(PLAIN_CONTENT);
         email.addTo("foo@bar.com");
 
+        email.buildMimeMessage();
+        mimeMessage = email.getMimeMessage();
+
         try
         {
-            this.result = this.getService().send(this.getDomain(),email);
+            this.result = this.getService().send(
+                this.getDomain(),
+                email.getMailSession(),
+                mimeMessage
+                );
+ 
             SendDeliveryStatus sendDeliveryStatus = this.getService().getSendDeliveryStatus( this.result );
             assertTrue( sendDeliveryStatus.hasSucceeded() );
             assertTrue( sendDeliveryStatus.getValidSentAddresses().length >= 1);
         }
         catch(Exception e)
         {
-            SendDeliveryStatus sendDeliveryStatus = this.getService().getSendDeliveryStatus( this.result );
-            assertTrue( sendDeliveryStatus.hasSucceeded() == false);
-        }
-    }
-
-    public void _testBulkEmailSending() throws Exception
-    {
-        File sourceDir = new File("./temp");
-        File[] fileList = sourceDir.listFiles();
-
-        for(int i=0; i<fileList.length; i++)
-        {
-            if(fileList[i].isFile())
-            {
-                MultiPartEmail email = this.getService().createMultiPartEmail("it20one.at");
-                EmailAttachment attachment = new EmailAttachment();
-                attachment.setPath(fileList[i].getAbsolutePath());
-                attachment.setDisposition(EmailAttachment.ATTACHMENT);
-                attachment.setName(attachment.getName());
-                attachment.setDescription(attachment.getName());
-
-                String subject = "Invoice Nr." + i;
-                email.setSubject(subject);
-                email.attach(attachment);
-                email.addTo(this.getMailTo());
-                email.setMsg(PLAIN_CONTENT);
-
-                System.out.println("Sending " + subject + " ...");
-
-                try
-                {
-                    this.result = this.getService().send("it20one.at",email);
-                }
-                catch(Exception e)
-                {}
-            }
+            SendDeliveryStatus sendDeliveryStatus = this.getService().getSendDeliveryStatus( mimeMessage );
+            assertNotNull( sendDeliveryStatus );
+            assertFalse( sendDeliveryStatus.hasSucceeded() );
         }
     }
 }

Modified: turbine/fulcrum/trunk/commonsemail/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/xdocs/changes.xml?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/xdocs/changes.xml (original)
+++ turbine/fulcrum/trunk/commonsemail/xdocs/changes.xml Fri Jul 30 18:13:56 2010
@@ -24,7 +24,10 @@
   </properties>
 
   <body>
-    <release version="1.0.0-dev" date="as in SVN">
+    <release version="1.0.0-SNAPSHOT" date="as in SVN">
+      <action dev="sgoeschl" type="update">
+        Synching with production code.
+      </action>
       <action dev="sgoeschl" type="update">
         Providing SendDeliveryStatus to keep track of the email delivery status, i.e.
         to whom the email was NOT send

Modified: turbine/fulcrum/trunk/commonsemail/xdocs/configuration.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/commonsemail/xdocs/configuration.xml?rev=980903&r1=980902&r2=980903&view=diff
==============================================================================
--- turbine/fulcrum/trunk/commonsemail/xdocs/configuration.xml (original)
+++ turbine/fulcrum/trunk/commonsemail/xdocs/configuration.xml Fri Jul 30 18:13:56 2010
@@ -177,6 +177,15 @@
             </td>
           </tr>
           <tr>
+            <td>domains\domain\mailCharset</td>
+            <td>String</td>
+            <td>[0|1]</td>
+            <td>
+            	The mail character set to use, e.g. "ISO-8859-1" to solve
+            	problems with national characters in the message
+            </td>
+          </tr>
+          <tr>
             <td>domains\domain\mailDump</td>
             <td>Boolean</td>
             <td>[0|1]</td>