Polishing
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
@@ -40,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
private final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
|
||||
@@ -120,8 +121,8 @@ public class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutor
|
||||
assertThat(errorHandler.lastError).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void scheduleTriggerTask() throws Exception {
|
||||
@RepeatedTest(20)
|
||||
void scheduleMultipleTriggerTasks() throws Exception {
|
||||
TestTask task = new TestTask(this.testName, 3);
|
||||
Future<?> future = scheduler.schedule(task, new TestTrigger(3));
|
||||
Object result = future.get(1000, TimeUnit.MILLISECONDS);
|
||||
@@ -130,13 +131,6 @@ public class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutor
|
||||
assertThreadNamePrefix(task);
|
||||
}
|
||||
|
||||
@Test
|
||||
void scheduleMultipleTriggerTasks() throws Exception {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
scheduleTriggerTask();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void await(TestTask task) {
|
||||
await(task.latch);
|
||||
|
||||
@@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Mark Fisher
|
||||
* @since 3.0
|
||||
*/
|
||||
public class PeriodicTriggerTests {
|
||||
class PeriodicTriggerTests {
|
||||
|
||||
@Test
|
||||
public void fixedDelayFirstExecution() {
|
||||
void fixedDelayFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofMillis(5000));
|
||||
Instant next = trigger.nextExecution(context(null, null, null));
|
||||
@@ -43,8 +43,8 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedDelayWithInitialDelayFirstExecution() {
|
||||
@SuppressWarnings("deprecation")
|
||||
void fixedDelayWithInitialDelayFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5000;
|
||||
long initialDelay = 30000;
|
||||
@@ -55,7 +55,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedDelayWithTimeUnitFirstExecution() {
|
||||
void fixedDelayWithTimeUnitFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofSeconds(5));
|
||||
Instant next = trigger.nextExecution(context(null, null, null));
|
||||
@@ -63,7 +63,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedDelayWithTimeUnitAndInitialDelayFirstExecution() {
|
||||
void fixedDelayWithTimeUnitAndInitialDelayFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5;
|
||||
long initialDelay = 30;
|
||||
@@ -74,7 +74,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedDelaySubsequentExecution() {
|
||||
void fixedDelaySubsequentExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5000;
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofMillis(period));
|
||||
@@ -83,8 +83,8 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedDelayWithInitialDelaySubsequentExecution() {
|
||||
@SuppressWarnings("deprecation")
|
||||
void fixedDelayWithInitialDelaySubsequentExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5000;
|
||||
long initialDelay = 30000;
|
||||
@@ -95,7 +95,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedDelayWithTimeUnitSubsequentExecution() {
|
||||
void fixedDelayWithTimeUnitSubsequentExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5;
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofSeconds(period));
|
||||
@@ -104,7 +104,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateFirstExecution() {
|
||||
void fixedRateFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofMillis(5000));
|
||||
trigger.setFixedRate(true);
|
||||
@@ -113,7 +113,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateWithTimeUnitFirstExecution() {
|
||||
void fixedRateWithTimeUnitFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofSeconds(5));
|
||||
trigger.setFixedRate(true);
|
||||
@@ -122,8 +122,8 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateWithInitialDelayFirstExecution() {
|
||||
@SuppressWarnings("deprecation")
|
||||
void fixedRateWithInitialDelayFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5000;
|
||||
long initialDelay = 30000;
|
||||
@@ -135,7 +135,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateWithTimeUnitAndInitialDelayFirstExecution() {
|
||||
void fixedRateWithTimeUnitAndInitialDelayFirstExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5;
|
||||
long initialDelay = 30;
|
||||
@@ -147,7 +147,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateSubsequentExecution() {
|
||||
void fixedRateSubsequentExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5000;
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofMillis(period));
|
||||
@@ -157,8 +157,8 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateWithInitialDelaySubsequentExecution() {
|
||||
@SuppressWarnings("deprecation")
|
||||
void fixedRateWithInitialDelaySubsequentExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5000;
|
||||
long initialDelay = 30000;
|
||||
@@ -170,7 +170,7 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedRateWithTimeUnitSubsequentExecution() {
|
||||
void fixedRateWithTimeUnitSubsequentExecution() {
|
||||
Instant now = Instant.now();
|
||||
long period = 5;
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofHours(period));
|
||||
@@ -180,8 +180,8 @@ public class PeriodicTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsVerification() {
|
||||
@SuppressWarnings("deprecation")
|
||||
void equalsVerification() {
|
||||
PeriodicTrigger trigger1 = new PeriodicTrigger(Duration.ofMillis(3000));
|
||||
PeriodicTrigger trigger2 = new PeriodicTrigger(Duration.ofMillis(3000));
|
||||
assertThat(trigger1.equals(new String("not a trigger"))).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user