Merge branch 'master' into BAEL-19751

This commit is contained in:
kwoyke 2020-01-29 19:59:07 +01:00 committed by GitHub
commit f61ef578ba
23 changed files with 1425 additions and 120 deletions

View File

@ -4,6 +4,7 @@ import org.junit.Test;
import java.time.OffsetDateTime;
import java.util.Date;
import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -18,12 +19,19 @@ public class ConvertToOffsetDateTimeUnitTest {
@Test
public void givenDate_whenHasOffset_thenConvertWithOffset() {
TimeZone prevTimezone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Date date = new Date();
date.setHours(6);
date.setMinutes(30);
OffsetDateTime odt = ConvertToOffsetDateTime.convert(date, 3, 30);
assertEquals(10, odt.getHour());
assertEquals(0, odt.getMinute());
// Reset the timezone to its original value to prevent side effects
TimeZone.setDefault(prevTimezone);
}
}

View File

@ -1,13 +1,17 @@
package com.baeldung.batch.understanding;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Properties;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import org.junit.jupiter.api.Test;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Disabled("Should be fixed in BAEL-3812")
class SimpleBatchLetUnitTest {
@Test
public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception {

View File

@ -1,21 +1,19 @@
package com.baeldung.batch.understanding;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.Metric.MetricType;
import javax.batch.runtime.StepExecution;
import java.util.List;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
@Disabled("Should be fixed in BAEL-3812")
class SimpleErrorChunkUnitTest {
@Test

View File

@ -641,7 +641,6 @@
<module>spring-boot</module>
<module>spring-boot-modules</module>
<module>spring-boot-angular</module>
<module>spring-boot-artifacts</module>
<module>spring-boot-autoconfiguration</module>
<module>spring-boot-bootstrap</module>
<module>spring-boot-camel</module>
@ -1175,7 +1174,6 @@
<module>spring-boot</module>
<module>spring-boot-modules</module>
<module>spring-boot-angular</module>
<module>spring-boot-artifacts</module>
<module>spring-boot-autoconfiguration</module>
<module>spring-boot-bootstrap</module>
<module>spring-boot-camel</module>

View File

@ -15,6 +15,7 @@
<modules>
<module>spring-boot-admin</module>
<module>spring-boot-artifacts</module>
<module>spring-boot-data</module>
<module>spring-boot-mvc-birt</module>
<module>spring-boot-properties</module>

View File

@ -11,7 +11,7 @@
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>

View File

@ -0,0 +1,14 @@
package com.baeldung.configurationproperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
@SpringBootApplication
@ConfigurationPropertiesScan
public class ImmutableConfigPropertiesApp {
public static void main(String[] args) {
SpringApplication.run(ImmutableConfigPropertiesApp.class, args);
}
}

View File

@ -0,0 +1,31 @@
package com.baeldung.configurationproperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
@ConfigurationProperties(prefix = "mail.credentials")
@ConstructorBinding
public class ImmutableCredentials {
private final String authMethod;
private final String username;
private final String password;
public ImmutableCredentials(String authMethod, String username, String password) {
this.authMethod = authMethod;
this.username = username;
this.password = password;
}
public String getAuthMethod() {
return authMethod;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
}

View File

@ -0,0 +1,26 @@
package com.baeldung.configurationproperties;
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.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ImmutableConfigPropertiesApp.class)
@TestPropertySource("classpath:configprops-test.properties")
public class ImmutableConfigurationPropertiesIntegrationTest {
@Autowired
private ImmutableCredentials immutableCredentials;
@Test
public void whenConstructorBindingUsed_thenPropertiesCorrectlyBound() {
assertThat(immutableCredentials.getAuthMethod()).isEqualTo("SHA1");
assertThat(immutableCredentials.getUsername()).isEqualTo("john");
assertThat(immutableCredentials.getPassword()).isEqualTo("password");
}
}

View File

@ -14,8 +14,6 @@ import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
// If we want to enable xml configurations for message-converter:
// @ImportResource("classpath:WEB-INF/api-servlet.xml")
public class WebConfig implements WebMvcConfigurer {
// @Override

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- We have to exclude Spring Boot's WebMvcAutoConfiguration if we want the xml-configured message-converters to work properly -->
<!-- <mvc:annotation-driven> -->
<!-- <mvc:message-converters -->
<!-- register-defaults="true"> -->
<!-- <bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"> -->
<!-- <property name="marshaller" ref="xstreamMarshaller" /> -->
<!-- <property name="unmarshaller" ref="xstreamMarshaller" /> -->
<!-- </bean> -->
<!-- <bean -->
<!-- class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" /> -->
<!-- </mvc:message-converters> -->
<!-- </mvc:annotation-driven> -->
<!-- <bean id="xstreamMarshaller" -->
<!-- class="org.springframework.oxm.xstream.XStreamMarshaller"> -->
<!-- <property name="autodetectAnnotations" value="true" /> -->
<!-- </bean> -->
<!-- -->
<!-- Also, we can JUST add a HttpMessageConverter Bean to the existing Spring Boot Autoconfiguration: -->
<!-- <bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"> -->
<!-- <property name="marshaller" ref="xstreamMarshaller" /> -->
<!-- <property name="unmarshaller" ref="xstreamMarshaller" /> -->
<!-- </bean> -->
<!-- <bean id="xstreamMarshaller" -->
<!-- class="org.springframework.oxm.xstream.XStreamMarshaller"> -->
<!-- <property name="autodetectAnnotations" value="true" /> -->
<!-- </bean> -->
</beans>

View File

@ -30,7 +30,7 @@
<module>spring-security-mvc-persisted-remember-me</module>
<module>spring-security-mvc-socket</module>
<module>spring-security-oidc</module>
<!--<module>spring-security-react</module> --> <!-- Module broken, fixing in BAEL-20772 -->
<module>spring-security-react</module>
<module>spring-security-rest</module>
<module>spring-security-rest-basic-auth</module>

View File

@ -6,8 +6,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = { MvcConfig.class, SecSecurityConfig.class })
public class SpringContextTest {

View File

@ -25,13 +25,11 @@
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-mongodb</artifactId>
<version>${spring-session-data-mongodb.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${spring-boot-starter-data-mongodb.version}</version>
</dependency>
<dependency>
@ -56,9 +54,4 @@
</plugins>
</build>
<properties>
<spring-session-data-mongodb.version>2.1.3.RELEASE</spring-session-data-mongodb.version>
<spring-boot-starter-data-mongodb.version>2.1.5.RELEASE</spring-boot-starter-data-mongodb.version>
</properties>
</project>

View File

@ -10,7 +10,7 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Base64;
@ -24,7 +24,7 @@ public class SpringSessionMongoDBIntegrationTest {
private int port;
@Autowired
private MongoOperationsSessionRepository repository;
private MongoIndexedSessionRepository repository;
private TestRestTemplate restTemplate = new TestRestTemplate();