### Question:
ManagedPoolingDataSource implements PoolingDataSource, ScopeEventListener { @Override public void close() { this.dataSource = new StoppedDataSource(dataSource); this.dataSourceManager.shutdown(); } ManagedPoolingDataSource(UnmanagedPoolingDataSource dataSource);  ManagedPoolingDataSource(UnmanagedPoolingDataSource dataSource, long managerWakeTime); @Override void beforeScopeEnd(); @Override void close(); @Override Connection getConnection(); @Override Connection getConnection(String username, String password); @Override PrintWriter getLogWriter(); @Override int getLoginTimeout(); @Override boolean isWrapperFor(Class<?> iface); @Override void setLogWriter(PrintWriter arg0); @Override void setLoginTimeout(int arg0); @SuppressWarnings("unchecked") @Override T unwrap(Class<T> iface); @Override Logger getParentLogger();  }### Answer:
@Test public void testClose() throws SQLException, InterruptedException { assertNotNull(dataSource.getConnection()); verify(mockPoolingDataSource, times(0)).close(); assertFalse(dataSource.getDataSourceManager().isStopped()); assertTrue(dataSource.getDataSourceManager().isAlive()); dataSource.close(); verify(mockPoolingDataSource, times(1)).close(); assertTrue(dataSource.getDataSourceManager().isStopped()); Thread.sleep(200); assertFalse(dataSource.getDataSourceManager().isAlive()); try { dataSource.getConnection(); } catch (SQLException e) { } }