ViburCpDatasourceAccessor implements DatasourceAccessor { @Override public DataSourceInfo getInfo(final Object resource) throws Exception { DataSourceInfo dataSourceInfo = null; if (canMap(resource)) { ViburDBCPDataSource source = (ViburDBCPDataSource) resource; MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); ObjectName poolName = new ObjectName(source.getJmxName()); ViburMonitoringMBean poolProxy = JMX.newMXBeanProxy(mbeanServer, poolName, ViburMonitoringMBean.class); dataSourceInfo = new DataSourceInfo(); dataSourceInfo.setBusyConnections(poolProxy.getPoolTaken()); dataSourceInfo.setEstablishedConnections( poolProxy.getPoolRemainingCreated() + poolProxy.getPoolTaken()); dataSourceInfo.setMaxConnections(source.getPoolMaxSize()); dataSourceInfo.setJdbcUrl(source.getJdbcUrl()); dataSourceInfo.setUsername(source.getUsername()); dataSourceInfo.setResettable(false); dataSourceInfo.setType("vibur"); } return dataSourceInfo; }  @Override DataSourceInfo getInfo(final Object resource); @Override boolean reset(final Object resource); @Override boolean canMap(final Object resource);  }
@Disabled @Test public void getInfoTest() throws Exception { new Expectations() { { source.getJmxName(); result = "viburJmx"; } }; accessor.getInfo(source); }