Skip to content

Commit 1f6f70b

Browse files
committed
Fix some sporadic tests failures
https://build.spring.io/browse/INT-MASTER-1004/
1 parent 82cbafa commit 1f6f70b

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ public void testCompoundTriggerAdvice() throws Exception {
290290
Trigger override = spy(new PeriodicTrigger(5));
291291
final CompoundTriggerAdvice advice = new CompoundTriggerAdvice(compoundTrigger, override);
292292
adapter.setSource(() -> {
293-
overridePresent.add(TestUtils.getPropertyValue(compoundTrigger, "override"));
293+
synchronized (overridePresent) {
294+
overridePresent.add(TestUtils.getPropertyValue(compoundTrigger, "override"));
295+
}
294296
Message<Object> m = null;
295297
if (latch.getCount() % 2 == 0) {
296298
m = new GenericMessage<>("foo");
@@ -305,8 +307,10 @@ public void testCompoundTriggerAdvice() throws Exception {
305307
adapter.start();
306308
assertTrue(latch.await(10, TimeUnit.SECONDS));
307309
adapter.stop();
308-
while (overridePresent.size() > 5) {
309-
overridePresent.removeLast();
310+
synchronized (overridePresent) {
311+
while (overridePresent.size() > 5) {
312+
overridePresent.removeLast();
313+
}
310314
}
311315
assertThat(overridePresent, contains(null, override, null, override, null));
312316
verify(override, atLeast(2)).nextExecutionTime(any(TriggerContext.class));

spring-integration-core/src/test/java/org/springframework/integration/handler/AsyncHandlerTests.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2018 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.
@@ -58,6 +58,8 @@
5858

5959
/**
6060
* @author Gary Russell
61+
* @author Artem Bilan
62+
*
6163
* @since 4.3
6264
*
6365
*/
@@ -86,7 +88,7 @@ public void setup() {
8688

8789
@Override
8890
protected Object handleRequestMessage(Message<?> requestMessage) {
89-
final SettableListenableFuture<String> future = new SettableListenableFuture<String>();
91+
final SettableListenableFuture<String> future = new SettableListenableFuture<>();
9092
AsyncHandlerTests.this.executor.execute(() -> {
9193
try {
9294
latch.await(10, TimeUnit.SECONDS);
@@ -131,7 +133,7 @@ public void tearDown() {
131133
@Test
132134
public void testGoodResult() {
133135
this.whichTest = 0;
134-
this.handler.handleMessage(new GenericMessage<String>("foo"));
136+
this.handler.handleMessage(new GenericMessage<>("foo"));
135137
assertNull(this.output.receive(0));
136138
this.latch.countDown();
137139
Message<?> received = this.output.receive(10000);
@@ -158,15 +160,15 @@ public void testGoodResultWithReplyChannelHeader() {
158160
}
159161

160162
@Test
161-
public void testGoodResultWithNoReplyChannelHeaderNoOutput() throws Exception {
163+
public void testGoodResultWithNoReplyChannelHeaderNoOutput() {
162164
this.whichTest = 0;
163165
this.handler.setOutputChannel(null);
164166
QueueChannel errorChannel = new QueueChannel();
165167
Message<String> message = MessageBuilder.withPayload("foo").setErrorChannel(errorChannel).build();
166168
this.handler.handleMessage(message);
167169
assertNull(this.output.receive(0));
168170
this.latch.countDown();
169-
Message<?> errorMessage = errorChannel.receive(1000);
171+
Message<?> errorMessage = errorChannel.receive(10000);
170172
assertNotNull(errorMessage);
171173
assertThat(errorMessage.getPayload(), instanceOf(DestinationResolutionException.class));
172174
assertEquals("no output-channel or replyChannel header available",

spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests-context.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<bean id="testTrigger" class="org.springframework.integration.test.util.OnlyOnceTrigger"/>
2121

2222
<int:bridge input-channel="input" output-channel="next">
23-
<int:poller trigger="testTrigger" receive-timeout="10000" />
23+
<int:poller trigger="testTrigger" receive-timeout="100000" />
2424
</int:bridge>
2525

2626
<int:service-activator input-channel="next">
@@ -29,7 +29,7 @@
2929

3030
<int:inbound-channel-adapter channel="pubsub">
3131
<bean class="org.springframework.integration.monitor.MonitorTests$TestSource" />
32-
<int:poller fixed-delay="500" />
32+
<int:poller fixed-delay="50" />
3333
</int:inbound-channel-adapter>
3434

3535
<int:publish-subscribe-channel id="pubsub" />

spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testStats() throws InterruptedException {
9898
new DirectFieldAccessor(this.next).setPropertyValue("channelMetrics", channelMetrics);
9999

100100
MessagingTemplate messagingTemplate = new MessagingTemplate(this.input);
101-
messagingTemplate.setReceiveTimeout(10000);
101+
messagingTemplate.setReceiveTimeout(100000);
102102
Integer active = messagingTemplate.convertSendAndReceive("foo", Integer.class);
103103
assertEquals(1, active.intValue());
104104
assertTrue(afterSendLatch.await(10, TimeUnit.SECONDS));
@@ -111,7 +111,7 @@ public void testStats() throws InterruptedException {
111111
assertEquals(1, this.next.getSendCount());
112112
assertThat(this.next.getSendDuration().getMax(), greaterThan(99.0));
113113
assertThat(this.next.getSendDuration().getMax(), lessThan(10000.0));
114-
Message<?> fromInbound = this.output.receive(10000);
114+
Message<?> fromInbound = this.output.receive(100000);
115115
assertNotNull(fromInbound);
116116
assertEquals(0, fromInbound.getPayload());
117117
fromInbound = this.output.receive(10000);

0 commit comments

Comments
 (0)