update to Java 13, fixing build
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package io.reflectoring;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
myapp.mail.enabled=true
|
||||
myapp
|
||||
myapp.mail.pauseBetweenMails=5s
|
||||
myapp.mail.maxAttachmentSize=1MB
|
||||
myapp.mail.smtpServers[0]=server1
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
package io.reflectoring.configuration.mail;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(properties = {
|
||||
"myapp.mail.enabled=asd",
|
||||
"myapp.mail.defaultSubject=hello",
|
||||
"myapp.mail.pauseBetweenMails=5s",
|
||||
"myapp.mail.maxAttachmentSize=1MB",
|
||||
"myapp.mail.smtpServers[0]=server1",
|
||||
"myapp.mail.smtpServers[1]=server2",
|
||||
"myapp.mail.maxAttachmentWeight=5kg"
|
||||
"myapp.mail.enabled=asd",
|
||||
"myapp.mail.defaultSubject=hello",
|
||||
"myapp.mail.pauseBetweenMails=5s",
|
||||
"myapp.mail.maxAttachmentSize=1MB",
|
||||
"myapp.mail.smtpServers[0]=server1",
|
||||
"myapp.mail.smtpServers[1]=server2",
|
||||
"myapp.mail.maxAttachmentWeight=5kg"
|
||||
})
|
||||
class MailModuleTestWithAllProperties {
|
||||
|
||||
@Autowired(required = false)
|
||||
private MailModuleProperties mailModuleProperties;
|
||||
@Autowired(required = false)
|
||||
private MailModuleProperties mailModuleProperties;
|
||||
|
||||
@Test
|
||||
void propertiesAreLoaded() {
|
||||
assertThat(mailModuleProperties).isNotNull();
|
||||
assertThat(mailModuleProperties.getDefaultSubject()).isEqualTo("hello");
|
||||
assertThat(mailModuleProperties.getEnabled()).isTrue();
|
||||
assertThat(mailModuleProperties.getPauseBetweenMails()).isEqualByComparingTo(Duration.ofSeconds(5));
|
||||
assertThat(mailModuleProperties.getMaxAttachmentSize()).isEqualByComparingTo(DataSize.ofMegabytes(1));
|
||||
assertThat(mailModuleProperties.getSmtpServers()).hasSize(2);
|
||||
assertThat(mailModuleProperties.getMaxAttachmentWeight().getGrams()).isEqualTo(5000L);
|
||||
}
|
||||
@Test
|
||||
void propertiesAreLoaded() {
|
||||
assertThat(mailModuleProperties).isNotNull();
|
||||
assertThat(mailModuleProperties.getDefaultSubject()).isEqualTo("hello");
|
||||
assertThat(mailModuleProperties.getEnabled()).isTrue();
|
||||
assertThat(mailModuleProperties.getPauseBetweenMails()).isEqualByComparingTo(Duration.ofSeconds(5));
|
||||
assertThat(mailModuleProperties.getMaxAttachmentSize()).isEqualByComparingTo(DataSize.ofMegabytes(1));
|
||||
assertThat(mailModuleProperties.getSmtpServers()).hasSize(2);
|
||||
assertThat(mailModuleProperties.getMaxAttachmentWeight().getGrams()).isEqualTo(5000L);
|
||||
}
|
||||
}
|
||||
@@ -70,8 +70,7 @@ class PropertiesInvalidInputTest {
|
||||
assertThatThrownBy(application::run)
|
||||
.isInstanceOf(ConfigurationPropertiesBindException.class)
|
||||
.hasRootCauseInstanceOf(BindValidationException.class)
|
||||
.hasStackTraceContaining("Field error in object 'app.properties' on field 'report.intervalInDays'")
|
||||
.hasStackTraceContaining("[must be less than or equal to 30]");
|
||||
.hasStackTraceContaining("rejected value [31]");
|
||||
|
||||
}
|
||||
|
||||
@@ -83,8 +82,7 @@ class PropertiesInvalidInputTest {
|
||||
assertThatThrownBy(application::run)
|
||||
.isInstanceOf(ConfigurationPropertiesBindException.class)
|
||||
.hasRootCauseInstanceOf(BindValidationException.class)
|
||||
.hasStackTraceContaining("Field error in object 'app.properties' on field 'report.intervalInDays'")
|
||||
.hasStackTraceContaining("[must be greater than or equal to 7]");
|
||||
.hasStackTraceContaining("rejected value [6]");
|
||||
|
||||
}
|
||||
|
||||
@@ -96,8 +94,7 @@ class PropertiesInvalidInputTest {
|
||||
assertThatThrownBy(application::run)
|
||||
.isInstanceOf(ConfigurationPropertiesBindException.class)
|
||||
.hasRootCauseInstanceOf(BindValidationException.class)
|
||||
.hasStackTraceContaining("Field error in object 'app.properties' on field 'report.emailAddress'")
|
||||
.hasStackTraceContaining("[must be a well-formed email address]");
|
||||
.hasStackTraceContaining("rejected value [manager.analysisapp.com]");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user