diff --git a/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java b/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java index 67d36cc613..6dfc6e4bc2 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/state/TestConnectionStateManager.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import com.google.common.collect.Queues; import org.apache.curator.framework.CuratorFramework; @@ -91,7 +92,10 @@ public void stateChanged(CuratorFramework client, ConnectionState newState) } @Test - public void testConnectionStateRecoversFromUnexpectedExpiredConnection() throws Exception { + void testConnectionStateRecoversFromUnexpectedExpiredConnection() throws Exception { + final int major = getVersionPart("MAJOR"); + final int minor = getVersionPart("MINOR"); + assumeTrue(major == 3 && minor >= 6 || major > 4, "Zookeeper version must be 3.6 or higher"); Timing2 timing = new Timing2(); CuratorFramework client = CuratorFrameworkFactory.builder() .connectString(server.getConnectString()) @@ -128,4 +132,13 @@ public String getPath() { CloseableUtils.closeQuietly(client); } } + + private int getVersionPart(String part) { + try { + return Class.forName("org.apache.zookeeper.version.Info").getDeclaredField(part).getInt(null); + } catch (Exception e) { + e.printStackTrace(); + return -1; + } + } }