Validate our own tests work with JUnit5 and the vintage engine
Closes gh-14737 Co-authored-by: Stephane Nicoll <snicoll@pivotal.io>
This commit is contained in:
committed by
Stephane Nicoll
parent
d9f339a1b6
commit
1db1c8b03c
@@ -16,8 +16,8 @@
|
||||
|
||||
package sample.propertyvalidation;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
@@ -33,17 +33,17 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Lucas Saldanha
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SamplePropertyValidationApplicationTests {
|
||||
class SamplePropertyValidationApplicationTests {
|
||||
|
||||
private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void closeContext() {
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindValidProperties() {
|
||||
void bindValidProperties() {
|
||||
this.context.register(SamplePropertyValidationApplication.class);
|
||||
TestPropertyValues.of("sample.host:192.168.0.1", "sample.port:9090")
|
||||
.applyTo(this.context);
|
||||
@@ -54,7 +54,7 @@ public class SamplePropertyValidationApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindInvalidHost() {
|
||||
void bindInvalidHost() {
|
||||
this.context.register(SamplePropertyValidationApplication.class);
|
||||
TestPropertyValues.of("sample.host:xxxxxx", "sample.port:9090")
|
||||
.applyTo(this.context);
|
||||
@@ -64,7 +64,7 @@ public class SamplePropertyValidationApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindNullHost() {
|
||||
void bindNullHost() {
|
||||
this.context.register(SamplePropertyValidationApplication.class);
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.context.refresh())
|
||||
@@ -72,7 +72,7 @@ public class SamplePropertyValidationApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validatorOnlyCalledOnSupportedClass() {
|
||||
void validatorOnlyCalledOnSupportedClass() {
|
||||
this.context.register(SamplePropertyValidationApplication.class);
|
||||
this.context.register(ServerProperties.class); // our validator will not apply
|
||||
TestPropertyValues.of("sample.host:192.168.0.1", "sample.port:9090")
|
||||
|
||||
Reference in New Issue
Block a user