Package org.apache.james.protocols.smtp

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



public class MaxRcptHandlerTest {
   
    private SMTPSession setupMockedSession(final int rcptCount) {
        SMTPSession session = new BaseFakeSMTPSession() {
            HashMap<String,Object> state = new HashMap<String,Object>();

            public Map<String,Object> getState() {
                return state;
            }
View Full Code Here


        return session;
    }
   
    @Test
    public void testRejectMaxRcpt() throws MailAddressException {
        SMTPSession session = setupMockedSession(3);
        MaxRcptHandler handler = new MaxRcptHandler();
       
        handler.setMaxRcpt(2);
        int resp = handler.doRcpt(session,null,new MailAddress("test@test")).getResult();
   
View Full Code Here

    }
 
 
    @Test
    public void testNotRejectMaxRcpt() throws MailAddressException {
        SMTPSession session = setupMockedSession(3);
        MaxRcptHandler handler = new MaxRcptHandler();   

        handler.setMaxRcpt(4);
        int resp = handler.doRcpt(session,null,new MailAddress("test@test")).getResult();
       
View Full Code Here

     *
     * @param channel
     */
    protected void cleanup(Channel channel) {
        // Make sure we dispose everything on exit on session close
        SMTPSession smtpSession = (SMTPSession) attributes.get(channel);
       
        if (smtpSession != null) {
            LifecycleUtil.dispose(smtpSession.getState().get(SMTPConstants.MAIL));
            LifecycleUtil.dispose(smtpSession.getState().get(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE));
        }
       
        super.cleanup(channel);
    }
View Full Code Here

     *
     * @param ctx
     */
    protected void cleanup(ChannelHandlerContext ctx) {
        // Make sure we dispose everything on exit on session close
        SMTPSession smtpSession = (SMTPSession) ctx.getAttachment();

        if (smtpSession != null) {
            LifecycleUtil.dispose(smtpSession.getAttachment(SMTPConstants.MAIL, State.Transaction));
            LifecycleUtil.dispose(smtpSession.getAttachment(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE, State.Transaction));
        }

        super.cleanup(ctx);
    }
View Full Code Here

    private final static String INVALID_HOST = "invalid.host.de";
    private final static String INVALID_MX = "mx." + INVALID_HOST;
    private final static String LOOPBACK = "127.0.0.1";

    private SMTPSession setupMockedSMTPSession(final MailAddress rcpt) {
        SMTPSession session = new BaseFakeSMTPSession() {

            private final HashMap<String, Object> sstate = new HashMap<String, Object>();
            private final HashMap<String, Object> connectionState = new HashMap<String, Object>();

            @Override
View Full Code Here

        Collection bNetworks = new ArrayList();
        bNetworks.add("127.0.0.1");

        DNSService dns = setupMockedDNSServer();
        MailAddress mailAddress = new MailAddress("test@" + INVALID_HOST);
        SMTPSession session = setupMockedSMTPSession(mailAddress);
        ValidRcptMX handler = new ValidRcptMX();

        handler.setDNSService(dns);
        handler.setBannedNetworks(bNetworks, dns);
        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
View Full Code Here

public class MaxUnknownCmdHandlerTest {

   
    @Test
    public void testRejectAndClose() throws MailAddressException {
        SMTPSession session = new BaseFakeSMTPSession() {
            private final HashMap<String,Object> map = new HashMap<String,Object>();

            public Map<String,Object> getState() {
                return map;
            }
View Full Code Here

            }
        };
    }
   
    private SMTPSession setupMockedSession(final MailAddress sender) {
        SMTPSession session = new BaseFakeSMTPSession() {
            HashMap<String,Object> map = new HashMap<String,Object>();

            public Map<String,Object> getState() {

                map.put(SMTPSession.SENDER, sender);
View Full Code Here

    }

    @Test
    public void testInvalidSenderDomainReject() throws MailAddressException {
        ValidSenderDomainHandler handler = createHandler();
        SMTPSession session = setupMockedSession(new MailAddress("invalid@invalid"));
        int response = handler.doMail(session,(MailAddress) session.getAttachment(SMTPSession.SENDER, State.Transaction)).getResult();
       
        assertEquals("Blocked cause we use reject action", response,HookReturnCode.DENY);
    }
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.