2018-01-13 13:59:49 +08:00
|
|
|
/*
|
2021-03-29 15:33:46 +08:00
|
|
|
* Copyright 2012-2021 the original author or authors.
|
2018-01-13 13:59:49 +08:00
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
2019-03-20 23:05:31 +08:00
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
2018-01-13 13:59:49 +08:00
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-06-26 01:11:56 +08:00
|
|
|
package smoketest.quartz;
|
2018-01-13 13:59:49 +08:00
|
|
|
|
2019-09-12 22:50:53 +08:00
|
|
|
import java.time.Duration;
|
|
|
|
|
|
|
|
|
|
import org.awaitility.Awaitility;
|
2018-12-06 05:56:29 +08:00
|
|
|
import org.junit.jupiter.api.Test;
|
2019-05-31 17:03:02 +08:00
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
2018-01-13 13:59:49 +08:00
|
|
|
|
2018-01-17 21:31:52 +08:00
|
|
|
import org.springframework.boot.SpringApplication;
|
2019-05-31 17:03:02 +08:00
|
|
|
import org.springframework.boot.test.system.CapturedOutput;
|
|
|
|
|
import org.springframework.boot.test.system.OutputCaptureExtension;
|
2018-01-17 21:31:52 +08:00
|
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
2018-01-13 13:59:49 +08:00
|
|
|
|
2019-09-12 22:50:53 +08:00
|
|
|
import static org.hamcrest.Matchers.containsString;
|
2018-01-13 13:59:49 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests for {@link SampleQuartzApplication}.
|
|
|
|
|
*
|
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
|
*/
|
2019-05-31 17:03:02 +08:00
|
|
|
@ExtendWith(OutputCaptureExtension.class)
|
2018-12-06 05:56:29 +08:00
|
|
|
class SampleQuartzApplicationTests {
|
2018-01-13 13:59:49 +08:00
|
|
|
|
|
|
|
|
@Test
|
2021-03-29 15:33:46 +08:00
|
|
|
void quartzJobIsTriggered(CapturedOutput output) {
|
|
|
|
|
try (ConfigurableApplicationContext context = SpringApplication.run(SampleQuartzApplication.class,
|
|
|
|
|
"--server.port=0")) {
|
2019-09-12 22:50:53 +08:00
|
|
|
Awaitility.waitAtMost(Duration.ofSeconds(5)).until(output::toString, containsString("Hello World!"));
|
2018-01-17 21:31:52 +08:00
|
|
|
}
|
2018-01-13 13:59:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|