From 70587f5e2ff3de3ebd1a28b9faf1d9aeac2fb384 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 8 Mar 2022 10:08:36 -0500 Subject: [PATCH] Upgrade some deps; fix compatibility with them * Upgrade to the latest Spring portfolio stack; fix tests and effected classes * The move to the latest Micrometer does not affect code base --- build.gradle | 18 +-- ...ToObjectTransformerParserTests-context.xml | 2 +- .../handler/DelayHandlerTests.java | 1 + .../outbound/GraphQlMessageHandler.java | 3 +- .../outbound/GraphQlMessageHandlerTests.java | 9 +- .../integration/http/dsl/HttpDslTests.java | 117 +++++++++--------- .../ConfigurableMongoDbMessageStore.java | 5 +- .../mongodb/store/MessageDocument.java | 6 +- .../mongodb/store/MongoDbMessageStore.java | 5 +- .../AbstractMongoDbMessageStoreTests.java | 13 +- .../inbound/RedisInboundChannelAdapter.java | 6 +- .../redis/rules/RedisAvailableRule.java | 6 +- .../redis/rules/RedisAvailableTests.java | 6 +- .../webflux/dsl/WebFluxDslTests.java | 66 ++++------ 14 files changed, 126 insertions(+), 137 deletions(-) diff --git a/build.gradle b/build.gradle index 9ffd1a5615..afe00003e9 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ ext { apacheSshdVersion = '2.8.0' artemisVersion = '2.20.0' - aspectjVersion = '1.9.8.RC3' + aspectjVersion = '1.9.8' assertjVersion = '3.22.0' assertkVersion = '0.25' avroVersion = '1.11.0' @@ -83,9 +83,9 @@ ext { lettuceVersion = '6.1.6.RELEASE' log4jVersion = '2.17.1' mailVersion = '2.0.1' - micrometerVersion = '2.0.0-M1' + micrometerVersion = '2.0.0-SNAPSHOT' mockitoVersion = '4.2.0' - mongoDriverVersion = '4.4.1' + mongoDriverVersion = '4.5.0' mysqlVersion = '8.0.28' pahoMqttClientVersion = '1.2.5' postgresVersion = '42.3.1' @@ -97,14 +97,14 @@ ext { saajVersion = '2.0.1' servletApiVersion = '5.0.0' smackVersion = '4.3.5' - springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '3.0.0-M1' - springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2022.0.0-M1' - springGraphqlVersion = '1.0.0-M5' + springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '3.0.0-SNAPSHOT' + springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2022.0.0-SNAPSHOT' + springGraphqlVersion = '1.0.0-SNAPSHOT' springKafkaVersion = '3.0.0-M1' springRetryVersion = '1.3.1' - springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '6.0.0-M1' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '6.0.0-M2' - springWsVersion = '4.0.0-M1' + springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '6.0.0-SNAPSHOT' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '6.0.0-SNAPSHOT' + springWsVersion = '4.0.0-SNAPSHOT' testcontainersVersion = '1.16.2' tomcatVersion = '10.0.14' xmlUnitVersion = '2.8.4' diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests-context.xml index 22f162302d..1cac904f17 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests-context.xml @@ -23,7 +23,7 @@ output-channel="outputA" ref="person"/> - + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java index 84cac0e69a..2b8c4bc0ca 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java @@ -139,6 +139,7 @@ public class DelayHandlerTests { } @Test + @SuppressWarnings("unchecked") public void errorFlowAndRetries() throws Exception { delayHandler.setDefaultDelay(10); delayHandler.setRetryDelay(15); diff --git a/spring-integration-graphql/src/main/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandler.java b/spring-integration-graphql/src/main/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandler.java index a12d42d045..48560892c9 100644 --- a/spring-integration-graphql/src/main/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandler.java +++ b/spring-integration-graphql/src/main/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandler.java @@ -38,6 +38,7 @@ import org.springframework.util.Assert; * GraphQL Query, Mutation and Subscription requests. * * @author Daniel Frey + * @author Artem Bilan * * @since 6.0 */ @@ -145,7 +146,7 @@ public class GraphQlMessageHandler extends AbstractReplyProducingMessageHandler String operationName = evaluateOperationNameExpression(requestMessage); Map variables = evaluateVariablesExpression(requestMessage); String id = evaluateExecutionIdExpression(requestMessage); - requestInput = new RequestInput(query, operationName, variables, this.locale, id); + requestInput = new RequestInput(query, operationName, variables, id, this.locale); } return this.graphQlService.execute(requestInput); diff --git a/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java b/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java index 9caffa62e8..c61f3e8179 100644 --- a/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java +++ b/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java @@ -64,6 +64,7 @@ import reactor.test.StepVerifier; /** * * @author Daniel Frey + * @author Artem Bilan * * @since 6.0 */ @@ -104,7 +105,7 @@ public class GraphQlMessageHandlerTests { .thenCancel() .verifyLater(); - RequestInput payload = new RequestInput("{ testQuery { id } }", null, null, null, UUID.randomUUID().toString()); + RequestInput payload = new RequestInput("{ testQuery { id } }", null, null, UUID.randomUUID().toString(), null); this.inputChannel.send(MessageBuilder.withPayload(payload).build()); verifier.verify(Duration.ofSeconds(10)); @@ -156,8 +157,8 @@ public class GraphQlMessageHandlerTests { .verifyLater(); RequestInput payload = - new RequestInput("mutation { update(id: \"" + fakeId + "\") { id } }", null, null, null, - UUID.randomUUID().toString()); + new RequestInput("mutation { update(id: \"" + fakeId + "\") { id } }", null, null, + UUID.randomUUID().toString(), null); this.inputChannel.send(MessageBuilder.withPayload(payload).build()); verifier.verify(Duration.ofSeconds(10)); @@ -195,7 +196,7 @@ public class GraphQlMessageHandlerTests { .verifyLater(); RequestInput payload = - new RequestInput("subscription { results { id } }", null, null, null, UUID.randomUUID().toString()); + new RequestInput("subscription { results { id } }", null, null, UUID.randomUUID().toString(), null); this.inputChannel.send(MessageBuilder.withPayload(payload).build()); verifier.verify(Duration.ofSeconds(10)); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java index 7fdc2561ef..efe5090ba4 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -63,13 +63,14 @@ import org.springframework.mock.web.MockPart; import org.springframework.security.access.AccessDecisionManager; import org.springframework.security.access.vote.AffirmativeBased; import org.springframework.security.access.vote.RoleVoter; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.factory.PasswordEncoderFactories; import org.springframework.security.provisioning.InMemoryUserDetailsManager; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; import org.springframework.test.web.client.MockMvcClientHttpRequestFactory; @@ -124,15 +125,15 @@ public class HttpDslTests { this.serviceInternalGatewayHandler.setRequestFactory(mockRequestFactory); this.mockMvc.perform( - get("/service") - .with(httpBasic("admin", "admin")) - .param("name", "foo")) + get("/service") + .with(httpBasic("admin", "admin")) + .param("name", "foo")) .andExpect(content().string("FOO")); this.mockMvc.perform( - get("/service") - .with(httpBasic("user", "user")) - .param("name", "name")) + get("/service") + .with(httpBasic("user", "user")) + .param("name", "name")) .andExpect(status().isForbidden()) .andExpect(content().string("Error")); } @@ -141,8 +142,8 @@ public class HttpDslTests { public void testDynamicHttpEndpoint() throws Exception { IntegrationFlow flow = IntegrationFlows.from(Http.inboundGateway("/dynamic") - .requestMapping(r -> r.params("name")) - .payloadExpression("#requestParams.name[0]")) + .requestMapping(r -> r.params("name")) + .payloadExpression("#requestParams.name[0]")) .transform(String::toLowerCase) .get(); @@ -150,17 +151,17 @@ public class HttpDslTests { this.integrationFlowContext.registration(flow).register(); this.mockMvc.perform( - get("/dynamic") - .with(httpBasic("user", "user")) - .param("name", "BAR")) + get("/dynamic") + .with(httpBasic("user", "user")) + .param("name", "BAR")) .andExpect(content().string("bar")); flowRegistration.destroy(); this.mockMvc.perform( - get("/dynamic") - .with(httpBasic("user", "user")) - .param("name", "BAZ")) + get("/dynamic") + .with(httpBasic("user", "user")) + .param("name", "BAZ")) .andExpect(status().isNotFound()); } @@ -176,9 +177,9 @@ public class HttpDslTests { MockPart mockPart2 = new MockPart("a1", "file2", "DEF".getBytes(StandardCharsets.UTF_8)); mockPart2.getHeaders().setContentType(MediaType.TEXT_PLAIN); this.mockMvc.perform( - multipart("/multiPartFiles") - .part(mockPart1, mockPart2) - .with(httpBasic("user", "user"))) + multipart("/multiPartFiles") + .part(mockPart1, mockPart2) + .with(httpBasic("user", "user"))) .andExpect(status().isOk()); Message result = this.multiPartFilesChannel.receive(10_000); @@ -214,12 +215,12 @@ public class HttpDslTests { public void testValidation() throws Exception { IntegrationFlow flow = IntegrationFlows.from( - Http.inboundChannelAdapter("/validation") - .requestMapping((mapping) -> mapping - .methods(HttpMethod.POST) - .consumes(MediaType.APPLICATION_JSON_VALUE)) - .requestPayloadType(TestModel.class) - .validator(this.validator)) + Http.inboundChannelAdapter("/validation") + .requestMapping((mapping) -> mapping + .methods(HttpMethod.POST) + .consumes(MediaType.APPLICATION_JSON_VALUE)) + .requestPayloadType(TestModel.class) + .validator(this.validator)) .bridge() .get(); @@ -227,10 +228,10 @@ public class HttpDslTests { this.integrationFlowContext.registration(flow).register(); this.mockMvc.perform( - post("/validation") - .with(httpBasic("user", "user")) - .contentType(MediaType.APPLICATION_JSON) - .content("{\"name\": \"\"}")) + post("/validation") + .with(httpBasic("user", "user")) + .contentType(MediaType.APPLICATION_JSON) + .content("{\"name\": \"\"}")) .andExpect(status().isBadRequest()) .andExpect(status().reason("Validation failure")); @@ -241,21 +242,21 @@ public class HttpDslTests { public void testBadRequest() throws Exception { IntegrationFlow flow = IntegrationFlows.from( - Http.inboundGateway("/badRequest") - .errorChannel((message, timeout) -> { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, - "Not valid request param", ((ErrorMessage) message).getPayload()); - }) - .payloadExpression("#requestParams.p1")) + Http.inboundGateway("/badRequest") + .errorChannel((message, timeout) -> { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, + "Not valid request param", ((ErrorMessage) message).getPayload()); + }) + .payloadExpression("#requestParams.p1")) .get(); IntegrationFlowContext.IntegrationFlowRegistration flowRegistration = this.integrationFlowContext.registration(flow).register(); this.mockMvc.perform( - get("/badRequest") - .with(httpBasic("user", "user")) - .param("p2", "P2")) + get("/badRequest") + .with(httpBasic("user", "user")) + .param("p2", "P2")) .andExpect(status().isBadRequest()) .andExpect(status().reason("Not valid request param")); @@ -266,16 +267,16 @@ public class HttpDslTests { public void testErrorChannelFlow() throws Exception { IntegrationFlow flow = IntegrationFlows.from( - Http.inboundGateway("/errorFlow") - .errorChannel(new FixedSubscriberChannel( - new AbstractReplyProducingMessageHandler() { + Http.inboundGateway("/errorFlow") + .errorChannel(new FixedSubscriberChannel( + new AbstractReplyProducingMessageHandler() { - @Override - protected Object handleRequestMessage(Message requestMessage) { - return "Error Response"; - } + @Override + protected Object handleRequestMessage(Message requestMessage) { + return "Error Response"; + } - }))) + }))) .transform((payload) -> { throw new RuntimeException("Error!"); }) @@ -285,8 +286,8 @@ public class HttpDslTests { this.integrationFlowContext.registration(flow).register(); this.mockMvc.perform( - get("/errorFlow") - .with(httpBasic("user", "user"))) + get("/errorFlow") + .with(httpBasic("user", "user"))) .andExpect(status().isOk()) .andExpect(content().string("Error Response")); @@ -296,9 +297,8 @@ public class HttpDslTests { @Configuration @EnableWebSecurity @EnableIntegration - public static class ContextConfiguration extends WebSecurityConfigurerAdapter { + public static class ContextConfiguration { - @Override @Bean public UserDetailsService userDetailsService() { InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); @@ -320,16 +320,18 @@ public class HttpDslTests { return manager; } - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + return http. + authorizeRequests() .antMatchers("/service/internal/**").hasRole("ADMIN") .anyRequest().permitAll() .and() .httpBasic() .and() .csrf().disable() - .anonymous().disable(); + .anonymous().disable() + .build(); } @Bean @@ -397,10 +399,11 @@ public class HttpDslTests { } @Bean - public ChannelSecurityInterceptor channelSecurityInterceptor(AccessDecisionManager accessDecisionManager) - throws Exception { + public ChannelSecurityInterceptor channelSecurityInterceptor(AccessDecisionManager accessDecisionManager, + AuthenticationManagerBuilder authenticationManagerBuilder) { + ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor(); - channelSecurityInterceptor.setAuthenticationManager(authenticationManager()); + channelSecurityInterceptor.setAuthenticationManager(authenticationManagerBuilder.getOrBuild()); channelSecurityInterceptor.setAccessDecisionManager(accessDecisionManager); return channelSecurityInterceptor; } 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 fd5a94948f..cb6c809f8f 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-2021 the original author or authors. + * Copyright 2013-2022 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. @@ -297,8 +297,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb Query query = groupOrderQuery(groupId); Stream documents = getMongoTemplate() - .stream(query, MessageDocument.class, this.collectionName) - .stream(); + .stream(query, MessageDocument.class, this.collectionName); return documents.map(MessageDocument::getMessage); } diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MessageDocument.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MessageDocument.java index c98358c7fd..534259bdd5 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MessageDocument.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MessageDocument.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 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. @@ -20,7 +20,7 @@ import java.util.UUID; import org.springframework.data.annotation.AccessType; import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; +import org.springframework.data.annotation.PersistenceCreator; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.lang.Nullable; import org.springframework.messaging.Message; @@ -77,7 +77,7 @@ public class MessageDocument { * @param messageId the id of the {@link Message} as a separate persistent property. * @since 5.1 */ - @PersistenceConstructor + @PersistenceCreator MessageDocument(Message message, UUID messageId) { Assert.notNull(message, "'message' must not be null"); Assert.notNull(messageId, "'message' ID header must not be null"); 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 502024a262..762cfe701d 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-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -442,8 +442,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL); Query query = whereGroupIdOrder(groupId); Stream messageWrappers = - this.template.stream(query, MessageWrapper.class, this.collectionName) - .stream(); + this.template.stream(query, MessageWrapper.class, this.collectionName); return messageWrappers.map(MessageWrapper::getMessage); } diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/AbstractMongoDbMessageStoreTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/AbstractMongoDbMessageStoreTests.java index b4e8cc85f6..97a15d54dc 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/AbstractMongoDbMessageStoreTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/AbstractMongoDbMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -27,7 +27,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.data.annotation.PersistenceConstructor; +import org.springframework.data.annotation.PersistenceCreator; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.history.MessageHistory; import org.springframework.integration.message.AdviceMessage; @@ -324,8 +324,7 @@ public abstract class AbstractMongoDbMessageStoreTests extends MongoDbAvailableT this("baz"); } - @PersistenceConstructor - Baz(String name) { + @PersistenceCreator Baz(String name) { this.name = name; } @@ -345,8 +344,7 @@ public abstract class AbstractMongoDbMessageStoreTests extends MongoDbAvailableT this("abx"); } - @PersistenceConstructor - Abc(String name) { + @PersistenceCreator Abc(String name) { this.name = name; } @@ -368,8 +366,7 @@ public abstract class AbstractMongoDbMessageStoreTests extends MongoDbAvailableT this("xyz"); } - @PersistenceConstructor - Xyz(String name) { + @PersistenceCreator Xyz(String name) { this.name = name; } diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapter.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapter.java index c825e7af09..6484d584da 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapter.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisInboundChannelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2007-2020 the original author or authors. + * Copyright 2007-2022 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. @@ -135,7 +135,9 @@ public class RedisInboundChannelAdapter extends MessageProducerSupport { } adapter.afterPropertiesSet(); this.container.addMessageListener(adapter, topicList); - this.container.afterPropertiesSet(); + if (!this.container.isActive()) { + this.container.afterPropertiesSet(); + } } @Override diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java index 98af8cae92..9714a28b91 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -61,7 +61,7 @@ public final class RedisAvailableRule implements MethodRule { .build(); connectionFactory = new LettuceConnectionFactory(redisStandaloneConfiguration, clientConfiguration); - connectionFactory.setEagerInitialization(true); + connectionFactory.afterPropertiesSet(); } @@ -82,7 +82,7 @@ public final class RedisAvailableRule implements MethodRule { if (redisAvailable != null) { if (connectionFactory != null) { try { - connectionFactory.afterPropertiesSet(); + connectionFactory.initConnection(); initialized = true; } catch (Exception e) { diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java index df9ba15181..b510b9cdf3 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -68,7 +68,7 @@ public abstract class RedisAvailableTests { int n = 0; while (n++ < 300 && (connection = - TestUtils.getPropertyValue(container, "subscriptionTask.connection", RedisConnection.class)) + TestUtils.getPropertyValue(container, "subscriber.connection", RedisConnection.class)) == null) { Thread.sleep(100); @@ -84,7 +84,7 @@ public abstract class RedisAvailableTests { protected void awaitContainerSubscribedWithPatterns(RedisMessageListenerContainer container) throws Exception { this.awaitContainerSubscribed(container); - RedisConnection connection = TestUtils.getPropertyValue(container, "subscriptionTask.connection", + RedisConnection connection = TestUtils.getPropertyValue(container, "subscriber.connection", RedisConnection.class); int n = 0; 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 9305fa4634..c4e0c47e17 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 @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -62,9 +62,7 @@ import org.springframework.messaging.PollableChannel; import org.springframework.security.access.AccessDecisionManager; import org.springframework.security.access.vote.AffirmativeBased; import org.springframework.security.access.vote.RoleVoter; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.security.core.userdetails.MapReactiveUserDetailsService; @@ -208,9 +206,9 @@ public class WebFluxDslTests { .setPropertyValue("webClient", webClient); this.mockMvc.perform( - get("/service2") - .with(httpBasic("guest", "guest")) - .param("name", "foo")) + get("/service2") + .with(httpBasic("guest", "guest")) + .param("name", "foo")) .andExpect( content() .string("FOO")); @@ -269,8 +267,8 @@ public class WebFluxDslTests { public void testDynamicHttpEndpoint() { IntegrationFlow flow = IntegrationFlows.from(WebFlux.inboundGateway("/dynamic") - .requestMapping(r -> r.params("name")) - .payloadExpression("#requestParams.name[0]")) + .requestMapping(r -> r.params("name")) + .payloadExpression("#requestParams.name[0]")) .transform(String::toLowerCase) .get(); @@ -299,13 +297,13 @@ public class WebFluxDslTests { public void testValidation() { IntegrationFlow flow = IntegrationFlows.from( - WebFlux.inboundGateway("/validation") - .requestMapping((mapping) -> mapping - .methods(HttpMethod.POST) - .consumes(MediaType.APPLICATION_JSON_VALUE)) - .requestPayloadType( - ResolvableType.forClassWithGenerics(Flux.class, TestModel.class)) - .validator(this.validator)) + WebFlux.inboundGateway("/validation") + .requestMapping((mapping) -> mapping + .methods(HttpMethod.POST) + .consumes(MediaType.APPLICATION_JSON_VALUE)) + .requestPayloadType( + ResolvableType.forClassWithGenerics(Flux.class, TestModel.class)) + .validator(this.validator)) .bridge() .get(); @@ -326,16 +324,16 @@ public class WebFluxDslTests { public void testErrorChannelFlow() { IntegrationFlow flow = IntegrationFlows.from( - WebFlux.inboundGateway("/errorFlow") - .errorChannel(new FixedSubscriberChannel( - new AbstractReplyProducingMessageHandler() { + WebFlux.inboundGateway("/errorFlow") + .errorChannel(new FixedSubscriberChannel( + new AbstractReplyProducingMessageHandler() { - @Override - protected Object handleRequestMessage(Message requestMessage) { - return "Error Response"; - } + @Override + protected Object handleRequestMessage(Message requestMessage) { + return "Error Response"; + } - }))) + }))) .channel(MessageChannels.flux()) .transform((payload) -> { throw new RuntimeException("Error!"); @@ -361,7 +359,7 @@ public class WebFluxDslTests { @EnableWebSecurity @EnableWebFluxSecurity @EnableIntegration - public static class ContextConfiguration extends WebSecurityConfigurerAdapter implements WebFluxConfigurer { + public static class ContextConfiguration implements WebFluxConfigurer { @Override public Validator getValidator() { @@ -377,7 +375,6 @@ public class WebFluxDslTests { .build(); } - @Override @Bean public UserDetailsService userDetailsService() { return new InMemoryUserDetailsManager(userDetails()); @@ -400,17 +397,6 @@ public class WebFluxDslTests { .build(); } - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .anyRequest().hasRole("ADMIN") - .and() - .httpBasic() - .and() - .csrf().disable() - .anonymous().disable(); - } - @Bean public IntegrationFlow webFluxFlowWithReplyPayloadToFlux() { return f -> f @@ -437,10 +423,10 @@ public class WebFluxDslTests { .from(Http.inboundGateway("/service2") .requestMapping(r -> r.params("name"))) .handle(WebFlux.>outboundGateway(m -> - UriComponentsBuilder.fromUriString("https://www.springsource.org/spring-integration") - .queryParams(m.getPayload()) - .build() - .toUri()) + UriComponentsBuilder.fromUriString("https://www.springsource.org/spring-integration") + .queryParams(m.getPayload()) + .build() + .toUri()) .httpMethod(HttpMethod.GET) .expectedResponseType(String.class)) .get();