1 18 package org.apache.activemq.management; 19 20 import org.apache.activemq.management.RangeStatisticImpl; 21 22 public class RangeStatisticTest extends StatisticTestSupport { 23 24 private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory 25 .getLog(RangeStatisticTest.class); 26 27 31 public void testStatistic() throws Exception { 32 RangeStatisticImpl stat = new RangeStatisticImpl("myRange", "millis", "myDescription"); 33 assertStatistic(stat, "myRange", "millis", "myDescription"); 34 35 assertRangeStatistic(stat); 36 } 37 38 protected void assertRangeStatistic(RangeStatisticImpl stat) throws InterruptedException { 39 assertEquals(0, stat.getCurrent()); 40 assertEquals(0, stat.getLowWaterMark()); 41 assertEquals(0, stat.getHighWaterMark()); 42 43 stat.setCurrent(100); 44 assertEquals(100, stat.getCurrent()); 45 assertEquals(100, stat.getLowWaterMark()); 46 assertEquals(100, stat.getHighWaterMark()); 47 48 stat.setCurrent(50); 49 assertEquals(50, stat.getCurrent()); 50 assertEquals(50, stat.getLowWaterMark()); 51 assertEquals(100, stat.getHighWaterMark()); 52 53 stat.setCurrent(200); 54 assertEquals(200, stat.getCurrent()); 55 assertEquals(50, stat.getLowWaterMark()); 56 assertEquals(200, stat.getHighWaterMark()); 57 58 Thread.sleep(500); 59 60 stat.setCurrent(10); 61 assertEquals(10, stat.getCurrent()); 62 assertEquals(10, stat.getLowWaterMark()); 63 assertEquals(200, stat.getHighWaterMark()); 64 65 assertLastTimeNotStartTime(stat); 66 67 log.info("Stat is: " + stat); 68 69 stat.reset(); 70 71 assertEquals(0, stat.getCurrent()); 72 assertEquals(0, stat.getLowWaterMark()); 73 assertEquals(0, stat.getHighWaterMark()); 74 75 stat.setCurrent(100); 76 assertEquals(100, stat.getCurrent()); 77 assertEquals(100, stat.getLowWaterMark()); 78 assertEquals(100, stat.getHighWaterMark()); 79 } 80 } 81 | Popular Tags |