use of javax.management.j2ee.statistics.JDBCConnectionStats in project newrelic-java-agent by newrelic.
the class J2EEStatsAttributeTest method addJmxValueJdbcTest.
@Test
public void addJmxValueJdbcTest() throws MalformedObjectNameException {
JDBCStats count = new JDBCStats() {
@Override
public Statistic[] getStatistics() {
return new Statistic[0];
}
@Override
public String[] getStatisticNames() {
return null;
}
@Override
public Statistic getStatistic(String statisticName) {
return null;
}
@Override
public JDBCConnectionStats[] getConnections() {
return new JDBCConnectionStats[0];
}
@Override
public JDBCConnectionPoolStats[] getConnectionPools() {
return new JDBCConnectionPoolStats[] { new TestJdbcConnectionPool() };
}
};
Attribute att = new Attribute("stats", count);
J2EEStatsAttributeProcessor processor = new J2EEStatsAttributeProcessor();
StatsEngine engine = new StatsEngineImpl();
processor.process(engine, new ObjectInstance("tezt:type=1", "test"), att, "JMX/Test", new HashMap<String, Float>());
// check count stats
Assert.assertEquals(77, engine.getStats("JMX/Test/Create").getTotal(), .001);
Assert.assertEquals(1, engine.getStats("JMX/Test/Create").getCallCount(), .001);
Assert.assertEquals(9, engine.getStats("JMX/Test/Close").getTotal(), .001);
Assert.assertEquals(1, engine.getStats("JMX/Test/Close").getCallCount(), .001);
// check time stats
Assert.assertEquals(12, engine.getResponseTimeStats("JMX/Test/WaitTime").getMaxCallTime(), .001);
Assert.assertEquals(8, engine.getResponseTimeStats("JMX/Test/WaitTime").getMinCallTime(), .001);
Assert.assertEquals(2, engine.getResponseTimeStats("JMX/Test/WaitTime").getCallCount(), .001);
Assert.assertEquals(6, engine.getResponseTimeStats("JMX/Test/UserTime").getMaxCallTime(), .001);
Assert.assertEquals(4, engine.getResponseTimeStats("JMX/Test/UserTime").getMinCallTime(), .001);
Assert.assertEquals(2, engine.getResponseTimeStats("JMX/Test/UserTime").getCallCount(), .001);
}
Aggregations