Support for bean refs in event SpEL condition
Issue: SPR-13814
This commit is contained in:
@@ -462,6 +462,10 @@ public class AnnotationDrivenEventListenerTests {
|
||||
this.context.publishEvent(timestamp);
|
||||
this.eventCollector.assertEvent(listener, event, "OK", timestamp);
|
||||
this.eventCollector.assertTotalEventsCount(3);
|
||||
|
||||
this.context.publishEvent(42d);
|
||||
this.eventCollector.assertEvent(listener, event, "OK", timestamp, 42d);
|
||||
this.eventCollector.assertTotalEventsCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -483,6 +487,10 @@ public class AnnotationDrivenEventListenerTests {
|
||||
this.context.publishEvent(maxLong);
|
||||
this.eventCollector.assertNoEventReceived(listener);
|
||||
this.eventCollector.assertTotalEventsCount(0);
|
||||
|
||||
this.context.publishEvent(24d);
|
||||
this.eventCollector.assertNoEventReceived(listener);
|
||||
this.eventCollector.assertTotalEventsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -534,6 +542,18 @@ public class AnnotationDrivenEventListenerTests {
|
||||
public CountDownLatch testCountDownLatch() {
|
||||
return new CountDownLatch(1);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestConditionEvaluator conditionEvaluator() {
|
||||
return new TestConditionEvaluator();
|
||||
}
|
||||
|
||||
static class TestConditionEvaluator {
|
||||
|
||||
public boolean valid(Double ratio) {
|
||||
return new Double(42).equals(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -810,6 +830,11 @@ public class AnnotationDrivenEventListenerTests {
|
||||
public void handleTimestamp(Long timestamp) {
|
||||
collectEvent(timestamp);
|
||||
}
|
||||
|
||||
@EventListener(condition = "@conditionEvaluator.valid(#p0)")
|
||||
public void handleRatio(Double ratio) {
|
||||
collectEvent(ratio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user