Fix some sporadic tests failures
https://build.spring.io/browse/INT-MASTER-1004/
This commit is contained in:
@@ -290,7 +290,9 @@ public class PollerAdviceTests {
|
||||
Trigger override = spy(new PeriodicTrigger(5));
|
||||
final CompoundTriggerAdvice advice = new CompoundTriggerAdvice(compoundTrigger, override);
|
||||
adapter.setSource(() -> {
|
||||
overridePresent.add(TestUtils.getPropertyValue(compoundTrigger, "override"));
|
||||
synchronized (overridePresent) {
|
||||
overridePresent.add(TestUtils.getPropertyValue(compoundTrigger, "override"));
|
||||
}
|
||||
Message<Object> m = null;
|
||||
if (latch.getCount() % 2 == 0) {
|
||||
m = new GenericMessage<>("foo");
|
||||
@@ -305,8 +307,10 @@ public class PollerAdviceTests {
|
||||
adapter.start();
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
adapter.stop();
|
||||
while (overridePresent.size() > 5) {
|
||||
overridePresent.removeLast();
|
||||
synchronized (overridePresent) {
|
||||
while (overridePresent.size() > 5) {
|
||||
overridePresent.removeLast();
|
||||
}
|
||||
}
|
||||
assertThat(overridePresent, contains(null, override, null, override, null));
|
||||
verify(override, atLeast(2)).nextExecutionTime(any(TriggerContext.class));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,6 +58,8 @@ import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@@ -86,7 +88,7 @@ public class AsyncHandlerTests {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
final SettableListenableFuture<String> future = new SettableListenableFuture<String>();
|
||||
final SettableListenableFuture<String> future = new SettableListenableFuture<>();
|
||||
AsyncHandlerTests.this.executor.execute(() -> {
|
||||
try {
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
@@ -131,7 +133,7 @@ public class AsyncHandlerTests {
|
||||
@Test
|
||||
public void testGoodResult() {
|
||||
this.whichTest = 0;
|
||||
this.handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
this.handler.handleMessage(new GenericMessage<>("foo"));
|
||||
assertNull(this.output.receive(0));
|
||||
this.latch.countDown();
|
||||
Message<?> received = this.output.receive(10000);
|
||||
@@ -158,7 +160,7 @@ public class AsyncHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGoodResultWithNoReplyChannelHeaderNoOutput() throws Exception {
|
||||
public void testGoodResultWithNoReplyChannelHeaderNoOutput() {
|
||||
this.whichTest = 0;
|
||||
this.handler.setOutputChannel(null);
|
||||
QueueChannel errorChannel = new QueueChannel();
|
||||
@@ -166,7 +168,7 @@ public class AsyncHandlerTests {
|
||||
this.handler.handleMessage(message);
|
||||
assertNull(this.output.receive(0));
|
||||
this.latch.countDown();
|
||||
Message<?> errorMessage = errorChannel.receive(1000);
|
||||
Message<?> errorMessage = errorChannel.receive(10000);
|
||||
assertNotNull(errorMessage);
|
||||
assertThat(errorMessage.getPayload(), instanceOf(DestinationResolutionException.class));
|
||||
assertEquals("no output-channel or replyChannel header available",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<bean id="testTrigger" class="org.springframework.integration.test.util.OnlyOnceTrigger"/>
|
||||
|
||||
<int:bridge input-channel="input" output-channel="next">
|
||||
<int:poller trigger="testTrigger" receive-timeout="10000" />
|
||||
<int:poller trigger="testTrigger" receive-timeout="100000" />
|
||||
</int:bridge>
|
||||
|
||||
<int:service-activator input-channel="next">
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<int:inbound-channel-adapter channel="pubsub">
|
||||
<bean class="org.springframework.integration.monitor.MonitorTests$TestSource" />
|
||||
<int:poller fixed-delay="500" />
|
||||
<int:poller fixed-delay="50" />
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:publish-subscribe-channel id="pubsub" />
|
||||
|
||||
@@ -98,7 +98,7 @@ public class MonitorTests {
|
||||
new DirectFieldAccessor(this.next).setPropertyValue("channelMetrics", channelMetrics);
|
||||
|
||||
MessagingTemplate messagingTemplate = new MessagingTemplate(this.input);
|
||||
messagingTemplate.setReceiveTimeout(10000);
|
||||
messagingTemplate.setReceiveTimeout(100000);
|
||||
Integer active = messagingTemplate.convertSendAndReceive("foo", Integer.class);
|
||||
assertEquals(1, active.intValue());
|
||||
assertTrue(afterSendLatch.await(10, TimeUnit.SECONDS));
|
||||
@@ -111,7 +111,7 @@ public class MonitorTests {
|
||||
assertEquals(1, this.next.getSendCount());
|
||||
assertThat(this.next.getSendDuration().getMax(), greaterThan(99.0));
|
||||
assertThat(this.next.getSendDuration().getMax(), lessThan(10000.0));
|
||||
Message<?> fromInbound = this.output.receive(10000);
|
||||
Message<?> fromInbound = this.output.receive(100000);
|
||||
assertNotNull(fromInbound);
|
||||
assertEquals(0, fromInbound.getPayload());
|
||||
fromInbound = this.output.receive(10000);
|
||||
|
||||
Reference in New Issue
Block a user