List of usage examples for org.springframework.integration.zookeeper.metadata ZookeeperMetadataStore start
@Override public void start()
From source file:org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStoreTests.java
@Test public void testPutIfAbsent() throws Exception { final String testKey = "ZookeeperMetadataStoreTests-Persist"; final String testKey2 = "ZookeeperMetadataStoreTests-Persist-2"; metadataStore.put(testKey, "Integration"); assertNotNull(client.checkExists().forPath(metadataStore.getPath(testKey))); assertEquals("Integration", IntegrationUtils.bytesToString(client.getData().forPath(metadataStore.getPath(testKey)), "UTF-8")); CuratorFramework otherClient = createNewClient(); final ZookeeperMetadataStore otherMetadataStore = new ZookeeperMetadataStore(otherClient); otherMetadataStore.start(); otherMetadataStore.putIfAbsent(testKey, "OtherValue"); assertEquals("Integration", IntegrationUtils.bytesToString(client.getData().forPath(metadataStore.getPath(testKey)), "UTF-8")); assertEquals("Integration", metadataStore.get(testKey)); assertThat("Integration", eventually(equalsResult(new Evaluator<String>() { @Override/*w w w . j a v a 2s . c om*/ public String evaluate() { return otherMetadataStore.get(testKey); } }))); otherMetadataStore.putIfAbsent(testKey2, "Integration-2"); assertEquals("Integration-2", IntegrationUtils.bytesToString(client.getData().forPath(metadataStore.getPath(testKey2)), "UTF-8")); assertEquals("Integration-2", otherMetadataStore.get(testKey2)); assertThat("Integration-2", eventually(equalsResult(new Evaluator<String>() { @Override public String evaluate() { return metadataStore.get(testKey2); } }))); closeClient(otherClient); }
From source file:org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStoreTests.java
@Test public void testReplace() throws Exception { final String testKey = "ZookeeperMetadataStoreTests-Replace"; metadataStore.put(testKey, "Integration"); assertNotNull(client.checkExists().forPath(metadataStore.getPath(testKey))); assertEquals("Integration", IntegrationUtils.bytesToString(client.getData().forPath(metadataStore.getPath(testKey)), "UTF-8")); CuratorFramework otherClient = createNewClient(); final ZookeeperMetadataStore otherMetadataStore = new ZookeeperMetadataStore(otherClient); otherMetadataStore.start(); otherMetadataStore.replace(testKey, "OtherValue", "Integration-2"); assertEquals("Integration", IntegrationUtils.bytesToString(client.getData().forPath(metadataStore.getPath(testKey)), "UTF-8")); assertEquals("Integration", metadataStore.get(testKey)); assertThat("Integration", eventually(equalsResult(new Evaluator<String>() { @Override/* w w w . j a v a 2s. com*/ public String evaluate() { return otherMetadataStore.get(testKey); } }))); otherMetadataStore.replace(testKey, "Integration", "Integration-2"); assertEquals("Integration-2", IntegrationUtils.bytesToString(client.getData().forPath(metadataStore.getPath(testKey)), "UTF-8")); assertThat("Integration-2", eventually(equalsResult(new Evaluator<String>() { @Override public String evaluate() { return metadataStore.get(testKey); } }))); assertEquals("Integration-2", otherMetadataStore.get(testKey)); closeClient(otherClient); }