Fix QueueChannelSpec.priority hook

* Since we already have `PriorityChannelSpec` that isn't
`QueueChannelSpec` responsibility to worry about `priority` option.
More over it has been done wrongly and `MessageGroupQueue.setPriority()`
has been called unconditionally by the provided `ChannelMessageStore` type

* Fix `PriorityChannelSpec` logic as well:
- set `this.messageGroupQueue.setPriority(true);` to check the state of
the provided `PriorityCapableChannelMessageStore`
- fix assert condition in the `doGet()`

* And simple compiled SpEL test-case for the JDK Proxy
This commit is contained in:
Artem Bilan
2017-11-13 16:39:07 -05:00
parent a2d0ea5997
commit 8c89d0ef98
3 changed files with 46 additions and 7 deletions

View File

@@ -55,9 +55,12 @@ import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.expression.Expression;
import org.springframework.expression.spel.SpelCompilerMode;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.annotation.UseSpelInvoker;
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
@@ -882,6 +885,43 @@ public class MethodInvokingMessageProcessorTests {
assertThat(bean.foo.bar, equalTo("bar"));
}
@Test
public void testCompiledSpELForProxy() {
Foo foo = new FooImpl();
foo = (Foo) new ProxyFactory(foo).getProxy();
SpelExpressionParser expressionParser =
new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null));
Expression expression = expressionParser.parseExpression("#target.handle(#root)");
StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
evaluationContext.setVariable("target", foo);
expression.getValue(evaluationContext, "foo", String.class); // Twice to make a compiler to work
String result = expression.getValue(evaluationContext, "foo", String.class);
assertEquals("FOO", result);
}
public interface Foo {
String handle(String payload);
}
public class FooImpl implements Foo {
@Override
public String handle(String payload) {
return payload.toUpperCase();
}
}
private DirectFieldAccessor compileImmediate(MethodInvokingMessageProcessor processor) {
// Update the parser configuration compiler mode
SpelParserConfiguration config = TestUtils.getPropertyValue(processor,