Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ static BeanDefinitionBuilder buildWebFluxRequestExecutingMessageHandler(Element

String webClientRef = element.getAttribute("web-client");
if (StringUtils.hasText(webClientRef)) {
if (element.hasAttribute("encoding-mode")) {
parserContext.getReaderContext()
.error("The 'web-client' and 'encoding-mode' attributes are mutually exclusive.", element);
}

builder.getBeanDefinition()
.getConstructorArgumentValues()
.addIndexedArgumentValue(1, new RuntimeBeanReference(webClientRef));
Expand All @@ -67,8 +72,8 @@ static BeanDefinitionBuilder buildWebFluxRequestExecutingMessageHandler(Element

if (hasType && hasTypeExpression) {
parserContext.getReaderContext()
.error("The 'publisher-element-type' and 'publisher-element-type-expression' " +
"are mutually exclusive. You can only have one or the other", element);
.error("The 'publisher-element-type' and 'publisher-element-type-expression' attributes " +
"are mutually exclusive.", element);
}

if (hasType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-webflux="http://www.springframework.org/schema/integration/webflux"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/webflux https://www.springframework.org/schema/integration/webflux/spring-integration-webflux.xsd">

<bean id="webClient" class="org.springframework.web.reactive.function.client.WebClient"
factory-method="create"/>

<int-webflux:outbound-gateway url="/fake"
web-client="webClient"
encoding-mode="VALUES_ONLY"/>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<outbound-gateway id="reactiveFullConfig"
url="http://localhost/test2"
http-method="PUT"
encoding-mode="NONE"
request-channel="requests"
reply-timeout="1234"
extract-request-payload="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.expression.Expression;
import org.springframework.http.HttpMethod;
import org.springframework.integration.endpoint.AbstractEndpoint;
Expand All @@ -35,8 +37,10 @@
import org.springframework.util.ObjectUtils;
import org.springframework.web.reactive.function.BodyExtractor;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.DefaultUriBuilderFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
* @author Artem Bilan
Expand Down Expand Up @@ -132,6 +136,17 @@ public void reactiveFullConfig() {
.isEqualTo(false);
assertThat(handlerAccessor.getPropertyValue("attributeVariablesExpression.expression"))
.isEqualTo("{name:{first:'Nikola',last:'Tesla'},dob:{day:10,month:'July',year:1856}}");
assertThat(handlerAccessor.getPropertyValue("webClient.uriBuilderFactory.encodingMode"))
.isEqualTo(DefaultUriBuilderFactory.EncodingMode.NONE);
}

@Test
void webClientAndEncodingModeExclusiveness() {
assertThatExceptionOfType(BeanDefinitionParsingException.class)
.isThrownBy(() ->
new ClassPathXmlApplicationContext("WebFluxOutboundGatewayParser-encoding-mode-fail.xml",
getClass()))
.withMessageContaining("The 'web-client' and 'encoding-mode' attributes are mutually exclusive");
}

}