Search in sources :

Example 1 with MockZkClient

use of org.apache.helix.mock.MockZkClient in project helix by apache.

the class TestHelixDataAccessor method beforeClass.

@BeforeClass
public void beforeClass() {
    _zkClient = new MockZkClient(ZK_ADDR);
    baseDataAccessor = new ZkBaseDataAccessor<>(_zkClient);
    accessor = new ZKHelixDataAccessor("HELIX", baseDataAccessor);
    Map<String, HelixProperty> paths = new TreeMap<>();
    propertyKeys = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        PropertyKey key = accessor.keyBuilder().idealStates("RESOURCE" + i);
        propertyKeys.add(key);
        paths.put(key.getPath(), new HelixProperty("RESOURCE" + i));
        accessor.setProperty(key, paths.get(key.getPath()));
    }
    List<HelixProperty> data = accessor.getProperty(new ArrayList<>(propertyKeys), true);
    Assert.assertEquals(data.size(), 5);
    PropertyKey key = accessor.keyBuilder().idealStates("RESOURCE6");
    propertyKeys.add(key);
    _zkClient.putData(key.getPath(), null);
}
Also used : MockZkClient(org.apache.helix.mock.MockZkClient) HelixProperty(org.apache.helix.HelixProperty) TreeMap(java.util.TreeMap) PropertyKey(org.apache.helix.PropertyKey) ZKHelixDataAccessor(org.apache.helix.manager.zk.ZKHelixDataAccessor) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TreeMap (java.util.TreeMap)1 HelixProperty (org.apache.helix.HelixProperty)1 PropertyKey (org.apache.helix.PropertyKey)1 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)1 MockZkClient (org.apache.helix.mock.MockZkClient)1 BeforeClass (org.testng.annotations.BeforeClass)1