Package org.apache.commons.mail.mocks

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


        // ====================================================================
        // bad encoding
        try
        {
            // reset the mail class
            MockEmailConcrete anotherEmail = new MockEmailConcrete();
            // set a dodgy encoding scheme
            anotherEmail.setCharset("bad.encoding\uc5ec\n");
            // set a valid address but bad personal name
            anotherEmail.addCc("me@home.com", "\t.bad.name.\uc5ec\n");
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            assertTrue(true);
View Full Code Here


        // ====================================================================
        // bad encoding
        try
        {
            // reset the mail class
            MockEmailConcrete anotherEmail = new MockEmailConcrete();
            // set a dodgy encoding scheme
            anotherEmail.setCharset("bad.encoding\uc5ec\n");
            // set a valid address but bad personal name
            anotherEmail.addBcc("me@home.com", "\t.bad.name.\uc5ec\n");
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            assertTrue(true);
View Full Code Here

        // ====================================================================
        // bad encoding
        try
        {
            // reset the mail class
            MockEmailConcrete anotherEmail = new MockEmailConcrete();
            // set a dodgy encoding scheme
            anotherEmail.setCharset("bad.encoding\uc5ec\n");
            // set a valid address but bad personal name
            anotherEmail.addReplyTo("me@home.com", "\t.bad.name.\uc5ec\n");
            fail("Should have thrown an exception");
        }
        catch (EmailException e)
        {
            assertTrue(true);
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);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail("Unexpected exception thrown");
        }

        // 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);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail("Unexpected exception thrown");
        }

        // ====================================================================
        // 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);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail("Unexpected exception thrown");
        }

        // 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);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail("Unexpected exception thrown");
        }

        // 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

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.