//log a bunch of messages
Logger logger = LoggerFactory.getLogger(StopWatch.DEFAULT_LOGGER_NAME);
for (int i = 0; i < 20; i++) {
long time = (i % 2) == 0 ? 100L : 200L;
logger.info("{}", new StopWatch(System.currentTimeMillis(), time, "tag" + (i % 2), "logging"));
Thread.sleep(110);
}
//check that the mbean attributes are accessible
assertTrue(((Integer) server.getAttribute(statisticsMBeanName, "tag0Count")) > 0);
assertEquals(0.0, server.getAttribute(statisticsMBeanName, "tag0StdDev"));
assertEquals(100.0, server.getAttribute(statisticsMBeanName, "tag0Mean"));
assertEquals(100L, server.getAttribute(statisticsMBeanName, "tag0Min"));
assertEquals(100L, server.getAttribute(statisticsMBeanName, "tag0Max"));
assertTrue(((Double) server.getAttribute(statisticsMBeanName, "tag0TPS")) > 1);
assertTrue(((Integer) server.getAttribute(statisticsMBeanName, "tag1Count")) > 0);
assertEquals(0.0, server.getAttribute(statisticsMBeanName, "tag1StdDev"));
assertEquals(200.0, server.getAttribute(statisticsMBeanName, "tag1Mean"));
assertEquals(200L, server.getAttribute(statisticsMBeanName, "tag1Min"));
assertEquals(200L, server.getAttribute(statisticsMBeanName, "tag1Max"));
assertTrue(((Double) server.getAttribute(statisticsMBeanName, "tag1TPS")) > 1);
//invoke exposeTag, insure that it makes a tag accessible
server.invoke(statisticsMBeanName, "exposeTag", new Object[]{"tagFoo"}, new String[0]);
assertEquals(0, server.getAttribute(statisticsMBeanName, "tagFooCount"));
//invoke removeTag, which should return true
assertTrue((Boolean) server.invoke(statisticsMBeanName,
"removeTag",
new Object[]{"tagFoo"},
new String[] {String.class.getName()}));
//now at a stopwatch that should trigger a notification
logger.info("{}", new StopWatch(System.currentTimeMillis(), 20000L, "tag0", "logging"));
Thread.sleep(1100L); //go over the next time slice boundary
logger.info("{}", new StopWatch(System.currentTimeMillis(), 20000L, "tag0", "logging"));
//check for the notification - need the wait loop as it takes time for the notification to appear
for (int i = 0; i <= 200; i++) {
Thread.sleep(10);
if (notificationListener.lastReceivedNotification != null) {