Merge pull request #591 from artembilan/INT-2717
This commit is contained in:
@@ -67,6 +67,22 @@
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
View name to be resolved when rendering a response.
|
||||
This attribute is not allowed if there is a 'view-expression' attribute.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="view-expression" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
SpEL expression that resolves to a view to be resolved when rendering a response.
|
||||
The expression can resolve to a view name or View object.
|
||||
However, because there is no reply message, the
|
||||
'evaluationContext' for this expression is rather lightweight; it has a
|
||||
'BeanResolver' but no variables,
|
||||
so the usage of this attribute is somewhat limited.
|
||||
An example might be to resolve, at runtime, some scoped Bean that returns a
|
||||
view name or View object.
|
||||
This attribute is not allowed if there is a 'view-name' attribute.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -199,6 +215,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
View name to be resolved when rendering a response.
|
||||
This attribute is not allowed if there is a 'view-expression' attribute.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -208,6 +225,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
|
||||
SpEL expression that resolves to a view to be resolved when rendering a response.
|
||||
The expression can resolve to a view name or View object.
|
||||
The root object of the evaluation context is the reply message.
|
||||
This attribute is not allowed if there is a 'view-name' attribute.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
@@ -23,27 +23,29 @@
|
||||
<inbound-channel-adapter id="putOrDeleteAdapter" channel="requests" supported-methods="PUT, delete"/>
|
||||
|
||||
<inbound-channel-adapter id="inboundController" channel="requests" view-name="foo" error-code="oops"/>
|
||||
|
||||
|
||||
<inbound-channel-adapter id="inboundControllerViewExp" channel="requests" view-expression="'foo'"/>
|
||||
|
||||
<inbound-channel-adapter id="withMappedHeaders" channel="requests"
|
||||
mapped-request-headers="foo,bar"/>
|
||||
|
||||
<inbound-channel-adapter id="inboundAdapterWithExpressions"
|
||||
|
||||
<inbound-channel-adapter id="inboundAdapterWithExpressions"
|
||||
path="/fname/{f}/lname/{l}"
|
||||
channel="requests"
|
||||
mapped-request-headers="foo,bar"
|
||||
payload-expression="#pathVariables.f">
|
||||
<header name="lname" expression="#pathVariables.l"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<inbound-channel-adapter name="/fname/{blah}/lname/{boo}"
|
||||
|
||||
<inbound-channel-adapter name="/fname/{blah}/lname/{boo}"
|
||||
path="/fname/{f}/lname/{l}"
|
||||
channel="requests"
|
||||
mapped-request-headers="foo,bar"
|
||||
payload-expression="#pathVariables.f">
|
||||
<header name="lname" expression="#pathVariables.l"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<inbound-channel-adapter name="/fname/{f}/lname/{l}"
|
||||
|
||||
<inbound-channel-adapter name="/fname/{f}/lname/{l}"
|
||||
channel="requests"
|
||||
mapped-request-headers="foo,bar"
|
||||
payload-expression="#pathVariables.f">
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -58,6 +59,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -92,6 +94,9 @@ public class HttpInboundChannelAdapterParserTests {
|
||||
@Autowired
|
||||
private HttpRequestHandlingController inboundController;
|
||||
|
||||
@Autowired
|
||||
private HttpRequestHandlingController inboundControllerViewExp;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel autoChannel;
|
||||
|
||||
@@ -268,9 +273,16 @@ public class HttpInboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void testController() throws Exception {
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(inboundController);
|
||||
String errorCode = (String) accessor.getPropertyValue("errorCode");
|
||||
String errorCode = TestUtils.getPropertyValue(inboundController, "errorCode", String.class);
|
||||
assertEquals("oops", errorCode);
|
||||
Expression viewExpression = TestUtils.getPropertyValue(inboundController, "viewExpression", Expression.class);
|
||||
assertEquals("foo", viewExpression.getExpressionString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInt2717ControllerWithViewExpression() throws Exception {
|
||||
Expression viewExpression = TestUtils.getPropertyValue(inboundControllerViewExp, "viewExpression", Expression.class);
|
||||
assertEquals("'foo'", viewExpression.getExpressionString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user