Search in sources :

Example 1 with GlassfishJmxValues

use of com.newrelic.agent.jmx.values.GlassfishJmxValues 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)

Example 2 with GlassfishJmxValues

use of com.newrelic.agent.jmx.values.GlassfishJmxValues in project newrelic-java-agent by newrelic.

the class JmxObjectFactoryTest method jmxConfig6.

@Test
public void jmxConfig6() throws MalformedObjectNameException {
    String versionSystemProp = System.getProperty("java.specification.version");
    double version = Double.parseDouble(versionSystemProp);
    if (version <= 1.5) {
        return;
    }
    JmxObjectFactory factory = JmxObjectFactory.createJmxFactory();
    List<JmxGet> objects = new ArrayList<>();
    List<JmxInvoke> invokes = new ArrayList<>();
    factory.getStartUpJmxObjects(objects, invokes);
    Assert.assertEquals(0, objects.size());
    JavaLangJmxMetrics metrics = new JavaLangJmxMetrics();
    factory.convertFramework(metrics, objects, invokes);
    Assert.assertEquals(metrics.getFrameworkMetrics().size(), objects.size());
    verify(objects, 4);
    objects.clear();
    factory.convertFramework(new GlassfishJmxValues(), objects, invokes);
    glassfishVerify(objects, invokes, 6);
}
Also used : JavaLangJmxMetrics(com.newrelic.agent.jmx.values.JavaLangJmxMetrics) ArrayList(java.util.ArrayList) GlassfishJmxValues(com.newrelic.agent.jmx.values.GlassfishJmxValues) Test(org.junit.Test)

Aggregations

GlassfishJmxValues (com.newrelic.agent.jmx.values.GlassfishJmxValues)2 Test (org.junit.Test)2 JmxService (com.newrelic.agent.jmx.JmxService)1 JmxGet (com.newrelic.agent.jmx.create.JmxGet)1 JavaLangJmxMetrics (com.newrelic.agent.jmx.values.JavaLangJmxMetrics)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 ArrayList (java.util.ArrayList)1