Package org.apache.james.protocols.smtp

Examples of org.apache.james.protocols.smtp.SMTPSession


    public void testSpam() throws IOException, MessagingException {

        int port = PortUtil.getNonPrivilegedPort();
        new Thread(new MockSpamd(port)).start();

        SMTPSession session = setupMockedSMTPSession(setupMockedMail(setupMockedMimeMessage(MockSpamd.GTUBE)));

        SpamAssassinHandler handler = new SpamAssassinHandler();

        handler.setSpamdHost(SPAMD_HOST);
        handler.setSpamdPort(port);
View Full Code Here


    public void testSpamReject() throws IOException, MessagingException {

        int port = PortUtil.getNonPrivilegedPort();
        new Thread(new MockSpamd(port)).start();

        SMTPSession session = setupMockedSMTPSession(setupMockedMail(setupMockedMimeMessage(MockSpamd.GTUBE)));

        SpamAssassinHandler handler = new SpamAssassinHandler();

        handler.setSpamdHost(SPAMD_HOST);
        handler.setSpamdPort(port);
View Full Code Here

    private static final String URISERVER = "multi.surbl.org.";
    private Mail mockedMail;

    private SMTPSession setupMockedSMTPSession(final Mail mail) {
        mockedMail = mail;
        SMTPSession mockedSMTPSession = new BaseFakeSMTPSession() {

            private final String ipAddress = "192.168.0.1";
            private final String host = "localhost";
            private boolean relayingAllowed;
View Full Code Here

    public void testNotBlocked() throws IOException, MessagingException {

        ArrayList servers = new ArrayList();
        servers.add(URISERVER);

        SMTPSession session = setupMockedSMTPSession(setupMockedMail(setupMockedMimeMessage(
                "http://" + GOOD_DOMAIN + "/")));

        URIRBLHandler handler = new URIRBLHandler();

        handler.setDNSService(setupMockedDnsServer());
View Full Code Here

    public void testBlocked() throws IOException, MessagingException {

        ArrayList servers = new ArrayList();
        servers.add(URISERVER);

        SMTPSession session = setupMockedSMTPSession(setupMockedMail(setupMockedMimeMessage(
                "http://" + BAD_DOMAIN1 + "/")));

        URIRBLHandler handler = new URIRBLHandler();

        handler.setDNSService(setupMockedDnsServer());
View Full Code Here

    public void testBlockedMultiPart() throws IOException, MessagingException {

        ArrayList servers = new ArrayList();
        servers.add(URISERVER);

        SMTPSession session = setupMockedSMTPSession(setupMockedMail(setupMockedMimeMessageMP(
                "http://" + BAD_DOMAIN1 + "/" + " " + "http://" + GOOD_DOMAIN + "/")));

        URIRBLHandler handler = new URIRBLHandler();

        handler.setDNSService(setupMockedDnsServer());
View Full Code Here

        });
    }

    private SMTPSession setupMockedSMTPSession(final SMTPConfiguration conf, final MailAddress rcpt,
                                               final boolean relayingAllowed) {
        SMTPSession session = new BaseFakeSMTPSession() {

            @Override
            public boolean isRelayingAllowed() {
                return relayingAllowed;
            }
View Full Code Here

    }

    @Test
    public void testRejectInvalidUser() throws Exception {
        MailAddress mailAddress = new MailAddress(INVALID_USER + "@localhost");
        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(), mailAddress, false);

        int rCode = handler.doRcpt(session, null, mailAddress).getResult();

        assertEquals("Rejected", rCode, HookReturnCode.DENY);
    }
View Full Code Here

    }

    @Test
    public void testRejectInvalidUserRelay() throws Exception {
        MailAddress mailAddress = new MailAddress(INVALID_USER + "@localhost");
        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(), mailAddress, true);

        int rCode = handler.doRcpt(session, null, mailAddress).getResult();

        assertEquals("Rejected", rCode, HookReturnCode.DENY);
    }
View Full Code Here

    }

    @Test
    public void testNotRejectValidUser() throws Exception {
        MailAddress mailAddress = new MailAddress(VALID_USER + "@localhost");
        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(), mailAddress, false);

        int rCode = handler.doRcpt(session, null, mailAddress).getResult();

        assertEquals("Not rejected", rCode, HookReturnCode.DECLINED);
    }
View Full Code Here

TOP

Related Classes of org.apache.james.protocols.smtp.SMTPSession

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.