Package org.auraframework.impl.context.LoggingContextImpl

Examples of org.auraframework.impl.context.LoggingContextImpl.Timer


    public LoggingTimerTest(String name) {
        super(name);
    }
   
    public void testTimer() throws Exception {
        Timer timer = new Timer("foo");
        assertEquals("Uninitialized timer has a totalTime", -1, timer.getTime());
        assertEquals("Timer name is wrong", "foo", timer.getName());
       
        timer.start();
        assertEquals("Running timer has a totalTime", -1, timer.getTime());
       
        timer.stop();
        assertTrue("Completed timer has no totalTime", timer.getTime() >= 0);
       
        timer.reset();
        assertEquals("Reseted timer has a totalTime", -1, timer.getTime());
    }
View Full Code Here


        timer.reset();
        assertEquals("Reseted timer has a totalTime", -1, timer.getTime());
    }
   
    public void testNesting() throws Exception {
        Timer timer = new Timer("foo");
       
        timer.start();
        assertEquals("Running timer has a totalTime", -1, timer.getTime());
       
        timer.start();
        assertEquals("Nested Running timer has a totalTime", -1, timer.getTime());
       
        timer.stop();
        assertEquals("Running timer has a totalTime", -1, timer.getTime());
       
        timer.stop();
        assertTrue("Completed timer has no totalTime", timer.getTime() >= 0);
    }
View Full Code Here

        assertTrue("Completed timer has no totalTime", timer.getTime() >= 0);
    }
   
    public void testRestart() throws Exception {
        Long skipAhead = 60L * 60L * 1000000000L;
        Timer timer = new Timer("foo");
        //this test is a little funky to avoid the need for Thread.sleep()
        //a second timer is used as somewhat of a control.
       
        timer.start();
        assertEquals("Running timer has a totalTime", -1, timer.getTime());
       
        //since totalTime is initially negative even if no time has passed
        //it will change to '0' and this test will pass
        timer.stop();
        assertTrue("Completed timer has no totalTime", timer.getTime() >= 0);
       
        Field totalTime = Timer.class.getDeclaredField("totalTime");
        totalTime.setAccessible(true);
        totalTime.setLong(timer, skipAhead); //assure value > 0 + likely thread down time
       
        Timer innerTimer = new Timer("bar");
        timer.start();
        innerTimer.start();
       
        innerTimer.stop(); //probably '0' totalTime but it could be a whole lot more
        timer.stop();
       
        //if reset is broken in the future this test becomes flappable with false passes
        //that would be the case if the innerTimer above waited for 1h less that the timer under test.
        //this is extremely unlikely.
        assertTrue("Timer restart did not accumulate time", timer.getTime() >= ((skipAhead / 1000000L) + innerTimer.getTime()));
    }
View Full Code Here

TOP

Related Classes of org.auraframework.impl.context.LoggingContextImpl.Timer

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.