@Before public void setUp() { Statistics.reset(); }
@Test public void shouldIncrementAllByteCounters() { assertThat(Statistics.getBytesReceived(), is(equalTo(0l))); assertThat(Statistics.getBytesSent(), is(equalTo(0l))); Statistics.addBytesReceived(3); assertThat(Statistics.getBytesReceived(), is(equalTo(3l))); Statistics.addBytesReceived(5); assertThat(Statistics.getBytesReceived(), is(equalTo(8l))); Statistics.addBytesSent(2); assertThat(Statistics.getBytesSent(), is(equalTo(2l))); Statistics.addBytesSent(11); assertThat(Statistics.getBytesSent(), is(equalTo(13l))); Statistics.reset(); assertThat(Statistics.getBytesReceived(), is(equalTo(0l))); assertThat(Statistics.getBytesSent(), is(equalTo(0l))); }
@Test public void shouldIncrementAllCountersAndResetThem() { assertThat(Statistics.getError404s(), is(equalTo(0l))); assertThat(Statistics.getError500s(), is(equalTo(0l))); assertThat(Statistics.getRequestsHandled(), is(equalTo(0l))); Statistics.incrementError404(); assertThat(Statistics.getError404s(), is(equalTo(1l))); Statistics.incrementError500(); assertThat(Statistics.getError500s(), is(equalTo(1l))); Statistics.incrementRequestHandled(); assertThat(Statistics.getRequestsHandled(), is(equalTo(1l))); Statistics.incrementError404(); assertThat(Statistics.getError404s(), is(equalTo(2l))); Statistics.incrementError500(); assertThat(Statistics.getError500s(), is(equalTo(2l))); Statistics.incrementRequestHandled(); assertThat(Statistics.getRequestsHandled(), is(equalTo(2l))); Statistics.reset(); assertThat(Statistics.getError404s(), is(equalTo(0l))); assertThat(Statistics.getError500s(), is(equalTo(0l))); assertThat(Statistics.getRequestsHandled(), is(equalTo(0l))); }