RSocket XML Config support

This commit is contained in:
Artem Bilan
2019-05-16 13:51:24 -04:00
committed by Gary Russell
parent 87169bc77a
commit bc9aa83aea
9 changed files with 537 additions and 12 deletions

View File

@@ -0,0 +1,28 @@
<?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-rsocket="http://www.springframework.org/schema/integration/rsocket"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/rsocket https://www.springframework.org/schema/integration/rsocket/spring-integration-rsocket.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd">
<bean id="clientRSocketConnector" class="org.springframework.integration.rsocket.ClientRSocketConnector">
<constructor-arg value="https://example.org"/>
</bean>
<bean id="rsocketStrategies" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.messaging.rsocket.RSocketStrategies"/>
</bean>
<int:channel id="requestChannel"/>
<int-rsocket:inbound-gateway id="inboundGateway"
path="testPath"
rsocket-connector="clientRSocketConnector"
auto-startup="false"
request-channel="requestChannel"
rsocket-strategies="rsocketStrategies"
request-element-type="byte[]"/>
</beans>

View File

@@ -0,0 +1,57 @@
/*
* Copyright 2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.rsocket.config;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.rsocket.ClientRSocketConnector;
import org.springframework.integration.rsocket.inbound.RSocketInboundGateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @author Artem Bilan
*
* @since 5.2
*/
@SpringJUnitConfig
@DirtiesContext
public class RSocketInboundGatewayParserTests {
@Autowired
private ClientRSocketConnector clientRSocketConnector;
@Autowired
private RSocketInboundGateway inboundGateway;
@Test
void testOutboundGatewayParser() {
assertThat(TestUtils.getPropertyValue(this.inboundGateway, "rsocketConnector"))
.isSameAs(this.clientRSocketConnector);
assertThat(TestUtils.getPropertyValue(this.inboundGateway, "rsocketStrategies"))
.isSameAs(this.clientRSocketConnector.getRSocketStrategies());
assertThat(TestUtils.getPropertyValue(this.inboundGateway, "path"))
.isEqualTo(new String[] { "testPath" });
assertThat(TestUtils.getPropertyValue(this.inboundGateway, "requestElementType.resolved"))
.isEqualTo(byte[].class);
}
}

View File

@@ -0,0 +1,25 @@
<?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-rsocket="http://www.springframework.org/schema/integration/rsocket"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/rsocket https://www.springframework.org/schema/integration/rsocket/spring-integration-rsocket.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd">
<bean id="clientRSocketConnector" class="org.springframework.integration.rsocket.ClientRSocketConnector">
<constructor-arg value="https://example.org"/>
</bean>
<int:channel id="requestChannel"/>
<int-rsocket:outbound-gateway id="outboundGateway"
client-rsocket-connector="clientRSocketConnector"
auto-startup="false"
command="fireAndForget"
route-expression="'testRoute'"
request-channel="requestChannel"
publisher-element-type="byte[]"
expected-response-type="java.util.Date"/>
</beans>

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.rsocket.config;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.rsocket.ClientRSocketConnector;
import org.springframework.integration.rsocket.outbound.RSocketOutboundGateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @author Artem Bilan
*
* @since 5.2
*/
@SpringJUnitConfig
@DirtiesContext
public class RSocketOutboundGatewayParserTests {
@Autowired
private ClientRSocketConnector clientRSocketConnector;
@Autowired
private RSocketOutboundGateway outboundGateway;
@Test
void testOutboundGatewayParser() {
assertThat(TestUtils.getPropertyValue(this.outboundGateway, "clientRSocketConnector"))
.isSameAs(this.clientRSocketConnector);
assertThat(TestUtils.getPropertyValue(this.outboundGateway, "commandExpression.literalValue"))
.isEqualTo("fireAndForget");
assertThat(TestUtils.getPropertyValue(this.outboundGateway, "routeExpression.expression"))
.isEqualTo("'testRoute'");
assertThat(TestUtils.getPropertyValue(this.outboundGateway, "publisherElementTypeExpression.literalValue"))
.isEqualTo("byte[]");
assertThat(TestUtils.getPropertyValue(this.outboundGateway, "expectedResponseTypeExpression.literalValue"))
.isEqualTo("java.util.Date");
}
}