### Question:
TokenSchedulerGroup extends AbstractSchedulerGroup { @Override public void incrementThreads() { consumeTokens(); super.incrementThreads(); } TokenSchedulerGroup(String schedGroupName, int numTokensPerMs, int tokenLifetimeMs); @Override void incrementThreads(); @Override void decrementThreads(); @Override void startQuery(); @Override void endQuery(); @Override int compareTo(SchedulerGroupAccountant rhs); String toString();  }### Answer:
@Test public void testIncrementThreads() throws Exception { timeMillis = 100; TestTokenSchedulerGroup group = new TestTokenSchedulerGroup(); int availableTokens = group.getAvailableTokens(); assertEquals(availableTokens, TestTokenSchedulerGroup.numTokensPerMs * TestTokenSchedulerGroup.tokenLifetimeMs); timeMillis += 2 * TestTokenSchedulerGroup.tokenLifetimeMs; availableTokens = group.getAvailableTokens(); int startTime = timeMillis; assertEquals(availableTokens, TestTokenSchedulerGroup.numTokensPerMs * TestTokenSchedulerGroup.tokenLifetimeMs); int nThreads = 1; incrementThreads(group, nThreads); assertEquals(group.getThreadsInUse(), nThreads); assertEquals(group.getAvailableTokens(), availableTokens); int timeIncrement = 20; timeMillis += timeIncrement; group.decrementThreads(); assertEquals(group.getThreadsInUse(), 0); assertEquals(group.getAvailableTokens(), availableTokens - timeIncrement * nThreads); availableTokens = group.getAvailableTokens(); nThreads = 5; incrementThreads(group, nThreads); assertEquals(group.getThreadsInUse(), nThreads); timeMillis += timeIncrement; assertEquals(group.getAvailableTokens(), availableTokens - timeIncrement * nThreads); group.addReservedThreads(2 * nThreads); availableTokens = group.getAvailableTokens(); timeIncrement = 10; timeMillis += timeIncrement; assertEquals(group.getAvailableTokens(), availableTokens - timeIncrement * nThreads); availableTokens = group.getAvailableTokens(); decrementThreads(group, 2); nThreads -= 2; timeMillis += timeIncrement; assertEquals(group.getAvailableTokens(), availableTokens - timeIncrement * nThreads); availableTokens = group.getAvailableTokens(); int pendingTimeInQuantum = startTime + TestTokenSchedulerGroup.tokenLifetimeMs - timeMillis; timeMillis = startTime + TestTokenSchedulerGroup.tokenLifetimeMs + timeIncrement; int timeAdvance = pendingTimeInQuantum + timeIncrement; int expectedTokens = TestTokenSchedulerGroup.numTokensPerMs * TestTokenSchedulerGroup.tokenLifetimeMs - timeAdvance * nThreads; assertTrue(group.getAvailableTokens() < expectedTokens); availableTokens = group.getAvailableTokens(); timeMillis = startTime + 3 * TestTokenSchedulerGroup.tokenLifetimeMs + timeIncrement; expectedTokens = TestTokenSchedulerGroup.numTokensPerMs * TestTokenSchedulerGroup.tokenLifetimeMs - timeIncrement * nThreads; assertTrue(group.getAvailableTokens() < expectedTokens); }