Coverage Report - org.mule.transport.email.SmtpConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
SmtpConnector
0%
0/31
N/A
1.053
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.email;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.construct.FlowConstruct;
 11  
 import org.mule.api.endpoint.InboundEndpoint;
 12  
 import org.mule.api.transport.MessageReceiver;
 13  
 
 14  
 import java.util.Properties;
 15  
 
 16  
 /**
 17  
  * <code>SmtpConnector</code> is used to connect to and send data to an SMTP mail
 18  
  * server
 19  
  */
 20  
 public class SmtpConnector extends AbstractMailConnector
 21  
 {
 22  
 
 23  
     public static final String SMTP = "smtp";
 24  
     public static final String DEFAULT_SMTP_HOST = "localhost";
 25  
     public static final int DEFAULT_SMTP_PORT = 25;
 26  
     public static final String DEFAULT_CONTENT_TYPE = "text/plain";
 27  
 
 28  
     /**
 29  
      * Holds value of bcc addresses.
 30  
      */
 31  
     private String bcc;
 32  
 
 33  
     /**
 34  
      * Holds value of cc addresses.
 35  
      */
 36  
     private String cc;
 37  
 
 38  
     /**
 39  
      * Holds value of replyTo addresses.
 40  
      */
 41  
     private String replyTo;
 42  
 
 43  
     /**
 44  
      * Holds value of default subject
 45  
      */
 46  0
     private String defaultSubject = "[No Subject]";
 47  
 
 48  
     /**
 49  
      * Holds value of the from address.
 50  
      */
 51  
     private String from;
 52  
 
 53  
     /**
 54  
      * Any custom headers to be set on messages sent using this connector
 55  
      */
 56  0
     private Properties customHeaders = new Properties();
 57  
 
 58  0
     private String contentType = DEFAULT_CONTENT_TYPE;
 59  
 
 60  
     
 61  
     public SmtpConnector(MuleContext context)
 62  
     {
 63  0
         this(DEFAULT_SMTP_PORT, context);
 64  0
     }
 65  
     
 66  
     SmtpConnector(int defaultPort, MuleContext context)
 67  
     {
 68  0
         super(defaultPort, null, context);
 69  0
     }
 70  
     
 71  
     public String getProtocol()
 72  
     {
 73  0
         return "smtp";
 74  
     }
 75  
 
 76  
     public MessageReceiver createReceiver(FlowConstruct flowConstruct, InboundEndpoint endpoint) throws Exception
 77  
     {
 78  0
         throw new UnsupportedOperationException("Listeners cannot be registered on a SMTP endpoint");
 79  
     }
 80  
 
 81  
     /**
 82  
      * @return The default from address to use
 83  
      */
 84  
     public String getFromAddress()
 85  
     {
 86  0
         return from;
 87  
     }
 88  
 
 89  
     /**
 90  
      * @return the default comma separated list of BCC addresses to use
 91  
      */
 92  
     public String getBccAddresses()
 93  
     {
 94  0
         return bcc;
 95  
     }
 96  
 
 97  
     /**
 98  
      * @return the default comma separated list of CC addresses to use
 99  
      */
 100  
     public String getCcAddresses()
 101  
     {
 102  0
         return cc;
 103  
     }
 104  
 
 105  
     /**
 106  
      * @return the default message subject to use
 107  
      */
 108  
     public String getSubject()
 109  
     {
 110  0
         return defaultSubject;
 111  
     }
 112  
 
 113  
     public void setBccAddresses(String string)
 114  
     {
 115  0
         bcc = string;
 116  0
     }
 117  
 
 118  
     public void setCcAddresses(String string)
 119  
     {
 120  0
         cc = string;
 121  0
     }
 122  
 
 123  
     public void setSubject(String string)
 124  
     {
 125  0
         defaultSubject = string;
 126  0
     }
 127  
 
 128  
     public void setFromAddress(String string)
 129  
     {
 130  0
         from = string;
 131  0
     }
 132  
 
 133  
     public String getReplyToAddresses()
 134  
     {
 135  0
         return replyTo;
 136  
     }
 137  
 
 138  
     public void setReplyToAddresses(String replyTo)
 139  
     {
 140  0
         this.replyTo = replyTo;
 141  0
     }
 142  
 
 143  
     public Properties getCustomHeaders()
 144  
     {
 145  0
         return customHeaders;
 146  
     }
 147  
 
 148  
     public void setCustomHeaders(Properties customHeaders)
 149  
     {
 150  0
         this.customHeaders = customHeaders;
 151  0
     }
 152  
 
 153  
     public String getContentType()
 154  
     {
 155  0
         return contentType;
 156  
     }
 157  
 
 158  
     public void setContentType(String contentType)
 159  
     {
 160  0
         this.contentType = contentType;
 161  0
     }
 162  
 
 163  
     public int getDefaultPort()
 164  
     {
 165  0
         return DEFAULT_SMTP_PORT;
 166  
     }
 167  
 
 168  
 }