1 32 33 package com.jeantessier.metrics; 34 35 import junit.framework.*; 36 37 import org.apache.log4j.*; 38 39 public class TestStatisticalMeasurementEmpty extends TestCase { 40 private StatisticalMeasurement measurement; 41 private Metrics metrics; 42 43 protected void setUp() throws Exception { 44 Logger.getLogger(getClass()).info("Starting test: " + getName()); 45 46 metrics = new Metrics("foo"); 47 measurement = new StatisticalMeasurement(null, metrics, "bar"); 48 } 49 50 protected void tearDown() throws Exception { 51 Logger.getLogger(getClass()).info("End of " + getName()); 52 } 53 54 public void testDirect() { 55 Metrics m = new Metrics("m"); 56 m.track("bar", new CounterMeasurement(null, null, null)); 57 metrics.addSubMetrics(m); 58 59 assertTrue("Before AddToMeasurement()", measurement.isEmpty()); 60 61 m.addToMeasurement("bar", 1); 62 63 assertFalse("After AddToMeasurement()", !measurement.isEmpty()); 64 } 65 66 public void testIndirect() { 67 Metrics m = new Metrics("m"); 68 metrics.addSubMetrics(m); 69 70 Metrics sm = new Metrics("sm"); 71 sm.track("bar", new CounterMeasurement(null, null, null)); 72 m.addSubMetrics(sm); 73 74 assertTrue("Before AddToMeasurement()", measurement.isEmpty()); 75 76 sm.addToMeasurement("bar", 1); 77 78 assertFalse("After AddToMeasurement()", !measurement.isEmpty()); 79 } 80 81 public void testViaStatisticalMeasurement() { 82 Metrics m = new Metrics("m"); 83 m.track("bar", new StatisticalMeasurement(null, m, "bar")); 84 metrics.addSubMetrics(m); 85 86 Metrics sm = new Metrics("sm"); 87 sm.track("bar", new CounterMeasurement(null, null, null)); 88 m.addSubMetrics(sm); 89 90 assertTrue("Before AddToMeasurement()", measurement.isEmpty()); 91 92 sm.addToMeasurement("bar", 1); 93 94 assertFalse("After AddToMeasurement()", !measurement.isEmpty()); 95 } 96 } 97 | Popular Tags |