com.opower.zookeeper.test.rule.MiniZooKeeperClusterRule Maven / Gradle / Ivy
The newest version!
package com.opower.zookeeper.test.rule;
import com.google.common.base.Preconditions;
import com.opower.zookeeper.test.MiniZooKeeperCluster;
import org.junit.rules.ExternalResource;
/**
* Wraps {@link com.opower.zookeeper.test.MiniZooKeeperCluster} in a JUnit rule.
*
* @author eric.chang
*/
public class MiniZooKeeperClusterRule extends ExternalResource {
private final MiniZooKeeperCluster miniZooKeeperCluster;
/**
* Initialize this rule with a {@link com.opower.zookeeper.test.MiniZooKeeperCluster}. Use
* {@link com.opower.zookeeper.test.MiniZooKeeperCluster.Builder} to construct the cluster.
*
* @param miniZooKeeperCluster the mini ZooKeeper cluster to startup/shutdown with this rule
*/
public MiniZooKeeperClusterRule(MiniZooKeeperCluster miniZooKeeperCluster) {
this.miniZooKeeperCluster = Preconditions.checkNotNull(miniZooKeeperCluster);
}
public String getZKConnectionString() {
return this.miniZooKeeperCluster.getZkConnectionString();
}
@Override
public void before() throws Throwable {
this.miniZooKeeperCluster.start();
}
@Override
public void after() {
this.miniZooKeeperCluster.shutdown();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy