Skip to content
/ zookeeper-rule Public archive

JUnit rule which provides an embedded ZooKeeper server.

Notifications You must be signed in to change notification settings

sahabpardaz/zookeeper-rule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zookeeper-rule

Tests Coverage Duplicated Lines (%) Vulnerabilities Security Rating Reliability Rating Maintainability Rating Technical Debt Quality Gate Status JitPack

This library provides Junit 4 Rule and Junit 5 Extension which is an embedded ZooKeeper server. The rule and extension has also helper methods to get curator clients which are initialized to work with that ZooKeeper.

Sample Usage

@Rule
public ZooKeeperRule zkRule = new ZooKeeperRule();

@Test
public void test() throws Exception {
    try (CuratorFramework client = zkRule.newClient()) {  // It is also possible to create a client on a specific namespace
       client.create().forPath("/path", "data".toBytes());
       Assert.assertArrayEquals("data".toBytes(), client.getData().forPath("/path"));
    }
}

JUnit 5 Support

Sample usage:

@RegisterExtension
static ZooKeeperExtension zooKeeperExtension = new ZooKeeperExtension();

@Test
public void test() throws Exception {
    try (CuratorFramework client = zooKeeperExtension.newClient()) {  // It is also possible to create a client on a specific namespace
        client.create().forPath("/path", "data".getBytes());
        assertArrayEquals("data".getBytes(), client.getData().forPath("/path"));
    }
}

Add it to your project

You can reference to this library by either of java build systems (Maven, Gradle, SBT or Leiningen) using snippets from this jitpack link:

JUnit 4 and 5 dependencies are marked as optional, so you need to provide JUnit 4 or 5 dependency (based on what version you need, and you use) in you project to make it work.

About

JUnit rule which provides an embedded ZooKeeper server.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages