@Test public void testRun() throws Exception { doNothing().when(aManager).cleanDataSources(); doReturn(0).when(aManager).getDbmsPoolSize(); PowerMockito.mockStatic(Thread.class); PowerMockito.doNothing().when(Thread.class, "sleep", any(Long.class)); cleaner.run(); verify(aManager, times(1)).cleanDataSources(); verify(aManager, times(1)).getDbmsPoolSize(); }
public void run() { state = STATE_CLEANER.RUNNING; while (state != STATE_CLEANER.SHUTDOWN) { try { Thread.sleep(interval * 1000); } catch (InterruptedException e) { break; } this.manager.cleanDataSources(); if (this.manager.getDbmsPoolSize() == 0) { state = STATE_CLEANER.SHUTDOWN; break; } } }
PooledDataSourceCleaner implements Runnable { public void run() { state = STATE_CLEANER.RUNNING; while (state != STATE_CLEANER.SHUTDOWN) { try { Thread.sleep(interval * 1000); } catch (InterruptedException e) { break; } this.manager.cleanDataSources(); if (this.manager.getDbmsPoolSize() == 0) { state = STATE_CLEANER.SHUTDOWN; break; } } } }
PooledDataSourceCleaner implements Runnable { public void run() { state = STATE_CLEANER.RUNNING; while (state != STATE_CLEANER.SHUTDOWN) { try { Thread.sleep(interval * 1000); } catch (InterruptedException e) { break; } this.manager.cleanDataSources(); if (this.manager.getDbmsPoolSize() == 0) { state = STATE_CLEANER.SHUTDOWN; break; } } } PooledDataSourceCleaner(DBConnectionManager aManager, long aInterval); }
PooledDataSourceCleaner implements Runnable { public void run() { state = STATE_CLEANER.RUNNING; while (state != STATE_CLEANER.SHUTDOWN) { try { Thread.sleep(interval * 1000); } catch (InterruptedException e) { break; } this.manager.cleanDataSources(); if (this.manager.getDbmsPoolSize() == 0) { state = STATE_CLEANER.SHUTDOWN; break; } } } PooledDataSourceCleaner(DBConnectionManager aManager, long aInterval); void run(); }
PooledDataSourceCleaner implements Runnable { public void run() { state = STATE_CLEANER.RUNNING; while (state != STATE_CLEANER.SHUTDOWN) { try { Thread.sleep(interval * 1000); } catch (InterruptedException e) { break; } this.manager.cleanDataSources(); if (this.manager.getDbmsPoolSize() == 0) { state = STATE_CLEANER.SHUTDOWN; break; } } } PooledDataSourceCleaner(DBConnectionManager aManager, long aInterval); void run();  }