From 36007a40573f7871cc469e6305e0de53f5065ced Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 2 Jun 2015 00:17:32 -0700 Subject: [PATCH] Fix failing developer tools tests Tweak timings for some tests to fix failures that only occur on Linux machines. See gh-3082 --- .../boot/developertools/restart/RestarterTests.java | 10 +++++----- .../tunnel/client/TunnelClientTests.java | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/restart/RestarterTests.java b/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/restart/RestarterTests.java index 63bf0fa3e8..4fe5251f92 100644 --- a/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/restart/RestarterTests.java +++ b/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/restart/RestarterTests.java @@ -91,10 +91,10 @@ public class RestarterTests { }; thread.start(); - Thread.sleep(1600); + Thread.sleep(2600); String output = this.out.toString(); - assertThat(StringUtils.countOccurrencesOf(output, "Tick 0"), greaterThan(2)); - assertThat(StringUtils.countOccurrencesOf(output, "Tick 1"), greaterThan(2)); + assertThat(StringUtils.countOccurrencesOf(output, "Tick 0"), greaterThan(1)); + assertThat(StringUtils.countOccurrencesOf(output, "Tick 1"), greaterThan(1)); } @Test @@ -199,12 +199,12 @@ public class RestarterTests { private static volatile boolean quit = false; - @Scheduled(fixedDelay = 100) + @Scheduled(fixedDelay = 200) public void tickBean() { System.out.println("Tick " + this.count++ + " " + Thread.currentThread()); } - @Scheduled(initialDelay = 350, fixedDelay = 350) + @Scheduled(initialDelay = 500, fixedDelay = 500) public void restart() { System.out.println("Restart " + Thread.currentThread()); if (!SampleApplication.quit) { diff --git a/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/tunnel/client/TunnelClientTests.java b/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/tunnel/client/TunnelClientTests.java index 807d43b9a7..2f9acbc6b1 100644 --- a/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/tunnel/client/TunnelClientTests.java +++ b/spring-boot-developer-tools/src/test/java/org/springframework/boot/developertools/tunnel/client/TunnelClientTests.java @@ -84,6 +84,7 @@ public class TunnelClientTests { client.start(); SocketChannel channel = SocketChannel .open(new InetSocketAddress(this.listenPort)); + Thread.sleep(200); channel.close(); client.getServerThread().stopAcceptingConnections(); client.getServerThread().join(2000); @@ -97,6 +98,7 @@ public class TunnelClientTests { client.start(); SocketChannel channel = SocketChannel .open(new InetSocketAddress(this.listenPort)); + Thread.sleep(200); client.stop(); assertThat(this.tunnelConnection.getOpenedTimes(), equalTo(1)); assertThat(this.tunnelConnection.isOpen(), equalTo(false)); @@ -111,6 +113,7 @@ public class TunnelClientTests { client.start(); SocketChannel channel = SocketChannel .open(new InetSocketAddress(this.listenPort)); + Thread.sleep(200); channel.close(); client.getServerThread().stopAcceptingConnections(); client.getServerThread().join(2000);