You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/02/27 22:02:23 UTC
[04/10] incubator-tamaya git commit: TAMAYA-143: Finished/tested
consul support.
TAMAYA-143: Finished/tested consul support.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/ffc59e03
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/ffc59e03
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/ffc59e03
Branch: refs/heads/master
Commit: ffc59e03bc5a0390144297f74250af386b89535a
Parents: 60e8827
Author: anatole <an...@apache.org>
Authored: Sat Feb 27 21:56:02 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Feb 27 21:56:02 2016 +0100
----------------------------------------------------------------------
modules/integration/consul/pom.xml | 2 +-
.../apache/tamaya/consul/ConsulBackends.java | 30 +++-----
.../tamaya/consul/ConsulPropertySource.java | 73 +++++++++++-------
.../ConsulMutableConfigurationBackend.java | 56 ++++++--------
.../consul/internal/MutableConfigSupport.java | 4 +-
...g.spi.MutableConfigurationBackendProviderSpi | 2 +-
.../org.apache.tamaya.spi.PropertySource | 2 +-
.../tamaya/etcd/ConsulPropertySourceTest.java | 6 +-
.../org/apache/tamaya/etcd/ConsulWriteTest.java | 80 +++++---------------
modules/integration/pom.xml | 1 +
10 files changed, 111 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/consul/pom.xml b/modules/integration/consul/pom.xml
index 2795597..add1089 100644
--- a/modules/integration/consul/pom.xml
+++ b/modules/integration/consul/pom.xml
@@ -26,7 +26,7 @@ under the License.
<version>0.2-incubating-SNAPSHOT</version>
</parent>
- <artifactId>tamaya-etcd</artifactId>
+ <artifactId>tamaya-consul</artifactId>
<name>Apache Tamaya Integration - consul</name>
<packaging>bundle</packaging>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
index cab9656..4eab141 100644
--- a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
+++ b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
@@ -18,48 +18,42 @@
*/
package org.apache.tamaya.consul;
+import com.google.common.net.HostAndPort;
+
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Singleton that reads and stores the current etcd setup, especially the possible URLs to be used.
+ * Singleton that reads and stores the current consul setup, especially the possible host:ports to be used.
*/
public final class ConsulBackends {
private static final Logger LOG = Logger.getLogger(ConsulBackends.class.getName());
- private static List<EtcdAccessor> etcdBackends = new ArrayList<>();
+ private static List<HostAndPort> consulBackends = new ArrayList<>();
static{
- int timeout = 2;
- String val = System.getProperty("tamaya.etcd.timeout");
- if(val == null){
- val = System.getenv("tamaya.etcd.timeout");
- }
- if(val!=null){
- timeout = Integer.parseInt(val);
- }
- String serverURLs = System.getProperty("tamaya.etcd.server.urls");
+ String serverURLs = System.getProperty("tamaya.consul.urls");
if(serverURLs==null){
- serverURLs = System.getenv("tamaya.etcd.server.urls");
+ serverURLs = System.getenv("tamaya.consul.urls");
}
if(serverURLs==null){
- serverURLs = "http://127.0.0.1:4001";
+ serverURLs = "127.0.0.1:8300";
}
for(String url:serverURLs.split("\\,")) {
try{
- etcdBackends.add(new EtcdAccessor(url.trim(), timeout));
- LOG.info("Using etcd endoint: " + url);
+ consulBackends.add(HostAndPort.fromString(url.trim()));
+ LOG.info("Using consul endoint: " + url);
} catch(Exception e){
- LOG.log(Level.SEVERE, "Error initializing etcd accessor for URL: " + url, e);
+ LOG.log(Level.SEVERE, "Error initializing consul accessor for URL: " + url, e);
}
}
}
private ConsulBackends(){}
- public static List<EtcdAccessor> getEtcdBackends(){
- return etcdBackends;
+ public static List<HostAndPort> getConsulBackends(){
+ return consulBackends;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
index 03db401..65ba6cd 100644
--- a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
+++ b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
@@ -18,6 +18,11 @@
*/
package org.apache.tamaya.consul;
+import com.google.common.base.Optional;
+import com.google.common.net.HostAndPort;
+import com.orbitz.consul.Consul;
+import com.orbitz.consul.KeyValueClient;
+import com.orbitz.consul.model.kv.Value;
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
import org.apache.tamaya.spi.PropertyValueBuilder;
@@ -29,14 +34,14 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Propertysource that is reading configuration from a configured etcd endpoint. Setting
- * {@code etcd.prefix} as system property maps the etcd based onfiguration
- * to this prefix namespace. Etcd servers are configured as {@code etcd.server.urls} system or environment property.
+ * Propertysource that is reading configuration from a configured consul endpoint. Setting
+ * {@code consul.prefix} as system property maps the consul based onfiguration
+ * to this prefix namespace. Consul servers are configured as {@code consul.urls} system or environment property.
*/
public class ConsulPropertySource implements PropertySource{
private static final Logger LOG = Logger.getLogger(ConsulPropertySource.class.getName());
- private String prefix = System.getProperty("tamaya.etcd.prefix", "");
+ private String prefix = System.getProperty("tamaya.consul.prefix", "");
@Override
@@ -63,7 +68,7 @@ public class ConsulPropertySource implements PropertySource{
@Override
public String getName() {
- return "etcd";
+ return "consul";
}
@Override
@@ -75,7 +80,6 @@ public class ConsulPropertySource implements PropertySource{
} else{
key = key.substring(prefix.length());
}
- Map<String,String> props;
String reqKey = key;
if(key.startsWith("_")){
reqKey = key.substring(1);
@@ -91,17 +95,25 @@ public class ConsulPropertySource implements PropertySource{
reqKey = reqKey.substring(0,reqKey.length()-".source".length());
}
}
- for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
+ for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
try{
- props = accessor.get(reqKey);
- if(!props.containsKey("_ERROR")) {
+ Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
+ KeyValueClient kvClient = consul.keyValueClient();
+ Optional<Value> valueOpt = kvClient.getValue(reqKey);
+ if(!valueOpt.isPresent()) {
+ LOG.log(Level.FINE, "key not found in consul: " + reqKey);
+ }else{
// No repfix mapping necessary here, since we only access/return the value...
- return new PropertyValueBuilder(key, props.get(reqKey), getName()).setContextData(props).build();
- } else{
- LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR"));
+ Value value = valueOpt.get();
+ Map<String,String> props = new HashMap<>();
+ props.put(reqKey+".createIndex", String.valueOf(value.getCreateIndex()));
+ props.put(reqKey+".modifyIndex", String.valueOf(value.getModifyIndex()));
+ props.put(reqKey+".lockIndex", String.valueOf(value.getLockIndex()));
+ props.put(reqKey+".flags", String.valueOf(value.getFlags()));
+ return new PropertyValueBuilder(key, value.getValue().get(), getName()).setContextData(props).build();
}
} catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
+ LOG.log(Level.FINE, "etcd access failed on " + hostAndPort + ", trying next...", e);
}
}
return null;
@@ -109,20 +121,25 @@ public class ConsulPropertySource implements PropertySource{
@Override
public Map<String, String> getProperties() {
- if(!EtcdBackends.getEtcdBackends().isEmpty()){
- for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
- try{
- Map<String, String> props = accessor.getProperties("");
- if(!props.containsKey("_ERROR")) {
- return mapPrefix(props);
- } else{
- LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR"));
- }
- } catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
- }
- }
- }
+// for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
+// try{
+// Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
+// KeyValueClient kvClient = consul.keyValueClient();
+// Optional<Value> valueOpt = kvClient.getValue(reqKey);
+// try{
+// Map<String, String> props = kvClient.getProperties("");
+// if(!props.containsKey("_ERROR")) {
+// return mapPrefix(props);
+// } else{
+// LOG.log(Level.FINE, "consul error on " + hostAndPort + ": " + props.get("_ERROR"));
+// }
+// } catch(Exception e){
+// LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e);
+// }
+// } catch(Exception e){
+// LOG.log(Level.FINE, "etcd access failed on " + hostAndPort + ", trying next...", e);
+// }
+// }
return Collections.emptyMap();
}
@@ -143,6 +160,6 @@ public class ConsulPropertySource implements PropertySource{
@Override
public boolean isScannable() {
- return true;
+ return false;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/ConsulMutableConfigurationBackend.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/ConsulMutableConfigurationBackend.java b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/ConsulMutableConfigurationBackend.java
index 6594b2c..b43c442 100644
--- a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/ConsulMutableConfigurationBackend.java
+++ b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/ConsulMutableConfigurationBackend.java
@@ -18,19 +18,20 @@
*/
package org.apache.tamaya.consul.internal;
+import com.google.common.net.HostAndPort;
+import com.orbitz.consul.Consul;
+import com.orbitz.consul.KeyValueClient;
import org.apache.tamaya.consul.ConsulBackends;
import org.apache.tamaya.mutableconfig.spi.AbstractMutableConfigurationBackendSpiSpi;
import java.net.URI;
+import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Change Request implementation based on etcd services. Etcd also supports a ttl to set values only for a defined
- * number of seconds {@code ttl}. This is also supported by this component by adding ttl as a key parameter, e.g.
- * {@code changeRequest.set("myTimedKey?ttl=30", "myValue");} will set a key {@code myTimedKey} valid only for
- * 30 seconds.
+ * Change Request implementation based on consul services.
*/
class ConsulMutableConfigurationBackend extends AbstractMutableConfigurationBackendSpiSpi {
@@ -42,15 +43,14 @@ class ConsulMutableConfigurationBackend extends AbstractMutableConfigurationBack
@Override
public boolean isExisting(String keyExpression) {
- for(EtcdAccessor accessor: ConsulBackends.getEtcdBackends()){
+ for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
try{
- Map<String,String> props = accessor.get(keyExpression);
- if(!props.containsKey("_ERROR")) {
- // No repfix mapping necessary here, since we only access/return the value...
- return props.get(keyExpression)!=null;
- }
+ Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
+ KeyValueClient kvClient = consul.keyValueClient();
+ List<String> keys = kvClient.getKeys(keyExpression);
+ return !keys.isEmpty();
} catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
+ LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e);
}
}
return false;
@@ -59,36 +59,28 @@ class ConsulMutableConfigurationBackend extends AbstractMutableConfigurationBack
@Override
protected void commitInternal() {
- for(EtcdAccessor accessor: ConsulBackends.getEtcdBackends()){
+ for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
try{
+ Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
+ KeyValueClient kvClient = consul.keyValueClient();
+
for(String k: getRemovedProperties()){
- Map<String,String> res = accessor.delete(k);
- if(res.get("_ERROR")!=null){
- LOG.info("Failed to remove key from etcd: " + k);
+ try{
+ kvClient.deleteKey(k);
+ } catch(Exception e){
+ LOG.info("Failed to remove key from consul: " + k);
}
}
for(Map.Entry<String,String> en:getAddedProperties().entrySet()){
String key = en.getKey();
- Integer ttl = null;
- int index = en.getKey().indexOf('?');
- if(index>0){
- key = en.getKey().substring(0, index);
- String rawQuery = en.getKey().substring(index+1);
- String[] queries = rawQuery.split("&");
- for(String query:queries){
- if(query.contains("ttl")){
- int qIdx = query.indexOf('=');
- ttl = qIdx>0?Integer.parseInt(query.substring(qIdx+1).trim()):null;
- }
- }
- }
- Map<String,String> res = accessor.set(key, en.getValue(), ttl);
- if(res.get("_ERROR")!=null){
- LOG.info("Failed key from etcd: " + en.getKey() + "=" + en.getValue());
+ try{
+ kvClient.putValue(key,en.getValue());
+ }catch(Exception e) {
+ LOG.info("Failed to add key to consul: " + en.getKey() + "=" + en.getValue());
}
}
} catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
+ LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/MutableConfigSupport.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/MutableConfigSupport.java b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/MutableConfigSupport.java
index 43dfb75..bc0fbf4 100644
--- a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/MutableConfigSupport.java
+++ b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/internal/MutableConfigSupport.java
@@ -31,13 +31,13 @@ public class MutableConfigSupport implements MutableConfigurationBackendProvider
private URI backendURI;
public MutableConfigSupport(){
- backendURI = URI.create("config:etcd");
+ backendURI = URI.create("config:consul");
}
@Override
public MutableConfigurationBackendSpi getBackend(URI uri) {
if(backendURI.equals(uri)) {
- return new EtcdConfigChangeRequest(backendURI);
+ return new ConsulMutableConfigurationBackend(backendURI);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationBackendProviderSpi
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationBackendProviderSpi b/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationBackendProviderSpi
index 2189807..9174018 100644
--- a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationBackendProviderSpi
+++ b/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationBackendProviderSpi
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.etcd.internal.MutableConfigSupport
\ No newline at end of file
+org.apache.tamaya.consul.internal.MutableConfigSupport
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
index eb7958e..4996059 100644
--- a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ b/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.etcd.EtcdPropertySource
\ No newline at end of file
+org.apache.tamaya.consul.ConsulPropertySource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java b/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
index 5d47738..8946a3c 100644
--- a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
+++ b/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
@@ -36,7 +36,7 @@ public class ConsulPropertySourceTest {
@BeforeClass
public static void setup(){
- System.setProperty("etcd.server.urls", "http://8.8.8.8:4001,http://192.168.99.105:4001");
+ System.setProperty("consul.urls", "http://127.0.0.1:8300");
}
@Test
@@ -51,7 +51,7 @@ public class ConsulPropertySourceTest {
@Test
public void testGetName() throws Exception {
- assertEquals("etcd", propertySource.getName());
+ assertEquals("consul", propertySource.getName());
}
@Test
@@ -70,6 +70,6 @@ public class ConsulPropertySourceTest {
@Test
public void testIsScannable() throws Exception {
- assertTrue(propertySource.isScannable());
+ assertFalse(propertySource.isScannable());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java b/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
index 4d94fe5..8901461 100644
--- a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
+++ b/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
@@ -19,9 +19,14 @@
package org.apache.tamaya.etcd;
import com.google.common.net.HostAndPort;
+import org.apache.tamaya.consul.ConsulPropertySource;
+import org.apache.tamaya.consul.internal.MutableConfigSupport;
+import org.apache.tamaya.mutableconfig.spi.MutableConfigurationBackendSpi;
import org.junit.BeforeClass;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Map;
import java.util.UUID;
@@ -35,60 +40,22 @@ public class ConsulWriteTest {
private static HostAndPort accessor;
static boolean execute = false;
+ private static ConsulPropertySource readingSource;
+ private static MutableConfigurationBackendSpi writer;
@BeforeClass
- public static void setup() throws MalformedURLException {
- accessor = new HostAndPort("192.168.99.105:4001");
- if(!accessor.getVersion().contains("etcd")){
- System.out.println("Disabling etcd tests, etcd not accessible at: " + System.getProperty("etcd.server.urls"));
- System.out.println("Configure etcd with -Detcd.server.urls=http://<IP>:<PORT>");
- }
- else{
- execute = true;
- }
- }
-
- @org.junit.Test
- public void testGetVersion() throws Exception {
- if(!execute)return;
- assertEquals(accessor.getVersion(), "etcd 0.4.9");
- }
-
- @org.junit.Test
- public void testGet() throws Exception {
- if(!execute)return;
- Map<String,String> result = accessor.get("test1");
- assertNotNull(result);
+ public static void setup() throws MalformedURLException, URISyntaxException {
+ System.setProperty("consul.urls", "http://127.0.0.1:8300");
+ accessor = HostAndPort.fromString("127.0.0.1:8500");
+ readingSource = new ConsulPropertySource();
+ writer = new MutableConfigSupport().getBackend(new URI("config:consul"));
}
@org.junit.Test
public void testSetNormal() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testSetNormal", value);
- assertNull(result.get("_testSetNormal.ttl"));
- assertEquals(accessor.get("testSetNormal").get("testSetNormal"), value);
- }
-
- @org.junit.Test
- public void testSetNormal2() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testSetNormal2", value, null);
- assertNull(result.get("_testSetNormal2.ttl"));
- assertEquals(accessor.get("testSetNormal2").get("testSetNormal2"), value);
- }
-
- @org.junit.Test
- public void testSetWithTTL() throws Exception {
- if(!execute)return;
+ if (!execute) return;
String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testSetWithTTL", value, 1);
- assertNotNull(result.get("_testSetWithTTL.ttl"));
- assertEquals(accessor.get("testSetWithTTL").get("testSetWithTTL"), value);
- Thread.sleep(2000L);
- result = accessor.get("testSetWithTTL");
- assertNull(result.get("testSetWithTTL"));
+ writer.put("testSetNormal", value);
}
@@ -96,22 +63,17 @@ public class ConsulWriteTest {
public void testDelete() throws Exception {
if(!execute)return;
String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testDelete", value, null);
- assertEquals(accessor.get("testDelete").get("testDelete"), value);
- assertNotNull(result.get("_testDelete.createdIndex"));
- result = accessor.delete("testDelete");
- assertEquals(result.get("_testDelete.prevNode.value"),value);
- assertNull(accessor.get("testDelete").get("testDelete"));
+ writer.put("testDelete", value);
+ assertEquals(readingSource.get("testDelete").get("testDelete"), value);
+ assertNotNull(readingSource.get("_testDelete.createdIndex"));
+ writer.remove("testDelete");
+ assertNull(readingSource.get("testDelete").get("testDelete"));
}
@org.junit.Test
public void testGetProperties() throws Exception {
if(!execute)return;
- String value = UUID.randomUUID().toString();
- accessor.set("testGetProperties1", value);
- Map<String,String> result = accessor.getProperties("");
- assertNotNull(result);
- assertEquals(result.get("testGetProperties1"), value);
- assertNotNull(result.get("_testGetProperties1.createdIndex"));
+ Map<String,String> result = readingSource.getProperties();
+ assertTrue(result.isEmpty());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ffc59e03/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml
index 4469452..08e38e5 100644
--- a/modules/integration/pom.xml
+++ b/modules/integration/pom.xml
@@ -39,6 +39,7 @@ under the License.
<module>osgi</module>
<module>camel</module>
<module>etcd</module>
+ <module>consul</module>
</modules>
</project>
\ No newline at end of file