Examples of TarpitHandler


Examples of org.apache.james.protocols.smtp.core.fastfail.TarpitHandler

    public void testTarpit() throws ParseException {
        long tarpitTime = 1000;
        long tarpitTolerance = 100;
        long startTime;
        TarpitHandler handler = new TarpitHandler();
       
        handler.setTarpitRcptCount(2);
        handler.setTarpitSleepTime(tarpitTime);

        // no tarpit used
        startTime = System.currentTimeMillis();
        handler.doRcpt(setupMockedSession(0),null,new MailAddress("test@test"));
        assertTrue("No tarpit",
                (System.currentTimeMillis() - startTime) < tarpitTime - tarpitTolerance);

        // tarpit used
        startTime = System.currentTimeMillis();
        handler.doRcpt(setupMockedSession(3),null,new MailAddress("test@test"));
        assertTrue("tarpit",
                (System.currentTimeMillis() - startTime) >= tarpitTime - tarpitTolerance);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.