Package org.jasig.cas.client.util

Examples of org.jasig.cas.client.util.MethodFlag


    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();
            }
        };

        filter.setMillisBetweenCleanUps(1);
        filter.setProxyGrantingTicketStorage(storage);
        filter.setTimer(timer);
        filter.setTimerTask(defaultTimerTask);

        filter.init();
        assertTrue(scheduleMethodFlag.wasCalled());
    }
View Full Code Here


        filter.init();
        assertTrue(scheduleMethodFlag.wasCalled());
    }

    public void testShutsDownTimerThread() throws Exception {
        final MethodFlag cancelMethodFlag = new MethodFlag();
        final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();

        final Timer timer = new Timer(true) {
            public void cancel() {
                cancelMethodFlag.setCalled();
                super.cancel();
            }
        };

        filter.setProxyGrantingTicketStorage(storage);
        filter.setMillisBetweenCleanUps(1);
        filter.setTimer(timer);
        filter.setTimerTask(defaultTimerTask);
        filter.init();
        filter.destroy();

        assertTrue(cancelMethodFlag.wasCalled());
    }
View Full Code Here

        assertTrue(cancelMethodFlag.wasCalled());
    }

    public void testCallsCleanAllOnSchedule() throws Exception {
        final MethodFlag timerTaskFlag = new MethodFlag();
        final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();

        final TimerTask timerTask = new TimerTask() {
            public void run() {
                timerTaskFlag.setCalled();
            }
        };

        final int millisBetweenCleanUps = 250;
        filter.setProxyGrantingTicketStorage(storage);
        filter.setTimerTask(timerTask);
        filter.setTimer(defaultTimer);
        filter.setMillisBetweenCleanUps(millisBetweenCleanUps);

        filter.init();

        // wait long enough for the clean up to occur
        Thread.sleep(millisBetweenCleanUps * 2);

        assertTrue(timerTaskFlag.wasCalled());
        filter.destroy();
    }
View Full Code Here

        assertTrue(timerTaskFlag.wasCalled());
        filter.destroy();
    }

    public void testDelaysFirstCleanAll() throws Exception {
        final MethodFlag timerTaskFlag = new MethodFlag();
        final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();

        final TimerTask timerTask = new TimerTask() {
            public void run() {
                timerTaskFlag.setCalled();
            }
        };

        final int millisBetweenCleanUps = 250;
        filter.setProxyGrantingTicketStorage(storage);
        filter.setMillisBetweenCleanUps(millisBetweenCleanUps);
        filter.setTimer(defaultTimer);
        filter.setTimerTask(timerTask);

        filter.init();

        assertFalse(timerTaskFlag.wasCalled());

        // wait long enough for the clean up to occur
        Thread.sleep(millisBetweenCleanUps * 2);

        assertTrue(timerTaskFlag.wasCalled());

        filter.destroy();
    }
View Full Code Here

TOP

Related Classes of org.jasig.cas.client.util.MethodFlag

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.