1
1
/*
2
- * Copyright 2017-2019 the original author or authors.
2
+ * Copyright 2017-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -59,43 +59,46 @@ public class RabbitTemplateMPPIntegrationTests {
59
59
@ Autowired
60
60
private Config config ;
61
61
62
- @ Test // 2.0.x only
62
+ @ Test
63
63
public void testMPPsAppliedDirectReplyToContainerTests () {
64
+ this .config .afterMppCalled = 0 ;
64
65
this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
65
66
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 );
67
68
}
68
69
69
70
@ Test
70
71
public void testMPPsAppliedDirectReplyToTests () {
72
+ this .config .afterMppCalled = 0 ;
71
73
this .template .setUseDirectReplyToContainer (false );
72
74
this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
73
75
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 );
75
77
}
76
78
77
79
@ Test
78
80
public void testMPPsAppliedTemporaryReplyQueueTests () {
81
+ this .config .afterMppCalled = 0 ;
79
82
this .template .setUseDirectReplyToContainer (false );
80
83
this .template .setUseTemporaryReplyQueues (true );
81
84
this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
82
85
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 );
84
87
}
85
88
86
89
@ Test
87
90
public void testMPPsAppliedReplyContainerTests () {
91
+ this .config .afterMppCalled = 0 ;
88
92
this .template .setReplyAddress (REPLIES );
89
93
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer (this .config .cf ());
90
94
try {
91
95
container .setQueueNames (REPLIES );
92
96
container .setMessageListener (this .template );
93
- container .setAfterReceivePostProcessors (this .config .afterMPP ());
94
97
container .afterPropertiesSet ();
95
98
container .start ();
96
99
this .template .sendAndReceive (new Message ("foo" .getBytes (), new MessageProperties ()));
97
100
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 );
99
102
}
100
103
finally {
101
104
container .stop ();
@@ -106,9 +109,9 @@ public void testMPPsAppliedReplyContainerTests() {
106
109
@ EnableRabbit
107
110
public static class Config {
108
111
109
- private boolean beforeMppCalled ;
112
+ boolean beforeMppCalled ;
110
113
111
- private boolean afterMppCalled ;
114
+ int afterMppCalled ;
112
115
113
116
@ Bean
114
117
public CachingConnectionFactory cf () {
@@ -131,7 +134,7 @@ public RabbitTemplate template() {
131
134
@ Bean
132
135
public MessagePostProcessor afterMPP () {
133
136
return m -> {
134
- this .afterMppCalled = true ;
137
+ this .afterMppCalled ++ ;
135
138
return m ;
136
139
};
137
140
}
0 commit comments