Clean up warnings in tests

This commit is contained in:
Sam Brannen
2023-07-31 16:17:48 +03:00
parent 2f7046f572
commit 170d6bfdad
4 changed files with 28 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,17 +33,18 @@ class SimpleAsyncTaskExecutorTests {
@Test
void cannotExecuteWhenConcurrencyIsSwitchedOff() {
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
assertThat(executor.isThrottleActive()).isTrue();
assertThatIllegalStateException().isThrownBy(() ->
executor.execute(new NoOpRunnable()));
try (SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor()) {
executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
assertThat(executor.isThrottleActive()).isTrue();
assertThatIllegalStateException().isThrownBy(() -> executor.execute(new NoOpRunnable()));
}
}
@Test
void throttleIsNotActiveByDefault() {
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
assertThat(executor.isThrottleActive()).as("Concurrency throttle must not default to being active (on)").isFalse();
try (SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor()) {
assertThat(executor.isThrottleActive()).as("Concurrency throttle must not default to being active (on)").isFalse();
}
}
@Test
@@ -67,8 +68,9 @@ class SimpleAsyncTaskExecutorTests {
@Test
void throwsExceptionWhenSuppliedWithNullRunnable() {
assertThatIllegalArgumentException().isThrownBy(() ->
new SimpleAsyncTaskExecutor().execute(null));
try (SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor()) {
assertThatIllegalArgumentException().isThrownBy(() -> executor.execute(null));
}
}
private void executeAndWait(SimpleAsyncTaskExecutor executor, Runnable task, Object monitor) {