diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java index c9a26367d1..8d43cfe7e3 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java @@ -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 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)); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/AsyncHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/AsyncHandlerTests.java index ef2581d3a3..831ee1d1cf 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/AsyncHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/AsyncHandlerTests.java @@ -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 future = new SettableListenableFuture(); + final SettableListenableFuture 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("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", diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests-context.xml b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests-context.xml index 8e2c206398..89acfd8b3a 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests-context.xml +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests-context.xml @@ -20,7 +20,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java index 566add749d..12fa5fc9c3 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java @@ -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);