You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2001/04/12 03:16:23 UTC

cvs commit: xml-batik/test-sources/org/apache/batik/test TestReportMailer.java

vhardy      01/04/11 18:16:23

  Modified:    test-sources/org/apache/batik/test TestReportMailer.java
  Log:
  Destination email is now a comma separated list.
  
  Revision  Changes    Path
  1.2       +30 -6     xml-batik/test-sources/org/apache/batik/test/TestReportMailer.java
  
  Index: TestReportMailer.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/test/TestReportMailer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestReportMailer.java	2001/04/10 22:10:27	1.1
  +++ TestReportMailer.java	2001/04/12 01:16:22	1.2
  @@ -11,12 +11,14 @@
   import javax.mail.Session;
   import javax.mail.Message;
   import javax.mail.Transport;
  +import javax.mail.internet.AddressException;
   import javax.mail.internet.MimeBodyPart;
   import javax.mail.internet.MimeMultipart;
   import javax.mail.internet.MimeMessage;
   import javax.mail.internet.InternetAddress;
   
   import java.util.Properties;
  +import java.util.StringTokenizer;
   
   import java.io.PrintWriter;
   import java.io.StringWriter;
  @@ -27,10 +29,16 @@
    * their respective owners.
    *
    * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
  - * @version $Id: TestReportMailer.java,v 1.1 2001/04/10 22:10:27 vhardy Exp $
  + * @version $Id: TestReportMailer.java,v 1.2 2001/04/12 01:16:22 vhardy Exp $
    */
   public class TestReportMailer implements TestReportProcessor {
       /**
  +     * Separators allowed to separate email addresses for the 
  +     * destination addresses.
  +     */
  +    public static final String ADDRESS_SEPARATORS = ",";
  +
  +    /**
        * System property used to specify the SMTP server
        */
       public static final String SYSTEM_PROPERTY_SMTP_HOST 
  @@ -56,16 +64,20 @@
       /**
        * Destination email address
        */
  -    private String reportDestinationAddress;
  +    private String reportDestinationAddressList;
   
       /**
  -     * Constructor
  +     * Constructor.
  +     * @param reportSourceAddress address to use as the source of the report
  +     * @param reportDestinationAddressList comma separated list of addresses where the
  +     *        report should be sent.
  +     * @param mailServer server which will send the email.
        */
       public TestReportMailer(String reportSourceAddress,
  -                            String reportDestinationAddress,
  +                            String reportDestinationAddressList,
                               String mailServer){
           this.reportSourceAddress = reportSourceAddress;
  -        this.reportDestinationAddress = reportDestinationAddress;
  +        this.reportDestinationAddressList = reportDestinationAddressList;
           this.mailServer = mailServer;
       }
   
  @@ -99,7 +111,7 @@
               
               MimeMessage msg = new MimeMessage(session);
               InternetAddress[] dest 
  -                = {new InternetAddress(reportDestinationAddress)};
  +                = convertAddressList(reportDestinationAddressList);
               msg.setRecipients(Message.RecipientType.TO, dest);
   
               String mailReportSubject 
  @@ -132,7 +144,19 @@
           }
       }
   
  +    protected InternetAddress[] convertAddressList(String addressList)
  +        throws AddressException {
   
  +        StringTokenizer st = new StringTokenizer(addressList, ADDRESS_SEPARATORS);
  +        InternetAddress[] addresses = new InternetAddress[st.countTokens()];
  +        int i=0;
  +        while(st.hasMoreElements()){
  +            addresses[i] = new InternetAddress(st.nextToken());
  +            i++;
  +        }
  +
  +        return addresses;
  +    }
   }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org