[BAEL-3934]shedlock update

This commit is contained in:
Kai Yuan
2020-03-26 23:00:07 +01:00
parent 566c18ad7e
commit c6f71e7ac7
7 changed files with 78 additions and 23 deletions
@@ -0,0 +1,39 @@
package com.baeldung.scheduling.shedlock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest
public class BaeldungTaskSchedulerIntegrationTest {
@Autowired
private BaeldungTaskScheduler taskScheduler;
@Test
public void whenShedLockConfigCorrect_thenSpringCtxtStartsWithoutError() {
// save the old out
PrintStream old = System.out;
// Create a stream to hold the output for test
ByteArrayOutputStream consoleOutput = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(consoleOutput);
System.setOut(ps);
//test
taskScheduler.scheduledTask();
System.out.flush();
String expected = "Running ShedLock task\n";
assertThat(consoleOutput.toString()).isEqualTo(expected);
//restore the old out
System.setOut(old);
}
}