use of org.springframework.expression.spel.standard.SpelExpression in project spring-integration by spring-projects.
the class HttpOutboundGatewayParserTests method withUrlExpression.
@Test
public void withUrlExpression() {
HttpRequestExecutingMessageHandler handler = (HttpRequestExecutingMessageHandler) new DirectFieldAccessor(this.withUrlExpressionEndpoint).getPropertyValue("handler");
MessageChannel requestChannel = (MessageChannel) new DirectFieldAccessor(this.withUrlExpressionEndpoint).getPropertyValue("inputChannel");
assertEquals(this.applicationContext.getBean("requests"), requestChannel);
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
Object replyChannel = handlerAccessor.getPropertyValue("outputChannel");
assertNull(replyChannel);
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(handlerAccessor.getPropertyValue("restTemplate"));
ClientHttpRequestFactory requestFactory = (ClientHttpRequestFactory) templateAccessor.getPropertyValue("requestFactory");
assertTrue(requestFactory instanceof SimpleClientHttpRequestFactory);
SpelExpression expression = (SpelExpression) handlerAccessor.getPropertyValue("uriExpression");
assertNotNull(expression);
assertEquals("'http://localhost/test1'", expression.getExpressionString());
assertEquals(HttpMethod.POST.name(), TestUtils.getPropertyValue(handler, "httpMethodExpression", Expression.class).getExpressionString());
assertEquals(Charset.forName("UTF-8"), handlerAccessor.getPropertyValue("charset"));
assertEquals(true, handlerAccessor.getPropertyValue("extractPayload"));
assertEquals(false, handlerAccessor.getPropertyValue("transferCookies"));
// INT-3055
Object uriVariablesExpression = handlerAccessor.getPropertyValue("uriVariablesExpression");
assertNotNull(uriVariablesExpression);
assertEquals("@uriVariables", ((Expression) uriVariablesExpression).getExpressionString());
Object uriVariableExpressions = handlerAccessor.getPropertyValue("uriVariableExpressions");
assertNotNull(uriVariableExpressions);
assertTrue(((Map<?, ?>) uriVariableExpressions).isEmpty());
}
use of org.springframework.expression.spel.standard.SpelExpression in project spring-integration by spring-projects.
the class MongoDbInboundChannelAdapterParserTests method fullConfigWithQueryExpression.
@Test
public void fullConfigWithQueryExpression() {
MongoDbMessageSource source = assertMongoDbMessageSource(this.fullConfigWithQueryExpressionAdapter);
assertTrue(TestUtils.getPropertyValue(source, "queryExpression") instanceof SpelExpression);
assertEquals("new BasicQuery('{''address.state'' : ''PA''}').limit(2)", TestUtils.getPropertyValue(source, "queryExpression.expression"));
}
use of org.springframework.expression.spel.standard.SpelExpression in project spring-integration by spring-projects.
the class MongoDbInboundChannelAdapterParserTests method fullConfigWithCollectionExpression.
@Test
public void fullConfigWithCollectionExpression() {
MongoDbMessageSource source = assertMongoDbMessageSource(this.fullConfigWithCollectionExpressionAdapter);
assertTrue(TestUtils.getPropertyValue(source, "collectionNameExpression") instanceof SpelExpression);
assertEquals("'foo'", TestUtils.getPropertyValue(source, "collectionNameExpression.expression"));
}
use of org.springframework.expression.spel.standard.SpelExpression in project spring-integration by spring-projects.
the class WebFluxInboundChannelAdapterParserTests method reactiveFullConfig.
@Test
@SuppressWarnings("unchecked")
public void reactiveFullConfig() {
DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(this.reactiveFullConfig);
assertSame(this.requests, endpointAccessor.getPropertyValue("requestChannel"));
assertNotNull(endpointAccessor.getPropertyValue("errorChannel"));
assertFalse((boolean) endpointAccessor.getPropertyValue("autoStartup"));
assertEquals(101, endpointAccessor.getPropertyValue("phase"));
assertFalse((boolean) endpointAccessor.getPropertyValue("expectReply"));
assertEquals("'202'", ((SpelExpression) endpointAccessor.getPropertyValue("statusCodeExpression")).getExpressionString());
assertEquals("payload", ((SpelExpression) endpointAccessor.getPropertyValue("payloadExpression")).getExpressionString());
Map<String, Expression> headerExpressions = (Map<String, Expression>) endpointAccessor.getPropertyValue("headerExpressions");
assertTrue(headerExpressions.containsKey("foo"));
assertEquals("foo", headerExpressions.get("foo").getValue());
CrossOrigin crossOrigin = (CrossOrigin) endpointAccessor.getPropertyValue("crossOrigin");
assertNotNull(crossOrigin);
assertArrayEquals(new String[] { "foo" }, crossOrigin.getOrigin());
assertEquals(ResolvableType.forClass(byte[].class), endpointAccessor.getPropertyValue("requestPayloadType"));
assertSame(this.headerMapper, endpointAccessor.getPropertyValue("headerMapper"));
assertSame(this.serverCodecConfigurer, endpointAccessor.getPropertyValue("codecConfigurer"));
assertSame(this.requestedContentTypeResolver, endpointAccessor.getPropertyValue("requestedContentTypeResolver"));
assertSame(this.reactiveAdapterRegistry, endpointAccessor.getPropertyValue("adapterRegistry"));
}
use of org.springframework.expression.spel.standard.SpelExpression in project spring-data-keyvalue by spring-projects.
the class SpelQueryCreatorUnitTests method createQueryForMethodWithArgs.
private KeyValueQuery<SpelExpression> createQueryForMethodWithArgs(String methodName, Object... args) throws NoSuchMethodException, SecurityException {
Class<?>[] argTypes = new Class<?>[args.length];
if (!ObjectUtils.isEmpty(args)) {
for (int i = 0; i < args.length; i++) {
argTypes[i] = args[i].getClass();
}
}
Method method = PersonRepository.class.getMethod(methodName, argTypes);
doReturn(Person.class).when(metadataMock).getReturnedDomainClass(method);
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(new QueryMethod(method, metadataMock, new SpelAwareProxyProjectionFactory()).getParameters(), args));
KeyValueQuery<SpelExpression> q = creator.createQuery();
q.getCriteria().setEvaluationContext(new StandardEvaluationContext(args));
return q;
}
Aggregations