This is an automated email from the ASF dual-hosted git repository.
zhouxj pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 80124de GEODE-5591: fix the GatewayReceiverImplJUnitTest to count the
retry times (#2435)
80124de is described below
commit 80124de596563f7ea9f6e4cab8bad6027525e75e
Author: Xiaojian Zhou <[email protected]>
AuthorDate: Fri Sep 7 11:24:36 2018 -0700
GEODE-5591: fix the GatewayReceiverImplJUnitTest to count the retry times
(#2435)
---
.../internal/cache/wan/GatewayReceiverImplJUnitTest.java | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git
a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplJUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplJUnitTest.java
index 9b7fe54..2d9b8ec 100644
---
a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplJUnitTest.java
+++
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplJUnitTest.java
@@ -126,6 +126,7 @@ public class GatewayReceiverImplJUnitTest {
new GatewayReceiverImpl(cache, 2000, 2001, 5, 100, null, null, null,
true);
assertThatThrownBy(() ->
gateway.start()).isInstanceOf(GatewayReceiverException.class)
.hasMessageContaining("No available free port found in the given
range");
+ verify(server, times(2)).start();
}
@Test
@@ -138,6 +139,7 @@ public class GatewayReceiverImplJUnitTest {
new GatewayReceiverImpl(cache, 2000, 2000, 5, 100, null, null, null,
true);
assertThatThrownBy(() ->
gateway.start()).isInstanceOf(GatewayReceiverException.class)
.hasMessageContaining("No available free port found in the given
range");
+ verify(server, times(1)).start();
}
@Test
@@ -151,6 +153,7 @@ public class GatewayReceiverImplJUnitTest {
assertThatThrownBy(() ->
gateway.start()).isInstanceOf(GatewayReceiverException.class)
.hasMessageContaining("No available free port found in the given
range");
assertTrue(gateway.getPort() == 0);
+ verify(server, times(101)).start(); // 2000-2100: contains 101 ports
}
@Test
@@ -162,17 +165,18 @@ public class GatewayReceiverImplJUnitTest {
when(cache.addCacheServer(eq(true))).thenReturn(server);
AtomicInteger callCount = new AtomicInteger();
doAnswer(invocation -> {
- // only throw IOException for 10 times
- if (callCount.get() < 10) {
+ // only throw IOException for 2 times
+ if (callCount.get() < 2) {
callCount.incrementAndGet();
throw new SocketException("Address already in use");
}
return 0;
}).when(server).start();
GatewayReceiverImpl gateway =
- new GatewayReceiverImpl(cache, 2000, 2100, 5, 100, null, null, null,
true);
+ new GatewayReceiverImpl(cache, 2000, 2010, 5, 100, null, null, null,
true);
gateway.start();
- assertTrue(gateway.getPort() > 2000);
- assertEquals(10, callCount.get());
+ assertTrue(gateway.getPort() >= 2000);
+ assertEquals(2, callCount.get());
+ verify(server, times(3)).start(); // 2 failed tries, 1 succeeded
}
}