11/*
2- * Copyright 2017-2019 the original author or authors.
2+ * Copyright 2017-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -59,43 +59,46 @@ public class RabbitTemplateMPPIntegrationTests {
5959 @ Autowired
6060 private Config config ;
6161
62- @ Test // 2.0.x only
62+ @ Test
6363 public void testMPPsAppliedDirectReplyToContainerTests () {
64+ this .config .afterMppCalled = 0 ;
6465 this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
6566 assertThat (this .config .beforeMppCalled ).as ("before MPP not called" ).isTrue ();
66- assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isTrue ( );
67+ assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isEqualTo ( 1 );
6768 }
6869
6970 @ Test
7071 public void testMPPsAppliedDirectReplyToTests () {
72+ this .config .afterMppCalled = 0 ;
7173 this .template .setUseDirectReplyToContainer (false );
7274 this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
7375 assertThat (this .config .beforeMppCalled ).as ("before MPP not called" ).isTrue ();
74- assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isTrue ( );
76+ assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isEqualTo ( 1 );
7577 }
7678
7779 @ Test
7880 public void testMPPsAppliedTemporaryReplyQueueTests () {
81+ this .config .afterMppCalled = 0 ;
7982 this .template .setUseDirectReplyToContainer (false );
8083 this .template .setUseTemporaryReplyQueues (true );
8184 this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
8285 assertThat (this .config .beforeMppCalled ).as ("before MPP not called" ).isTrue ();
83- assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isTrue ( );
86+ assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isEqualTo ( 1 );
8487 }
8588
8689 @ Test
8790 public void testMPPsAppliedReplyContainerTests () {
91+ this .config .afterMppCalled = 0 ;
8892 this .template .setReplyAddress (REPLIES );
8993 SimpleMessageListenerContainer container = new SimpleMessageListenerContainer (this .config .cf ());
9094 try {
9195 container .setQueueNames (REPLIES );
9296 container .setMessageListener (this .template );
93- container .setAfterReceivePostProcessors (this .config .afterMPP ());
9497 container .afterPropertiesSet ();
9598 container .start ();
9699 this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
97100 assertThat (this .config .beforeMppCalled ).as ("before MPP not called" ).isTrue ();
98- assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isTrue ( );
101+ assertThat (this .config .afterMppCalled ).as ("after MPP not called" ).isEqualTo ( 1 );
99102 }
100103 finally {
101104 container .stop ();
@@ -106,9 +109,9 @@ public void testMPPsAppliedReplyContainerTests() {
106109 @ EnableRabbit
107110 public static class Config {
108111
109- private boolean beforeMppCalled ;
112+ boolean beforeMppCalled ;
110113
111- private boolean afterMppCalled ;
114+ int afterMppCalled ;
112115
113116 @ Bean
114117 public CachingConnectionFactory cf () {
@@ -131,7 +134,7 @@ public RabbitTemplate template() {
131134 @ Bean
132135 public MessagePostProcessor afterMPP () {
133136 return m -> {
134- this .afterMppCalled = true ;
137+ this .afterMppCalled ++ ;
135138 return m ;
136139 };
137140 }
0 commit comments