use of java.util.concurrent.RunnableScheduledFuture in project java-chassis by ServiceComb.
the class TestThreadPoolPublishModelFactory method createDefaultPublishModel.
@Test
public void createDefaultPublishModel() throws JsonProcessingException {
new Expectations() {
{
threadPoolExecutor.getQueue();
result = queue;
queue.size();
result = 10d;
}
};
new MockUp<ScheduledThreadPoolExecutor>() {
@Mock
void delayedExecute(RunnableScheduledFuture<?> task) {
}
};
try {
ThreadPoolMonitor.attach(registry, threadPoolExecutor, "test");
PolledMeter.update(registry);
PublishModelFactory factory = new PublishModelFactory(Lists.newArrayList(registry.iterator()));
DefaultPublishModel model = factory.createDefaultPublishModel();
Assert.assertEquals("{\"test\":{\"avgTaskCount\":0.0,\"avgCompletedTaskCount\":0.0,\"currentThreadsBusy\":0,\"maxThreads\":0,\"poolSize\":0,\"corePoolSize\":0,\"queueSize\":10,\"rejected\":\"NaN\"}}", JsonUtils.writeValueAsString(model.getThreadPools()));
} catch (Throwable e) {
e.printStackTrace();
Assert.fail("unexpected error happen. " + e.getMessage());
}
}
Aggregations