Compatibility with the latest Spring AMQP-1.6.6

This must be back-ported to `4.3.x` after upgrade to the particular `1.6.x` or `1.7.x`
This commit is contained in:
Artem Bilan
2016-12-20 18:03:17 -05:00
committed by Gary Russell
parent c5ef70eb92
commit fedb65c6fb

View File

@@ -29,6 +29,7 @@ import static org.mockito.Mockito.mock;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
@@ -137,8 +138,8 @@ public class ChannelTests extends LogAdjustingTestSupport {
this.channel.send(new GenericMessage<String>("foo"));
latch.await(10, TimeUnit.SECONDS);
latch.reset();
BlockingQueueConsumer consumer = (BlockingQueueConsumer) TestUtils
.getPropertyValue(this.channel, "container.consumers", Map.class).keySet().iterator().next();
BlockingQueueConsumer consumer = (BlockingQueueConsumer) TestUtils.getPropertyValue(this.channel,
"container.consumers", Set.class).iterator().next();
factory.destroy();
waitForNewConsumer(this.channel, consumer);
this.channel.send(new GenericMessage<String>("bar"));
@@ -150,15 +151,15 @@ public class ChannelTests extends LogAdjustingTestSupport {
private void waitForNewConsumer(PublishSubscribeAmqpChannel channel, BlockingQueueConsumer consumer)
throws Exception {
BlockingQueueConsumer newConsumer = (BlockingQueueConsumer) TestUtils
.getPropertyValue(channel, "container.consumers", Map.class).keySet().iterator().next();
BlockingQueueConsumer newConsumer = (BlockingQueueConsumer) TestUtils.getPropertyValue(channel,
"container.consumers", Set.class).iterator().next();
int n = 0;
boolean newConsumerIsConsuming = newConsumer != consumer && TestUtils.getPropertyValue(newConsumer,
"consumerTags", Map.class).size() > 0;
while (n++ < 100 && !newConsumerIsConsuming) {
Thread.sleep(100);
newConsumer = (BlockingQueueConsumer) TestUtils
.getPropertyValue(channel, "container.consumers", Map.class).keySet().iterator().next();
newConsumer = (BlockingQueueConsumer) TestUtils.getPropertyValue(channel,
"container.consumers", Set.class).iterator().next();
newConsumerIsConsuming = newConsumer != consumer && TestUtils.getPropertyValue(newConsumer,
"consumerTags", Map.class).size() > 0;
}