Code example for Timer

0
 * 
 * @author Brad Cupit (brad [at] lsu {dot} edu) 
 */ 
public class Cas20ProxyReceivingTicketValidationFilterTests extends TestCase {
 
    private final Timer defaultTimer = new Timer(true);
 
    private final ProxyGrantingTicketStorage storage = new ProxyGrantingTicketStorageImpl();
 
    private final CleanUpTimerTask defaultTimerTask = new CleanUpTimerTask(storage);
 
    public void testStartsThreadAtStartup() throws Exception { 
        final MethodFlag scheduleMethodFlag = new MethodFlag();
        final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
 
        final Timer timer = new Timer(true) {
            public void schedule(TimerTask task, long delay, long period) {
                scheduleMethodFlag.setCalled();
            } 
        };