From be4491959b0132c4cbaca4f887cb0d9e2cf0d9f3 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Fri, 26 Mar 2021 22:06:18 +0100 Subject: [PATCH] Fix flaky QuartzAutoConfigurationTests See gh-25810 --- .../quartz/QuartzAutoConfigurationTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java index 3283738997..f8d6f6769f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -19,10 +19,12 @@ package org.springframework.boot.autoconfigure.quartz; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.util.concurrent.Executor; import javax.sql.DataSource; +import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; @@ -194,8 +196,8 @@ class QuartzAutoConfigurationTests { Scheduler scheduler = context.getBean(Scheduler.class); assertThat(scheduler.getJobDetail(JobKey.jobKey("fooJob"))).isNotNull(); assertThat(scheduler.getTrigger(TriggerKey.triggerKey("fooTrigger"))).isNotNull(); - Thread.sleep(1000L); - assertThat(output).contains("withConfiguredJobAndTrigger").contains("jobDataValue"); + Awaitility.waitAtMost(Duration.ofSeconds(5)).untilAsserted( + () -> assertThat(output).contains("withConfiguredJobAndTrigger").contains("jobDataValue")); }); }