类org.springframework.util.ConcurrencyThrottleSupport源码实例Demo

下面列出了怎么用org.springframework.util.ConcurrencyThrottleSupport的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void cannotExecuteWhenConcurrencyIsSwitchedOff() throws Exception {
	SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
	executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
	assertTrue(executor.isThrottleActive());
	assertThatIllegalStateException().isThrownBy(() ->
			executor.execute(new NoOpRunnable()));
}
 
@Test
public void cannotExecuteWhenConcurrencyIsSwitchedOff() throws Exception {
	SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
	executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
	assertTrue(executor.isThrottleActive());
	exception.expect(IllegalStateException.class);
	executor.execute(new NoOpRunnable());
}
 
@Ignore("Disabled because task is still executed when concurrency is switched off")
@Test
public void cannotExecuteWhenConcurrencyIsSwitchedOff() throws Exception {
	SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
	executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
	assertFalse(executor.isThrottleActive());
	exception.expect(IllegalStateException.class);
	executor.execute(new NoOpRunnable());
}
 
 类所在包
 类方法
 同包方法