Skip to content

Commit f81d29a

Browse files
Adapt to upcoming changes in core framework.
This commit makes sure to move off deprecated API and changes event listener generics in tests to comply with java assignability rules. Closes: spring-projects#4749
1 parent 404fde7 commit f81d29a

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/event/AfterSaveListener.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import org.springframework.context.ApplicationEvent;
2121
import org.springframework.context.ApplicationListener;
2222

23-
public class AfterSaveListener implements ApplicationListener<AfterSaveEvent<Object>> {
23+
public class AfterSaveListener implements ApplicationListener<AfterSaveEvent<? extends Object>> {
2424

2525
public final ArrayList<ApplicationEvent> seenEvents = new ArrayList<ApplicationEvent>();
2626

27-
public void onApplicationEvent(AfterSaveEvent<Object> event) {
27+
public void onApplicationEvent(AfterSaveEvent<? extends Object> event) {
2828
this.seenEvents.add(event);
2929
}
3030

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/CriteriaTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.springframework.data.mongodb.core.query.Query.*;
2121

2222
import java.util.Arrays;
23+
import java.util.Base64;
2324

2425
import org.bson.types.Binary;
2526
import org.junit.jupiter.api.BeforeEach;
@@ -29,7 +30,6 @@
2930
import org.springframework.data.mongodb.test.util.MongoTemplateExtension;
3031
import org.springframework.data.mongodb.test.util.MongoTestTemplate;
3132
import org.springframework.data.mongodb.test.util.Template;
32-
import org.springframework.util.Base64Utils;
3333

3434
/**
3535
* Integration tests for {@link Criteria} usage as part of a {@link Query}.
@@ -50,7 +50,7 @@ class CriteriaTests {
5050
static final DocumentWithBitmask TWENTY_FLOAT/*00010100*/ = new DocumentWithBitmask("3", Float.valueOf(20),
5151
Integer.toBinaryString(20));
5252
static final DocumentWithBitmask ONE_HUNDRED_TWO/*01100110*/ = new DocumentWithBitmask("4",
53-
new Binary(Base64Utils.decodeFromString("Zg==")), "01100110");
53+
new Binary(Base64.getDecoder().decode("Zg==")), "01100110");
5454

5555
@BeforeEach
5656
void beforeEach() {

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/ReactiveStringBasedMongoQueryUnitTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import reactor.core.publisher.Mono;
2626

2727
import java.lang.reflect.Method;
28+
import java.util.Base64;
2829
import java.util.Collections;
2930
import java.util.Map;
3031

@@ -55,7 +56,6 @@
5556
import org.springframework.data.spel.spi.EvaluationContextExtension;
5657
import org.springframework.data.spel.spi.ReactiveEvaluationContextExtension;
5758
import org.springframework.expression.spel.standard.SpelExpressionParser;
58-
import org.springframework.util.Base64Utils;
5959

6060
/**
6161
* Unit tests for {@link ReactiveStringBasedMongoQuery}.
@@ -224,7 +224,7 @@ public void shouldSupportNonQuotedBinaryDataReplacement() throws Exception {
224224

225225
org.springframework.data.mongodb.core.query.Query query = mongoQuery.createQuery(accesor).block();
226226
org.springframework.data.mongodb.core.query.Query reference = new BasicQuery(
227-
"{'lastname' : { '$binary' : '" + Base64Utils.encodeToString(binaryData) + "', '$type' : '" + 0 + "'}}");
227+
"{'lastname' : { '$binary' : '" + Base64.getEncoder().encodeToString(binaryData) + "', '$type' : '" + 0 + "'}}");
228228

229229
assertThat(query.getQueryObject().toJson()).isEqualTo(reference.getQueryObject().toJson());
230230
}

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/StringBasedMongoQueryUnitTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.charset.StandardCharsets;
2424
import java.util.ArrayList;
2525
import java.util.Arrays;
26+
import java.util.Base64;
2627
import java.util.Collections;
2728
import java.util.List;
2829
import java.util.Map;
@@ -60,7 +61,6 @@
6061
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
6162
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
6263
import org.springframework.expression.spel.standard.SpelExpressionParser;
63-
import org.springframework.util.Base64Utils;
6464

6565
import com.mongodb.MongoClientSettings;
6666
import com.mongodb.reactivestreams.client.MongoClients;
@@ -329,7 +329,7 @@ public void shouldSupportNonQuotedBinaryDataReplacement() {
329329

330330
org.springframework.data.mongodb.core.query.Query query = mongoQuery.createQuery(accessor);
331331
org.springframework.data.mongodb.core.query.Query reference = new BasicQuery("{'lastname' : { '$binary' : '"
332-
+ Base64Utils.encodeToString(binaryData) + "', '$type' : '" + BsonBinarySubType.BINARY.getValue() + "'}}");
332+
+ Base64.getEncoder().encodeToString(binaryData) + "', '$type' : '" + BsonBinarySubType.BINARY.getValue() + "'}}");
333333

334334
assertThat(query.getQueryObject().toJson()).isEqualTo(reference.getQueryObject().toJson());
335335
}
@@ -344,7 +344,7 @@ public void shouldSupportNonQuotedBinaryCollectionDataReplacement() {
344344

345345
org.springframework.data.mongodb.core.query.Query query = mongoQuery.createQuery(accessor);
346346
org.springframework.data.mongodb.core.query.Query reference = new BasicQuery("{'lastname' : { $in: [{'$binary' : '"
347-
+ Base64Utils.encodeToString(binaryData) + "', '$type' : '" + BsonBinarySubType.BINARY.getValue() + "'}] }}");
347+
+ Base64.getEncoder().encodeToString(binaryData) + "', '$type' : '" + BsonBinarySubType.BINARY.getValue() + "'}] }}");
348348

349349
assertThat(query.getQueryObject().toJson()).isEqualTo(reference.getQueryObject().toJson());
350350
}

0 commit comments

Comments
 (0)