1 16 17 package org.springframework.web.context.support; 18 19 import java.io.FileNotFoundException ; 20 21 import junit.framework.TestCase; 22 23 import org.springframework.context.event.ContextRefreshedEvent; 24 import org.springframework.context.support.StaticApplicationContext; 25 26 29 public class PerformanceMonitorListenerTests extends TestCase { 30 31 public void testPerformanceMonitorListener() { 32 PerformanceMonitorListener l = new PerformanceMonitorListener(); 34 } 36 37 public void testOnApplicationEvent() throws FileNotFoundException { 38 PerformanceMonitorListener l = new PerformanceMonitorListener(); 39 l.onApplicationEvent(new ContextRefreshedEvent(new StaticApplicationContext())); 40 assertEquals(0, l.responseTimeMonitor.getAccessCount()); 41 42 RequestHandledEvent evt = new RequestHandledEvent(new Object (), 43 "http://www.springframework.org", 200, "192.168.1.122", "GET", "servlet"); 44 l.onApplicationEvent(evt); 45 assertEquals(1, l.responseTimeMonitor.getAccessCount()); 46 assertEquals(200, l.responseTimeMonitor.getAverageResponseTimeMillis()); 47 assertEquals(200, l.responseTimeMonitor.getBestResponseTimeMillis()); 48 assertEquals(200, l.responseTimeMonitor.getWorstResponseTimeMillis()); 49 } 50 51 } 52 | Popular Tags |