Permalink
Browse files

enrich test case to use StabilityStatistics

  • Loading branch information...
1 parent 5d02fea commit 21ead6b2c9b904dac038a3f6901ec8d939520b0d @ropalka ropalka committed Jan 16, 2013
Showing with 53 additions and 3 deletions.
  1. +53 −3 src/test/java/org/jboss/msc/service/ContainerStabilityTestCase.java
@@ -23,13 +23,13 @@
package org.jboss.msc.service;
import java.util.Set;
-import org.jboss.msc.service.util.FailToStartService;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public final class ContainerStabilityTestCase extends AbstractServiceTest {
@@ -135,15 +135,40 @@ public Object getValue() throws IllegalStateException, IllegalArgumentException
stabilityMonitor.addController(controller2);
final Set<Object> problem = new IdentityHashSet<Object>();
final Set<Object> failed = new IdentityHashSet<Object>();
+ final StabilityStatistics statistics = new StabilityStatistics();
try {
- stabilityMonitor.awaitStability(failed, problem);
+ stabilityMonitor.awaitStability(failed, problem, statistics);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertController(controller1.getName(), controller1);
assertController(controller2.getName(), controller2);
assertTrue(problem.isEmpty());
assertTrue(failed.isEmpty());
+ assertTrue(statistics.getActiveCount() == 1);
+ assertTrue(statistics.getOnDemandCount() == 1);
+ assertTrue(statistics.getStartedCount() == 2);
+ assertTrue(statistics.getFailedCount() == 0);
+ assertTrue(statistics.getLazyCount() == 0);
+ assertTrue(statistics.getNeverCount() == 0);
+ assertTrue(statistics.getPassiveCount() == 0);
+ assertTrue(statistics.getProblemsCount() == 0);
+ assertTrue(statistics.getRemovedCount() == 0);
+ stabilityMonitor.clear();
+ try {
+ stabilityMonitor.awaitStability(statistics);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ assertTrue(statistics.getActiveCount() == 0);
+ assertTrue(statistics.getOnDemandCount() == 0);
+ assertTrue(statistics.getStartedCount() == 0);
+ assertTrue(statistics.getFailedCount() == 0);
+ assertTrue(statistics.getLazyCount() == 0);
+ assertTrue(statistics.getNeverCount() == 0);
+ assertTrue(statistics.getPassiveCount() == 0);
+ assertTrue(statistics.getProblemsCount() == 0);
+ assertTrue(statistics.getRemovedCount() == 0);
}
@Test
@@ -180,14 +205,39 @@ public Object getValue() throws IllegalStateException, IllegalArgumentException
stabilityMonitor.addController(controller2);
final Set<Object> problem = new IdentityHashSet<Object>();
final Set<Object> failed = new IdentityHashSet<Object>();
+ final StabilityStatistics statistics = new StabilityStatistics();
try {
- stabilityMonitor.awaitStability(failed, problem);
+ stabilityMonitor.awaitStability(failed, problem, statistics);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertController(controller1.getName(), controller1);
assertController(controller2.getName(), controller2);
assertTrue(problem.isEmpty());
assertTrue(failed.size() == 1);
+ assertTrue(statistics.getActiveCount() == 1);
+ assertTrue(statistics.getOnDemandCount() == 1);
+ assertTrue(statistics.getStartedCount() == 2);
+ assertTrue(statistics.getFailedCount() == 1);
+ assertTrue(statistics.getLazyCount() == 0);
+ assertTrue(statistics.getNeverCount() == 0);
+ assertTrue(statistics.getPassiveCount() == 0);
+ assertTrue(statistics.getProblemsCount() == 0);
+ assertTrue(statistics.getRemovedCount() == 0);
+ stabilityMonitor.clear();
+ try {
+ stabilityMonitor.awaitStability(statistics);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ assertTrue(statistics.getActiveCount() == 0);
+ assertTrue(statistics.getOnDemandCount() == 0);
+ assertTrue(statistics.getStartedCount() == 0);
+ assertTrue(statistics.getFailedCount() == 0);
+ assertTrue(statistics.getLazyCount() == 0);
+ assertTrue(statistics.getNeverCount() == 0);
+ assertTrue(statistics.getPassiveCount() == 0);
+ assertTrue(statistics.getProblemsCount() == 0);
+ assertTrue(statistics.getRemovedCount() == 0);
}
}

0 comments on commit 21ead6b

Please sign in to comment.