RequestRateModule extends Module { @Override public void stop() { logger.trace("Stopping request rate module."); timer.cancel(); } RequestRateModule(ModuleConfiguration configuration, List<Reporter> reporters,
            final GlobalConfiguration globalConfiguration); @Override void process(Query query); @Override void stop();  }
@Test public void should_load_default_configuration_and_initialize() throws ConfigurationException { final RequestRateModule module = new RequestRateModule(testConfiguration(1, Arrays.asList("*:*")), testReporters(), GlobalConfiguration.getDefault()); module.stop(); }
@Test public void should_report_request_rate_when_started() throws ConfigurationException, InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final LatchTestReporter testReporter = new LatchTestReporter(null, GlobalConfiguration.getDefault(), latch); final List<Reporter> reporters = new ArrayList<Reporter>() { { add(testReporter); } }; final RequestRateModule module = new RequestRateModule(testConfiguration(1, Arrays.asList("*:*")), reporters, GlobalConfiguration.getDefault()); boolean wait = latch.await(100, TimeUnit.MILLISECONDS); module.stop(); assertThat(wait).isTrue(); }
@Test public void should_report_using_log_reporter() throws ConfigurationException, InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final LatchTestReporter latchTestReporter = new LatchTestReporter(null, GlobalConfiguration.getDefault(), latch); final List<Reporter> reporters = new ArrayList<Reporter>() { { add(latchTestReporter); add(new LogReporter(null, GlobalConfiguration.getDefault())); } }; final RequestRateModule module = new RequestRateModule( testConfiguration(1, Arrays.asList("*:*")), reporters, GlobalConfiguration.getDefault()); boolean wait = latch.await(200, TimeUnit.MILLISECONDS); module.stop(); assertThat(wait).isTrue(); }