Skip to content

Commit

Permalink
CURATOR-633: Use reflection to get the actual version of Zookeeper
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
  • Loading branch information
martin-g committed Feb 25, 2022
1 parent 7b1737b commit 84ac20d
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.version.Info;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -93,8 +92,10 @@ public void stateChanged(CuratorFramework client, ConnectionState newState)
}

@Test
public void testConnectionStateRecoversFromUnexpectedExpiredConnection() throws Exception {
assumeTrue(() -> (getMajor() == 3 && getMinor() >= 6) || (getMajor() > 4), "Zookeeper version must be 3.6 or higher");
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())
Expand Down Expand Up @@ -132,13 +133,12 @@ public String getPath() {
}
}

public int getMajor() {
System.err.println("------- MAJOR: " + Info.MAJOR);
return Info.MAJOR;
}

public int getMinor() {
System.err.println("------- MINOR: " + Info.MINOR);
return Info.MINOR;
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;
}
}
}

0 comments on commit 84ac20d

Please sign in to comment.