Search in sources :

Example 1 with ResinJmxValues

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());
}
Also used : TomcatJmxValues(com.newrelic.agent.jmx.values.TomcatJmxValues) ResinJmxValues(com.newrelic.agent.jmx.values.ResinJmxValues) JettyJmxMetrics(com.newrelic.agent.jmx.values.JettyJmxMetrics) StatsEngineImpl(com.newrelic.agent.stats.StatsEngineImpl) JmxService(com.newrelic.agent.jmx.JmxService) GlassfishJmxValues(com.newrelic.agent.jmx.values.GlassfishJmxValues) StatsEngine(com.newrelic.agent.stats.StatsEngine) JmxGet(com.newrelic.agent.jmx.create.JmxGet) Test(org.junit.Test)

Aggregations

JmxService (com.newrelic.agent.jmx.JmxService)1 JmxGet (com.newrelic.agent.jmx.create.JmxGet)1 GlassfishJmxValues (com.newrelic.agent.jmx.values.GlassfishJmxValues)1 JettyJmxMetrics (com.newrelic.agent.jmx.values.JettyJmxMetrics)1 ResinJmxValues (com.newrelic.agent.jmx.values.ResinJmxValues)1 TomcatJmxValues (com.newrelic.agent.jmx.values.TomcatJmxValues)1 StatsEngine (com.newrelic.agent.stats.StatsEngine)1 StatsEngineImpl (com.newrelic.agent.stats.StatsEngineImpl)1 Test (org.junit.Test)1