SpamTrapHandler handler = new SpamTrapHandler();
handler.setBlockTime(blockTime);
handler.setSpamTrapRecipients(rcpts);
int result = handler.doRcpt(setUpSMTPSession(ip),null,new MailAddress(SPAM_TRAP_RECIP1)).getResult();
assertEquals("Blocked on first connect",HookReturnCode.DENY,result);
result = handler.doRcpt(setUpSMTPSession(ip),null,new MailAddress(RECIP1)).getResult();
assertEquals("Blocked on second connect", HookReturnCode.DENY,result);
result = handler.doRcpt(setUpSMTPSession(ip2),null,new MailAddress(RECIP1)).getResult();
assertEquals("Not Blocked", HookReturnCode.DECLINED,result);
try {
// Wait for the blockTime to exceed
Thread.sleep(blockTime);
} catch (InterruptedException e) {
fail("Failed to sleep for " + blockTime +" ms");
}
result = handler.doRcpt(setUpSMTPSession(ip),null,new MailAddress(RECIP1)).getResult();
assertEquals("Not blocked. BlockTime exceeded", HookReturnCode.DECLINED,result);
}