@Test public void verifyObserve() throws Exception { final DataSourceMonitor monitor = new DataSourceMonitor(this.dataSource); monitor.setExecutor(Executors.newSingleThreadExecutor()); monitor.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"); final PoolStatus status = monitor.observe(); assertEquals(StatusCode.OK, status.getCode()); }
/* * Checks that a watch holds a given sequence of samples. */ private void checkData(double[] expected, CounterWatch watch) throws RemoteException { DataSourceMonitor mon = new DataSourceMonitor(watch); mon.waitFor(expected.length); Calculable[] calcs = watch.getWatchDataSource().getCalculable(); Assert.assertEquals(expected.length, calcs.length); for (int i = 0; i < expected.length; i++) { Assert.assertEquals(expected[i], calcs[i].getValue(), 0); } }