Skip to content

Commit c762ba7

Browse files
committed
Merge branch '3.5.x'
Closes gh-46892
2 parents 0454b08 + 7fd38ef commit c762ba7

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

module/spring-boot-mongodb/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies {
4949
testImplementation(project(":core:spring-boot-test"))
5050
testImplementation(project(":test-support:spring-boot-test-support"))
5151
testImplementation(testFixtures(project(":core:spring-boot-testcontainers")))
52+
testImplementation("org.springframework.data:spring-data-mongodb")
5253

5354
testRuntimeOnly("ch.qos.logback:logback-classic")
5455
testRuntimeOnly("io.netty:netty-handler")

module/spring-boot-mongodb/src/main/java/org/springframework/boot/mongodb/autoconfigure/MongoProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public class MongoProperties {
114114
/**
115115
* Representation to use when converting a UUID to a BSON binary value.
116116
*/
117-
private UuidRepresentation uuidRepresentation = UuidRepresentation.JAVA_LEGACY;
117+
private UuidRepresentation uuidRepresentation = UuidRepresentation.STANDARD;
118118

119119
private final Ssl ssl = new Ssl();
120120

module/spring-boot-mongodb/src/test/java/org/springframework/boot/mongodb/autoconfigure/MongoAutoConfigurationTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,6 @@ public ConnectionString getConnectionString() {
260260
.doesNotHaveBean(PropertiesMongoConnectionDetails.class));
261261
}
262262

263-
@Test
264-
void uuidRepresentationDefaultsAreAligned() {
265-
this.contextRunner.run((context) -> assertThat(getSettings(context).getUuidRepresentation())
266-
.isEqualTo(new MongoProperties().getUuidRepresentation()));
267-
}
268-
269263
private MongoClientSettings getSettings(AssertableApplicationContext context) {
270264
assertThat(context).hasSingleBean(MongoClient.class);
271265
MongoClientImpl client = (MongoClientImpl) context.getBean(MongoClient.class);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.mongodb.autoconfigure;
18+
19+
import org.bson.UuidRepresentation;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.data.mongodb.config.MongoConfigurationSupport;
23+
24+
import static org.assertj.core.api.Assertions.assertThat;
25+
26+
/**
27+
* Tests for {@link MongoProperties}.
28+
*
29+
* @author Andy Wilkinson
30+
*/
31+
class MongoPropertiesTests {
32+
33+
@Test
34+
void defaultUUidRepresentationIsAlignedWithSpringData() {
35+
UuidRepresentation springDataDefault = springDataDefaultUuidRepresentation();
36+
UuidRepresentation springBootDefault = new MongoProperties().getUuidRepresentation();
37+
assertThat(springBootDefault).isEqualTo(springDataDefault);
38+
}
39+
40+
private UuidRepresentation springDataDefaultUuidRepresentation() {
41+
return new MongoConfigurationSupport() {
42+
43+
@Override
44+
protected String getDatabaseName() {
45+
return "test";
46+
}
47+
48+
UuidRepresentation defaultUuidRepresentation() {
49+
return mongoClientSettings().getUuidRepresentation();
50+
}
51+
52+
}.defaultUuidRepresentation();
53+
}
54+
55+
}

0 commit comments

Comments
 (0)