TimingParserTest.java from Tea Stats at Krugle
Show TimingParserTest.java syntax highlighted
/*
* This file is distributed under the GPL v2 as part of teastats site statistics package
* http://teastats.sourceforge.net
*/
package net.time4tea.webstats.parser;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
/**
* $$Header$
* Initially by: james on 30-Jul-2006
*/
public class TimingParserTest extends MockObjectTestCase {
public Mock mockParser;
public TimingParser timingParser;
public void testCallsUnderlyingParser() throws Exception {
mockParser.expects(once()).method("parseLine");
timingParser.parseLine("foo");
}
public void testCanCountLinesParsed() throws Exception {
mockParser.expects(once()).method("parseLine");
mockParser.expects(once()).method("parseLine");
assertEquals(0, timingParser.getCount());
assertEquals(0, timingParser.getTotalTime());
timingParser.parseLine("foo");
assertEquals(1, timingParser.getCount());
long totalTime = timingParser.getTotalTime();
assertTrue(totalTime > 0);
timingParser.parseLine("foo");
assertEquals(2, timingParser.getCount());
assertTrue(timingParser.getTotalTime() > totalTime);
}
protected void setUp() throws Exception {
super.setUp();
mockParser = mock(LogParser.class);
timingParser = new TimingParser((LogParser) mockParser.proxy());
}
}
See more files for this project here