diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java index c98c8bd4d3..64cd48b812 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ import org.springframework.util.Assert; * @author Amol Nayak * @author Artem Bilan * @author Gary Russell + * * @since 3.0 */ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDbMessageStore @@ -58,7 +59,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb public final static String DEFAULT_COLLECTION_NAME = "configurableStoreMessages"; - private final Collection expiryCallbacks = new LinkedHashSet(); + private final Collection expiryCallbacks = new LinkedHashSet<>(); private volatile boolean timeoutOnIdle; @@ -133,7 +134,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb public long getMessageCount() { Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true) .and(MessageDocumentFields.GROUP_ID).exists(false)); - return this.mongoTemplate.getCollection(this.collectionName).count(query.getQueryObject()); + return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject()); } diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java index 76feaf74a7..87b2c34b2c 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -248,7 +248,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore @Override @ManagedAttribute public long getMessageCount() { - return this.template.getCollection(this.collectionName).count(); + return this.template.getCollection(this.collectionName).countDocuments(); } @Override diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableTests.java index f8aa7a2727..95ef3d354c 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,8 @@ import com.mongodb.client.MongoCollection; * * @author Oleg Zhurakousky * @author Xavier PadrĂ³ + * @author Artem Bilan + * * @since 2.1 */ public abstract class MongoDbAvailableTests { @@ -48,7 +50,7 @@ public abstract class MongoDbAvailableTests { public MongoDbAvailableRule redisAvailableRule = new MongoDbAvailableRule(); - protected MongoDbFactory prepareMongoFactory(String... additionalCollectionsToDrop) throws Exception { + protected MongoDbFactory prepareMongoFactory(String... additionalCollectionsToDrop) { MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test"); cleanupCollections(mongoDbFactory, additionalCollectionsToDrop); return mongoDbFactory; @@ -151,6 +153,7 @@ public abstract class MongoDbAvailableTests { public TestMongoConverter( MongoDbFactory mongoDbFactory, MappingContext, MongoPersistentProperty> mappingContext) { + super(new DefaultDbRefResolver(mongoDbFactory), mappingContext); } @@ -170,7 +173,7 @@ public abstract class MongoDbAvailableTests { @Override public Long doInCollection(MongoCollection collection) throws MongoException, DataAccessException { - return collection.count(); + return collection.countDocuments(); } } diff --git a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java index 3e8d888356..4d9c578d41 100644 --- a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java +++ b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java @@ -23,8 +23,6 @@ import static org.junit.Assert.assertThat; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials; -import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication; import java.security.Principal; import java.util.Collections; @@ -139,7 +137,6 @@ public class WebFluxDslTests { WebTestClient.bindToApplicationContext(this.wac) .apply(SecurityMockServerConfigurers.springSecurity()) .configureClient() - .filter(basicAuthentication()) .build(); } @@ -217,7 +214,7 @@ public class WebFluxDslTests { @SuppressWarnings("unchecked") public void testHttpReactivePost() { this.webTestClient.post().uri("/reactivePost") - .attributes(basicAuthenticationCredentials("guest", "guest")) + .headers(headers -> headers.setBasicAuth("guest", "guest")) .body(Mono.just("foo\nbar\nbaz"), String.class) .exchange() .expectStatus().isAccepted(); @@ -239,7 +236,7 @@ public class WebFluxDslTests { public void testSse() { Flux responseBody = this.webTestClient.get().uri("/sse") - .attributes(basicAuthenticationCredentials("guest", "guest")) + .headers(headers -> headers.setBasicAuth("guest", "guest")) .exchange() .returnResult(String.class) .getResponseBody(); @@ -263,7 +260,7 @@ public class WebFluxDslTests { this.integrationFlowContext.registration(flow).register(); this.webTestClient.get().uri("/dynamic?name=BAR") - .attributes(basicAuthenticationCredentials("guest", "guest")) + .headers(headers -> headers.setBasicAuth("guest", "guest")) .exchange() .expectBody(String.class) .isEqualTo("bar"); @@ -271,7 +268,7 @@ public class WebFluxDslTests { flowRegistration.destroy(); this.webTestClient.get().uri("/dynamic?name=BAZ") - .attributes(basicAuthenticationCredentials("guest", "guest")) + .headers(headers -> headers.setBasicAuth("guest", "guest")) .exchange() .expectStatus() .isNotFound();