Updated all Junit tests to 5.x
resolves TASK-675
This commit is contained in:
committed by
Michael Minella
parent
f3bbc37293
commit
59c9adf047
@@ -19,11 +19,12 @@ package org.springframework.cloud.task.timestamp;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.test.system.OutputCaptureRule;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -32,13 +33,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
public class TaskApplicationTests {
|
||||
|
||||
@Rule
|
||||
public OutputCaptureRule outputCapture = new OutputCaptureRule();
|
||||
|
||||
@Test
|
||||
public void testTimeStampApp() throws Exception {
|
||||
public void testTimeStampApp(CapturedOutput capturedOutput) throws Exception {
|
||||
final String TEST_DATE_DOTS = ".......";
|
||||
final String CREATE_TASK_MESSAGE = "Creating: TaskExecution{executionId=";
|
||||
final String UPDATE_TASK_MESSAGE = "Updating: TaskExecution with executionId=";
|
||||
@@ -47,7 +47,7 @@ public class TaskApplicationTests {
|
||||
|
||||
SpringApplication.run(TaskApplication.class, args);
|
||||
|
||||
String output = this.outputCapture.toString();
|
||||
String output = capturedOutput.toString();
|
||||
assertThat(output.contains(TEST_DATE_DOTS))
|
||||
.as("Unable to find the timestamp: " + output).isTrue();
|
||||
assertThat(output.contains(CREATE_TASK_MESSAGE))
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.task.timestamp;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
@@ -24,13 +25,14 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
public class TimestampTaskPropertiesTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testEmptyFormat() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues testPropertyValues = TestPropertyValues.of("format:");
|
||||
@@ -39,7 +41,9 @@ public class TimestampTaskPropertiesTests {
|
||||
context.refresh();
|
||||
TimestampTaskProperties properties = context
|
||||
.getBean(TimestampTaskProperties.class);
|
||||
properties.getFormat();
|
||||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
|
||||
properties.getFormat();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user