Skip to content

Commit 529a0c7

Browse files
sxhinzvcchristophstrobl
authored andcommitted
Fix test setup so that temporal conversions use symmetric timezone setting.
Closes: #4446 Original Pull Request: #4447
1 parent 77a9622 commit 529a0c7

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.net.URL;
3131
import java.time.LocalDate;
3232
import java.time.LocalDateTime;
33-
import java.time.ZoneOffset;
3433
import java.time.temporal.ChronoUnit;
3534
import java.util.*;
3635

@@ -110,6 +109,7 @@
110109
* @author Mark Paluch
111110
* @author Roman Puchkovskiy
112111
* @author Heesu Jung
112+
* @author Julia Lee
113113
*/
114114
@ExtendWith(MockitoExtension.class)
115115
class MappingMongoConverterUnitTests {
@@ -2623,7 +2623,7 @@ void readsMapThatDoesNotComeAsDocument() {
26232623
void projectShouldReadSimpleInterfaceProjection() {
26242624

26252625
org.bson.Document source = new org.bson.Document("birthDate",
2626-
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay().toInstant(ZoneOffset.UTC))).append("foo", "Walter");
2626+
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay(systemDefault()).toInstant())).append("foo", "Walter");
26272627

26282628
EntityProjectionIntrospector discoverer = EntityProjectionIntrospector.create(converter.getProjectionFactory(),
26292629
EntityProjectionIntrospector.ProjectionPredicate.typeHierarchy()
@@ -2641,7 +2641,7 @@ void projectShouldReadSimpleInterfaceProjection() {
26412641
void projectShouldReadSimpleDtoProjection() {
26422642

26432643
org.bson.Document source = new org.bson.Document("birthDate",
2644-
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay().toInstant(ZoneOffset.UTC))).append("foo", "Walter");
2644+
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay(systemDefault()).toInstant())).append("foo", "Walter");
26452645

26462646
EntityProjectionIntrospector introspector = EntityProjectionIntrospector.create(converter.getProjectionFactory(),
26472647
EntityProjectionIntrospector.ProjectionPredicate.typeHierarchy()

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/encryption/AbstractEncryptionTestBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070

7171
/**
7272
* @author Christoph Strobl
73+
* @author Julia Lee
7374
*/
7475
public abstract class AbstractEncryptionTestBase {
7576

@@ -450,7 +451,8 @@ public MongoClient mongoClient() {
450451
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {
451452

452453
converterConfigurationAdapter
453-
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext));
454+
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext))
455+
.useNativeDriverJavaTimeCodecs();
454456
}
455457

456458
@Bean

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/encryption/BypassAutoEncryptionTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* Encryption tests for client having {@link AutoEncryptionSettings#isBypassAutoEncryption()}.
4646
*
4747
* @author Christoph Strobl
48+
* @author Julia Lee
4849
*/
4950
@ExtendWith(SpringExtension.class)
5051
@ContextConfiguration(classes = Config.class)
@@ -78,7 +79,8 @@ protected void configureClientSettings(Builder builder) {
7879
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {
7980

8081
converterConfigurationAdapter
81-
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext));
82+
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext))
83+
.useNativeDriverJavaTimeCodecs();
8284
}
8385

8486
@Bean

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/encryption/EncryptionTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
/**
5959
* @author Christoph Strobl
60+
* @author Julia Lee
6061
*/
6162
@ExtendWith(SpringExtension.class)
6263
@ContextConfiguration(classes = Config.class)
@@ -82,7 +83,8 @@ public MongoClient mongoClient() {
8283
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {
8384

8485
converterConfigurationAdapter
85-
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext));
86+
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext))
87+
.useNativeDriverJavaTimeCodecs();
8688
}
8789

8890
@Bean

0 commit comments

Comments
 (0)