use of com.newrelic.agent.jmx.values.ResinJmxValues in project newrelic-java-agent by newrelic.
the class JmxServiceTest method testAddingToConfig.
@Test
public void testAddingToConfig() {
JmxService jmxService = ServiceFactory.getJmxService();
List<JmxGet> configurations = jmxService.getConfigurations();
int startupsize = configurations.size();
TomcatJmxValues tomcat = new TomcatJmxValues();
ResinJmxValues resin = new ResinJmxValues();
jmxService.addJmxFrameworkValues(tomcat);
jmxService.addJmxFrameworkValues(resin);
String appName = ServiceFactory.getConfigService().getDefaultAgentConfig().getApplicationName();
StatsEngine statsEngine = new StatsEngineImpl();
jmxService.beforeHarvest(appName, statsEngine);
int expectedSize = startupsize + tomcat.getFrameworkMetrics().size() + resin.getFrameworkMetrics().size();
Assert.assertEquals("Failed on initial check: " + configurations.toString(), expectedSize, configurations.size());
GlassfishJmxValues glassfish = new GlassfishJmxValues();
jmxService.addJmxFrameworkValues(glassfish);
jmxService.beforeHarvest(appName, statsEngine);
int newExpectedSize = expectedSize + glassfish.getFrameworkMetrics().size();
Assert.assertEquals("Failed on second check: " + configurations.toString(), newExpectedSize, configurations.size());
JettyJmxMetrics jetty = new JettyJmxMetrics();
jmxService.addJmxFrameworkValues(jetty);
jmxService.beforeHarvest(appName, statsEngine);
int thirdExpectedSize = newExpectedSize + jetty.getFrameworkMetrics().size();
Assert.assertEquals("Failed on third check: " + configurations.toString(), thirdExpectedSize, configurations.size());
}
Aggregations