6060import org .springframework .scheduling .annotation .EnableAsync ;
6161import org .springframework .stereotype .Component ;
6262import org .springframework .util .Assert ;
63+ import org .springframework .validation .annotation .Validated ;
64+ import org .springframework .validation .beanvalidation .MethodValidationPostProcessor ;
6365
6466import static org .hamcrest .Matchers .*;
6567import static org .junit .Assert .*;
@@ -488,10 +490,20 @@ public void listenerWithResolvableTypeEventWrongGeneric() {
488490
489491 @ Test
490492 public void conditionMatch () {
493+ validateConditionMatch (ConditionalEventListener .class );
494+ }
495+
496+ @ Test
497+ public void conditionMatchWithProxy () {
498+ validateConditionMatch (ConditionalEventListener .class , MethodValidationPostProcessor .class );
499+ }
500+
501+ private void validateConditionMatch (Class <?>... classes ) {
491502 long timestamp = System .currentTimeMillis ();
492- load (ConditionalEventListener . class );
503+ load (classes );
493504 TestEvent event = new TestEvent (this , "OK" );
494- TestEventListener listener = this .context .getBean (ConditionalEventListener .class );
505+
506+ ConditionalEventInterface listener = this .context .getBean (ConditionalEventInterface .class );
495507 this .eventCollector .assertNoEventReceived (listener );
496508
497509 this .context .publishEvent (event );
@@ -502,6 +514,9 @@ public void conditionMatch() {
502514 this .eventCollector .assertEvent (listener , event , "OK" );
503515 this .eventCollector .assertTotalEventsCount (2 );
504516
517+ this .context .publishEvent ("NOT OK" );
518+ this .eventCollector .assertTotalEventsCount (2 );
519+
505520 this .context .publishEvent (timestamp );
506521 this .eventCollector .assertEvent (listener , event , "OK" , timestamp );
507522 this .eventCollector .assertTotalEventsCount (3 );
@@ -885,8 +900,21 @@ public void handleString(GenericEventPojo<String> value) {
885900 }
886901
887902
903+ interface ConditionalEventInterface extends Identifiable {
904+
905+ void handle (TestEvent event );
906+
907+ void handleString (String payload );
908+
909+ void handleTimestamp (Long timestamp );
910+
911+ void handleRatio (Double ratio );
912+ }
913+
914+
888915 @ Component
889- static class ConditionalEventListener extends TestEventListener {
916+ @ Validated
917+ static class ConditionalEventListener extends TestEventListener implements ConditionalEventInterface {
890918
891919 @ EventListener (condition = "'OK'.equals(#root.event.msg)" )
892920 @ Override
0 commit comments