Skip to content

Commit d4b7cef

Browse files
committed
Fix deprecations in MongoDB and WebFlux modules
Related to spring-projects/spring-framework@a663454
1 parent a1f016a commit d4b7cef

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2017 the original author or authors.
2+
* Copyright 2013-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,14 +51,15 @@
5151
* @author Amol Nayak
5252
* @author Artem Bilan
5353
* @author Gary Russell
54+
*
5455
* @since 3.0
5556
*/
5657
public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDbMessageStore
5758
implements MessageStore {
5859

5960
public final static String DEFAULT_COLLECTION_NAME = "configurableStoreMessages";
6061

61-
private final Collection<MessageGroupCallback> expiryCallbacks = new LinkedHashSet<MessageGroupCallback>();
62+
private final Collection<MessageGroupCallback> expiryCallbacks = new LinkedHashSet<>();
6263

6364
private volatile boolean timeoutOnIdle;
6465

@@ -133,7 +134,7 @@ public Message<?> removeMessage(UUID id) {
133134
public long getMessageCount() {
134135
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
135136
.and(MessageDocumentFields.GROUP_ID).exists(false));
136-
return this.mongoTemplate.getCollection(this.collectionName).count(query.getQueryObject());
137+
return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject());
137138
}
138139

139140

spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -248,7 +248,7 @@ public MessageMetadata getMessageMetadata(UUID id) {
248248
@Override
249249
@ManagedAttribute
250250
public long getMessageCount() {
251-
return this.template.getCollection(this.collectionName).count();
251+
return this.template.getCollection(this.collectionName).countDocuments();
252252
}
253253

254254
@Override

spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,6 +40,8 @@
4040
*
4141
* @author Oleg Zhurakousky
4242
* @author Xavier Padró
43+
* @author Artem Bilan
44+
*
4345
* @since 2.1
4446
*/
4547
public abstract class MongoDbAvailableTests {
@@ -48,7 +50,7 @@ public abstract class MongoDbAvailableTests {
4850
public MongoDbAvailableRule redisAvailableRule = new MongoDbAvailableRule();
4951

5052

51-
protected MongoDbFactory prepareMongoFactory(String... additionalCollectionsToDrop) throws Exception {
53+
protected MongoDbFactory prepareMongoFactory(String... additionalCollectionsToDrop) {
5254
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
5355
cleanupCollections(mongoDbFactory, additionalCollectionsToDrop);
5456
return mongoDbFactory;
@@ -151,6 +153,7 @@ public static class TestMongoConverter extends MappingMongoConverter {
151153
public TestMongoConverter(
152154
MongoDbFactory mongoDbFactory,
153155
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {
156+
154157
super(new DefaultDbRefResolver(mongoDbFactory), mappingContext);
155158
}
156159

@@ -170,7 +173,7 @@ public static class TestCollectionCallback implements CollectionCallback<Long> {
170173

171174
@Override
172175
public Long doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException {
173-
return collection.count();
176+
return collection.countDocuments();
174177
}
175178

176179
}

spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
2424
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
2525
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
26-
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
27-
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
2826

2927
import java.security.Principal;
3028
import java.util.Collections;
@@ -139,7 +137,6 @@ public void setup() {
139137
WebTestClient.bindToApplicationContext(this.wac)
140138
.apply(SecurityMockServerConfigurers.springSecurity())
141139
.configureClient()
142-
.filter(basicAuthentication())
143140
.build();
144141
}
145142

@@ -217,7 +214,7 @@ public void testHttpReactiveProxyFlow() throws Exception {
217214
@SuppressWarnings("unchecked")
218215
public void testHttpReactivePost() {
219216
this.webTestClient.post().uri("/reactivePost")
220-
.attributes(basicAuthenticationCredentials("guest", "guest"))
217+
.headers(headers -> headers.setBasicAuth("guest", "guest"))
221218
.body(Mono.just("foo\nbar\nbaz"), String.class)
222219
.exchange()
223220
.expectStatus().isAccepted();
@@ -239,7 +236,7 @@ public void testHttpReactivePost() {
239236
public void testSse() {
240237
Flux<String> responseBody =
241238
this.webTestClient.get().uri("/sse")
242-
.attributes(basicAuthenticationCredentials("guest", "guest"))
239+
.headers(headers -> headers.setBasicAuth("guest", "guest"))
243240
.exchange()
244241
.returnResult(String.class)
245242
.getResponseBody();
@@ -263,15 +260,15 @@ public void testDynamicHttpEndpoint() throws Exception {
263260
this.integrationFlowContext.registration(flow).register();
264261

265262
this.webTestClient.get().uri("/dynamic?name=BAR")
266-
.attributes(basicAuthenticationCredentials("guest", "guest"))
263+
.headers(headers -> headers.setBasicAuth("guest", "guest"))
267264
.exchange()
268265
.expectBody(String.class)
269266
.isEqualTo("bar");
270267

271268
flowRegistration.destroy();
272269

273270
this.webTestClient.get().uri("/dynamic?name=BAZ")
274-
.attributes(basicAuthenticationCredentials("guest", "guest"))
271+
.headers(headers -> headers.setBasicAuth("guest", "guest"))
275272
.exchange()
276273
.expectStatus()
277274
.isNotFound();

0 commit comments

Comments
 (0)