Package org.apache.commons.mail.mocks

Examples of org.apache.commons.mail.mocks.MockEmailConcrete


        // ====================================================================
        // Test Exceptions
        // ====================================================================
        // reset the mail class
        MockEmailConcrete anotherEmail = new MockEmailConcrete();

        // bad encoding
        try
        {
            // set a dodgy encoding scheme
            anotherEmail.addTo("me@home.com", "me@home.com", "bad.encoding\uc5ec\n");
            fail("setting invalid charset should have failed!");
        }
        catch (IllegalCharsetNameException  e)
        {
            // expected runtime exception.
View Full Code Here


        // ====================================================================
        // Test Exceptions
        // ====================================================================
        // reset the mail class
        MockEmailConcrete anotherEmail = new MockEmailConcrete();

        // bad encoding
        try
        {
            // set a dodgy encoding scheme
            anotherEmail.addCc("me@home.com", "me@home.com", "bad.encoding\uc5ec\n");
            fail("setting invalid charset should have failed!");
        }
        catch (IllegalCharsetNameException e)
        {
            // expected runtime exception.
View Full Code Here

        // ====================================================================
        // Test Exceptions
        // ====================================================================
        // reset the mail class
        MockEmailConcrete anotherEmail = new MockEmailConcrete();

        // bad encoding
        try
        {
            // set a dodgy encoding scheme
            anotherEmail.addBcc("me@home.com", "me@home.com", "bad.encoding\uc5ec\n");
            fail("setting invalid charset should have failed!");
        }
        catch (IllegalCharsetNameException e)
        {
            // expected runtime exception.
View Full Code Here

        // ====================================================================
        // Test Exceptions
        // ====================================================================
        // reset the mail class
        MockEmailConcrete anotherEmail = new MockEmailConcrete();

        // bad encoding
        try
        {
            // set a dodgy encoding scheme
            anotherEmail.addReplyTo("me@home.com", "me@home.com", "bad.encoding\uc5ec\n");
            fail("setting invalid charset should have failed!");
        }
        catch (IllegalCharsetNameException e)
        {
            // expected runtime exception.
View Full Code Here

        // hostname not set
        try
        {
            this.getMailServer();

            this.email = new MockEmailConcrete();
            this.email.send();
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            this.fakeMailServer.stop();
            assertTrue(true);
        }

        // bad hostname
        try
        {
            this.getMailServer();

            this.email = new MockEmailConcrete();
            this.email.setSubject("Test Email #1 Subject");
            this.email.setHostName("bad.host.com");
            this.email.setFrom("me@home.com");
            this.email.addTo("me@home.com");
            this.email.addCc("me@home.com");
            this.email.addBcc("me@home.com");
            this.email.addReplyTo("me@home.com");

            this.email.setContent(
                "test string object",
                " ; charset=" + Email.US_ASCII);

            this.email.send();
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            assertTrue(e.getCause() instanceof ParseException);
            this.fakeMailServer.stop();
            assertTrue(true);
        }

        // ====================================================================
        // Test Exceptions (in send)
        // ====================================================================
        // from add not set
        try
        {
            this.getMailServer();

            this.email = new MockEmailConcrete();
            this.email.setHostName(this.strTestMailServer);
            this.email.setSmtpPort(this.getMailServerPort());

            this.email.send();
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            this.fakeMailServer.stop();
            assertTrue(true);
        }

        // destination (to/cc/bcc) dd not set
        try
        {
            this.getMailServer();

            this.email = new MockEmailConcrete();
            this.email.setHostName(this.strTestMailServer);
            this.email.setSmtpPort(this.getMailServerPort());
            this.email.setFrom("me@home.com");
            this.email.send();
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            this.fakeMailServer.stop();
            assertTrue(true);
        }

        // bad auth set
        try
        {
            this.getMailServer();

            this.email = new MockEmailConcrete();
            this.email.setHostName(this.strTestMailServer);
            this.email.setSmtpPort(this.getMailServerPort());
            this.email.setFrom(this.strTestMailFrom);
            this.email.addTo(this.strTestMailTo);
            this.email.setAuthentication(null, null);
View Full Code Here

    @Before
    public void setUpEmailTest()
    {
        // reusable objects to be used across multiple tests
        email = new MockEmailConcrete();
    }
View Full Code Here

    @Test(expected = EmailException.class)
    public void testSendNoHostName() throws Exception
    {
        getMailServer();

        email = new MockEmailConcrete();
        email.send();
    }
View Full Code Here

    {
        try
        {
            getMailServer();

            email = new MockEmailConcrete();
            email.setSubject("Test Email #1 Subject");
            email.setHostName("bad.host.com");
            email.setFrom("me@home.com");
            email.addTo("me@home.com");
            email.addCc("me@home.com");
View Full Code Here

    @Test(expected = EmailException.class)
    public void testSendFromNotSet() throws Exception
    {
         getMailServer();

         email = new MockEmailConcrete();
         email.setHostName(strTestMailServer);
         email.setSmtpPort(getMailServerPort());

         email.send();
    }
View Full Code Here

    @Test(expected = EmailException.class)
    public void testSendDestinationNotSet() throws Exception
    {
        getMailServer();

        email = new MockEmailConcrete();
        email.setHostName(strTestMailServer);
        email.setSmtpPort(getMailServerPort());
        email.setFrom("me@home.com");

        email.send();
View Full Code Here

TOP

Related Classes of org.apache.commons.mail.mocks.MockEmailConcrete

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.