test.atlassian.mail.server
Class TestSMTPMailServer

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended bycom.atlassian.core.ofbiz.test.AbstractOFBizTestCase
              extended bytest.atlassian.mail.server.TestSMTPMailServer
All Implemented Interfaces:
junit.framework.Test

public class TestSMTPMailServer
extends com.atlassian.core.ofbiz.test.AbstractOFBizTestCase

Mails are basically sent by the thisSession.getTransport("smtp").send() method in the SMTPMailServerImpl class We have created an MockSMTPMailServer class that extends SMTPMailServerImpl but overrides the getSession() to return our MockSession. Our MockSession in turn returns our MockTransport when getTransport() is called on it. Finally and therefore, when getTransport("smtp") is called, our MockTransport is used and we can test if the message passed to it matches the message that we contruct and expect.


Constructor Summary
TestSMTPMailServer(java.lang.String s)
           
 
Method Summary
 void testConstructor()
           
 void testGetJNDIServer()
          Test case to verify JRA-1436
 void testGetSessionNoUser()
           
 void testGetSessionWithUser()
           
 void testGetsSets()
           
 void testIncorrectJndiClass()
          Test that if the class at the specified jndi location is not of the correct type, that an illegalargument exception is thrown.
 void testParseAddressPass(java.lang.String pAddress)
           
 void testSend()
           
 void testSendFail()
          Following tests moved over from TestMailFactory (since all send methods have been removed from there
 void testSendMail1()
           
 void testSendMail2()
           
 void testSendMail3()
           
 void testSendWithAttachment()
           
 
Methods inherited from class com.atlassian.core.ofbiz.test.AbstractOFBizTestCase
setUp
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestSMTPMailServer

public TestSMTPMailServer(java.lang.String s)
Method Detail

testConstructor

public void testConstructor()

testGetsSets

public void testGetsSets()

testGetSessionNoUser

public void testGetSessionNoUser()
                          throws javax.naming.NamingException,
                                 MailException
Throws:
javax.naming.NamingException
MailException

testGetSessionWithUser

public void testGetSessionWithUser()
                            throws javax.naming.NamingException,
                                   MailException
Throws:
javax.naming.NamingException
MailException

testSend

public void testSend()
              throws javax.naming.NamingException,
                     javax.mail.MessagingException,
                     javax.mail.internet.AddressException,
                     MailException
Throws:
javax.naming.NamingException
javax.mail.MessagingException
javax.mail.internet.AddressException
MailException

testSendWithAttachment

public void testSendWithAttachment()
                            throws javax.naming.NamingException,
                                   javax.mail.MessagingException,
                                   javax.mail.internet.AddressException,
                                   MailException,
                                   java.io.IOException
Throws:
javax.naming.NamingException
javax.mail.MessagingException
javax.mail.internet.AddressException
MailException
java.io.IOException

testParseAddressPass

public void testParseAddressPass(java.lang.String pAddress)
                          throws javax.mail.internet.AddressException
Throws:
javax.mail.internet.AddressException

testGetJNDIServer

public void testGetJNDIServer()
                       throws javax.naming.NamingException,
                              MailException
Test case to verify JRA-1436

Throws:
javax.naming.NamingException
MailException

testIncorrectJndiClass

public void testIncorrectJndiClass()
                            throws javax.naming.NamingException,
                                   MailException
Test that if the class at the specified jndi location is not of the correct type, that an illegalargument exception is thrown.

Throws:
javax.naming.NamingException
MailException

testSendFail

public void testSendFail()
                  throws java.lang.Exception
Following tests moved over from TestMailFactory (since all send methods have been removed from there

Throws:
java.lang.Exception

testSendMail1

public void testSendMail1()
                   throws java.lang.Exception,
                          javax.mail.MessagingException,
                          org.apache.velocity.exception.VelocityException
Throws:
java.lang.Exception
javax.mail.MessagingException
org.apache.velocity.exception.VelocityException

testSendMail2

public void testSendMail2()
                   throws java.lang.Exception,
                          javax.mail.MessagingException,
                          org.apache.velocity.exception.VelocityException
Throws:
java.lang.Exception
javax.mail.MessagingException
org.apache.velocity.exception.VelocityException

testSendMail3

public void testSendMail3()
                   throws java.lang.Exception,
                          javax.mail.MessagingException,
                          javax.mail.internet.AddressException,
                          org.apache.velocity.exception.VelocityException
Throws:
java.lang.Exception
javax.mail.MessagingException
javax.mail.internet.AddressException
org.apache.velocity.exception.VelocityException


Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.