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());
}
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);
}
Aggregations