camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/7] camel git commit: formatting
Date Sat, 28 May 2016 07:30:39 GMT
Repository: camel
Updated Branches:
  refs/heads/master bc50b54c4 -> fc0292346


formatting


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/aea4ddc6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/aea4ddc6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/aea4ddc6

Branch: refs/heads/master
Commit: aea4ddc692de21ee9baf06341eb92457e8c9bc38
Parents: 81d36f3
Author: Bernd Prager <bernd@prager.ws>
Authored: Fri May 27 11:49:37 2016 -0400
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat May 28 09:18:07 2016 +0200

----------------------------------------------------------------------
 .../camel/component/consul/ConsulRegistry.java  | 391 +++++++++----------
 .../component/consul/ConsulRegistryTest.java    | 268 +++++++------
 parent/pom.xml                                  |   2 +-
 3 files changed, 328 insertions(+), 333 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aea4ddc6/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
index 6a51308..40a1f51 100644
--- a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
+++ b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
@@ -24,11 +24,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import org.apache.camel.NoSuchBeanException;
-import org.apache.camel.spi.Registry;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.SerializationUtils;
-
 import com.google.common.base.Optional;
 import com.google.common.net.HostAndPort;
 import com.orbitz.consul.Consul;
@@ -38,220 +33,224 @@ import com.orbitz.consul.SessionClient;
 import com.orbitz.consul.model.session.ImmutableSession;
 import com.orbitz.consul.model.session.SessionCreatedResponse;
 
+import org.apache.camel.NoSuchBeanException;
+import org.apache.camel.spi.Registry;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.SerializationUtils;
+
 /**
- * 
- * @author Bernd Prager 
- * 		Apache Camel Plug-in for Consul Registry (Objects stored
- *      under kv/key as well as bookmarked under kv/[type]/key to avoid
- *      iteration over types)
+ * Apache Camel Plug-in for Consul Registry (Objects stored under kv/key as well
+ * as bookmarked under kv/[type]/key to avoid iteration over types)
  * 
  */
 public class ConsulRegistry implements Registry {
-	
-	private String hostname = "localhost";
-	private int port = 8500;
-	private Consul consul;
-	private KeyValueClient kvClient;
-	
-	/* constructor with default port */
-	public ConsulRegistry(String hostname) {
-		this(hostname, 8500);
-	}
 
-	/* constructor (since spring.xml does not support builder pattern) */
-	public ConsulRegistry(String hostname, int port) {
-		super();
-		this.hostname = hostname;
-		this.port = port;
-		HostAndPort hostAndPort = HostAndPort.fromParts(hostname, port);
-		this.consul = Consul.builder().withHostAndPort(hostAndPort).build();
-	}
+    private String hostname = "localhost";
+    private int port = 8500;
+    private Consul consul;
+    private KeyValueClient kvClient;
+
+    /* constructor with default port */
+    public ConsulRegistry(String hostname) {
+        this(hostname, 8500);
+    }
+
+    /* constructor (since spring.xml does not support builder pattern) */
+    public ConsulRegistry(String hostname, int port) {
+        super();
+        this.hostname = hostname;
+        this.port = port;
+        HostAndPort hostAndPort = HostAndPort.fromParts(hostname, port);
+        this.consul = Consul.builder().withHostAndPort(hostAndPort).build();
+    }
 
-	/* builder pattern */
-	private ConsulRegistry(Builder builder) {
-		this.hostname = builder.hostname;
-		this.port = builder.port;
-		HostAndPort hostAndPort = HostAndPort.fromParts(hostname, port);
-		this.consul = Consul.builder().withHostAndPort(hostAndPort).build();
-	}
+    /* builder pattern */
+    private ConsulRegistry(Builder builder) {
+        this.hostname = builder.hostname;
+        this.port = builder.port;
+        HostAndPort hostAndPort = HostAndPort.fromParts(hostname, port);
+        this.consul = Consul.builder().withHostAndPort(hostAndPort).build();
+    }
 
-	@Override
-	public Object lookupByName(String key) {
-		// Substitute $ character in key
-		key = key.replaceAll("\\$", "/");
-		kvClient = consul.keyValueClient();
-		Optional<String> result = kvClient.getValueAsString(key);
-		if (result.isPresent()) {
-			byte[] postDecodedValue = Base64.decodeBase64(result.get());
-			return SerializationUtils.deserialize(postDecodedValue);
-		}
-		return null;
-	}
+    @Override
+    public Object lookupByName(String key) {
+        // Substitute $ character in key
+        key = key.replaceAll("\\$", "/");
+        kvClient = consul.keyValueClient();
+        Optional<String> result = kvClient.getValueAsString(key);
+        if (result.isPresent()) {
+            byte[] postDecodedValue = Base64.decodeBase64(result.get());
+            return SerializationUtils.deserialize(postDecodedValue);
+        }
+        return null;
+    }
 
-	@Override
-	public <T> T lookupByNameAndType(String name, Class<T> type) {
-		Object object = lookupByName(name);
-		if (object == null)
-			return null;
-		try {
-			return type.cast(object);
-		} catch (Throwable e) {
-			String msg = "Found bean: " + name + " in Consul Registry: " + this + " of type: "
-					+ object.getClass().getName() + "expected type was: " + type;
-			throw new NoSuchBeanException(name, msg, e);
-		}
-	}
+    @Override
+    public <T> T lookupByNameAndType(String name, Class<T> type) {
+        Object object = lookupByName(name);
+        if (object == null) {
+            return null;
+        }
+        try {
+            return type.cast(object);
+        } catch (Throwable e) {
+            String msg = "Found bean: " + name + " in Consul Registry: " + this + " of type:
"
+                    + object.getClass().getName() + "expected type was: " + type;
+            throw new NoSuchBeanException(name, msg, e);
+        }
+    }
 
-	@Override
-	public <T> Map<String, T> findByTypeWithName(Class<T> type) {
-		Object obj = null;
-		Map<String, T> result = new HashMap<String, T>();
-		// encode $ signs as they occur in subclass types
-		String keyPrefix = type.getName().replaceAll("\\$", "/");
-		kvClient = consul.keyValueClient();
-		List<String> keys = null;
-		try {
-			keys = kvClient.getKeys(keyPrefix);
-		} catch (ConsulException e) {
-			return result;
-		}
-		if (keys != null) {
-			for (String key : keys) {
-				// change bookmark back into actual key
-				key = key.substring((key.lastIndexOf('/') + 1));
-				obj = lookupByName(key.replaceAll("\\$", "/"));
-				if (type.isInstance(obj)) {
-					result.put(key, type.cast(obj));
-				}
-			}
-		}
-		return result;
-	}
+    @Override
+    public <T> Map<String, T> findByTypeWithName(Class<T> type) {
+        Object obj = null;
+        Map<String, T> result = new HashMap<String, T>();
+        // encode $ signs as they occur in subclass types
+        String keyPrefix = type.getName().replaceAll("\\$", "/");
+        kvClient = consul.keyValueClient();
+        List<String> keys = null;
+        try {
+            keys = kvClient.getKeys(keyPrefix);
+        } catch (ConsulException e) {
+            return result;
+        }
+        if (keys != null) {
+            for (String key : keys) {
+                // change bookmark back into actual key
+                key = key.substring(key.lastIndexOf('/') + 1);
+                obj = lookupByName(key.replaceAll("\\$", "/"));
+                if (type.isInstance(obj)) {
+                    result.put(key, type.cast(obj));
+                }
+            }
+        }
+        return result;
+    }
 
-	@Override
-	public <T> Set<T> findByType(Class<T> type) {
-		String keyPrefix = type.getName().replaceAll("\\$", "/");
-		Object object = null;
-		Set<T> result = new HashSet<T>();
-		List<String> keys = null;
-		try {
-			keys = kvClient.getKeys(keyPrefix);
-		} catch (ConsulException e) {
-			return result;
-		}
-		if (keys != null) {
-			for (String key : keys) {
-				// change bookmark back into actual key
-				key = key.substring((key.lastIndexOf('/') + 1));
-				object = lookupByName(key.replaceAll("\\$", "/"));
-				if (type.isInstance(object)) {
-					result.add(type.cast(object));
-				}
-			}
-		}
-		return result;
-	}
+    @Override
+    public <T> Set<T> findByType(Class<T> type) {
+        String keyPrefix = type.getName().replaceAll("\\$", "/");
+        Object object = null;
+        Set<T> result = new HashSet<T>();
+        List<String> keys = null;
+        try {
+            keys = kvClient.getKeys(keyPrefix);
+        } catch (ConsulException e) {
+            return result;
+        }
+        if (keys != null) {
+            for (String key : keys) {
+                // change bookmark back into actual key
+                key = key.substring(key.lastIndexOf('/') + 1);
+                object = lookupByName(key.replaceAll("\\$", "/"));
+                if (type.isInstance(object)) {
+                    result.add(type.cast(object));
+                }
+            }
+        }
+        return result;
+    }
 
-	public void remove(String key) {
-		// create session to avoid conflicts (not sure if that is safe enough)
-		SessionClient sessionClient = consul.sessionClient();
-		String sessionName = "session_" + UUID.randomUUID().toString();
-		//
-		SessionCreatedResponse response = sessionClient
-				.createSession(ImmutableSession.builder().name(sessionName).build());
-		String sessionId = response.getId();
-		kvClient = consul.keyValueClient();
-		String lockKey = "lock_" + key;
-		kvClient.acquireLock(lockKey, sessionName, sessionId);
-		Object object = lookupByName(key);
-		if (object == null) {
-			String msg = "Bean with key '" + key + "' did not exist in Consul Registry.";
-			throw new NoSuchBeanException(msg);
-		}
-		kvClient.deleteKey(key);
-		kvClient.deleteKey(object.getClass().getName() + "/" + key);
-		kvClient.releaseLock(lockKey, sessionId);
-	}
+    public void remove(String key) {
+        // create session to avoid conflicts (not sure if that is safe
+        // enough)
+        SessionClient sessionClient = consul.sessionClient();
+        String sessionName = "session_" + UUID.randomUUID().toString();
+        //
+        SessionCreatedResponse response = sessionClient
+                .createSession(ImmutableSession.builder().name(sessionName).build());
+        String sessionId = response.getId();
+        kvClient = consul.keyValueClient();
+        String lockKey = "lock_" + key;
+        kvClient.acquireLock(lockKey, sessionName, sessionId);
+        Object object = lookupByName(key);
+        if (object == null) {
+            String msg = "Bean with key '" + key + "' did not exist in Consul Registry.";
+            throw new NoSuchBeanException(msg);
+        }
+        kvClient.deleteKey(key);
+        kvClient.deleteKey(object.getClass().getName() + "/" + key);
+        kvClient.releaseLock(lockKey, sessionId);
+    }
 
-	public void put(String key, Object object) {
-		// Substitute $ character in key
-		key = key.replaceAll("\\$", "/");
-		// create session to avoid conflicts
-		// (not sure if that is safe enough, again)
-		SessionClient sessionClient = consul.sessionClient();
-		String sessionName = "session_" + UUID.randomUUID().toString();
-		SessionCreatedResponse response = sessionClient
-				.createSession(ImmutableSession.builder().name(sessionName).build());
-		String sessionId = response.getId();
-		kvClient = consul.keyValueClient();
-		String lockKey = "lock_" + key;
-		kvClient.acquireLock(lockKey, sessionName, sessionId);
+    public void put(String key, Object object) {
+        // Substitute $ character in key
+        key = key.replaceAll("\\$", "/");
+        // create session to avoid conflicts
+        // (not sure if that is safe enough, again)
+        SessionClient sessionClient = consul.sessionClient();
+        String sessionName = "session_" + UUID.randomUUID().toString();
+        SessionCreatedResponse response = sessionClient
+                .createSession(ImmutableSession.builder().name(sessionName).build());
+        String sessionId = response.getId();
+        kvClient = consul.keyValueClient();
+        String lockKey = "lock_" + key;
+        kvClient.acquireLock(lockKey, sessionName, sessionId);
 
-		// Allow only unique keys, last one wins
-		if (lookupByName(key) != null) {
-			remove(key);
-		}
-		Object clone = SerializationUtils.clone((Serializable) object);
-		byte[] serializedObject = SerializationUtils.serialize((Serializable) clone);
-		// pre-encode due native encoding issues
-		byte[] preEncodedValue = Base64.encodeBase64(serializedObject);
-		String value = new String(preEncodedValue);
-		// store the actual class
-		kvClient.putValue(key, value);
-		// store just as a bookmark
-		kvClient.putValue(object.getClass().getName().replaceAll("\\$", "/") + "/" + key, "1");
-		kvClient.releaseLock(lockKey, sessionId);
-	}
+        // Allow only unique keys, last one wins
+        if (lookupByName(key) != null) {
+            remove(key);
+        }
+        Object clone = SerializationUtils.clone((Serializable) object);
+        byte[] serializedObject = SerializationUtils.serialize((Serializable) clone);
+        // pre-encode due native encoding issues
+        byte[] preEncodedValue = Base64.encodeBase64(serializedObject);
+        String value = new String(preEncodedValue);
+        // store the actual class
+        kvClient.putValue(key, value);
+        // store just as a bookmark
+        kvClient.putValue(object.getClass().getName().replaceAll("\\$", "/") + "/" + key,
"1");
+        kvClient.releaseLock(lockKey, sessionId);
+    }
 
-	public static class Builder {
-		// required parameter
-		String hostname;
-		// optional parameter
-		Integer port = 8500;
+    public static class Builder {
+        // required parameter
+        String hostname;
+        // optional parameter
+        Integer port = 8500;
 
-		public Builder(String hostname) {
-			this.hostname = hostname;
-		}
+        public Builder(String hostname) {
+            this.hostname = hostname;
+        }
 
-		public Builder port(Integer port) {
-			this.port = port;
-			return this;
-		}
+        public Builder port(Integer port) {
+            this.port = port;
+            return this;
+        }
 
-		public ConsulRegistry build() {
-			return new ConsulRegistry(this);
-		}
-	}
+        public ConsulRegistry build() {
+            return new ConsulRegistry(this);
+        }
+    }
 
-	public String getHostname() {
-		return hostname;
-	}
+    public String getHostname() {
+        return hostname;
+    }
 
-	public void setHostname(String hostname) {
-		this.hostname = hostname;
-	}
+    public void setHostname(String hostname) {
+        this.hostname = hostname;
+    }
 
-	public int getPort() {
-		return port;
-	}
+    public int getPort() {
+        return port;
+    }
 
-	public void setPort(int port) {
-		this.port = port;
-	}
+    public void setPort(int port) {
+        this.port = port;
+    }
 
-	@Override
-	public Object lookup(String name) {
-		return lookupByName(name);
-	}
+    @Override
+    public Object lookup(String name) {
+        return lookupByName(name);
+    }
 
-	@Override
-	public <T> T lookup(String name, Class<T> type) {
-		return lookupByNameAndType(name, type);
-	}
+    @Override
+    public <T> T lookup(String name, Class<T> type) {
+        return lookupByNameAndType(name, type);
+    }
 
-	@Override
-	public <T> Map<String, T> lookupByType(Class<T> type) {
-		return lookupByType(type);
-	}
+    @Override
+    public <T> Map<String, T> lookupByType(Class<T> type) {
+        return lookupByType(type);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/aea4ddc6/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulRegistryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulRegistryTest.java
b/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulRegistryTest.java
index 9abc248..b8fd1c8 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulRegistryTest.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulRegistryTest.java
@@ -1,11 +1,12 @@
 /**
- * Copyright (C) 2015 Bernd Prager <http://prager.ws>
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,10 +16,6 @@
  */
 package org.apache.camel.component.consul;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -31,133 +28,132 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
- * 
- * @author Bernd Prager Unit test for Camel Registry implementation for Consul
+ * Unit test for Camel Registry implementation for Consul
  */
 public class ConsulRegistryTest implements Serializable {
 
-	private static final long serialVersionUID = -3482971969351609265L;
-	private static ConsulRegistry registry;
-	private static final Logger LOGGER = Logger.getLogger(ConsulRegistryTest.class);
-
-	public class ConsulTestClass implements Serializable {
-		private static final long serialVersionUID = -4815945688487114891L;
-
-		public String hello(String name) {
-			return "Hello " + name;
-		}
-	}
-
-	@BeforeClass
-	public static void setUp() {
-		registry = new ConsulRegistry.Builder("localhost").build();
-	}
-
-	@Test
-	public void storeString() {
-		registry.put("stringTestKey", "stringValue");
-		String result = (String) registry.lookupByName("stringTestKey");
-		registry.remove("stringTestKey");
-		assertNotNull(result);
-		assertEquals("stringValue", result);
-	}
-
-	@Test
-	public void overrideExistingKey() {
-		registry.put("uniqueKey", "stringValueOne");
-		registry.put("uniqueKey", "stringValueTwo");
-		String result = (String) registry.lookupByName("uniqueKey");
-		registry.remove("uniqueKey");
-		assertNotNull(result);
-		assertEquals("stringValueTwo", result);
-	}
-
-	@Test
-	public void checkLookupByName() {
-		registry.put("namedKey", "namedValue");
-		String result = (String) registry.lookupByName("namedKey");
-		registry.remove("namedKey");
-		assertNotNull(result);
-		assertEquals("namedValue", result);
-	}
-
-	@Test
-	public void checkFailedLookupByName() {
-		registry.put("namedKey", "namedValue");
-		registry.remove("namedKey");
-		String result = (String) registry.lookupByName("namedKey");
-		assertNull(result);
-	}
-
-	@Test
-	public void checkLookupByNameAndType() {
-		ConsulTestClass consulTestClass = new ConsulTestClass();
-		registry.put("testClass", consulTestClass);
-		ConsulTestClass consulTestClassClone = registry.lookupByNameAndType("testClass", consulTestClass.getClass());
-		registry.remove("testClass");
-		assertNotNull(consulTestClassClone);
-		assertEquals(consulTestClass.getClass(), consulTestClassClone.getClass());
-	}
-
-	@Test
-	public void checkFailedLookupByNameAndType() {
-		ConsulTestClass consulTestClass = new ConsulTestClass();
-		registry.put("testClass", consulTestClass);
-		registry.remove("testClass");
-		ConsulTestClass consulTestClassClone = registry.lookupByNameAndType("testClass", consulTestClass.getClass());
-		assertNull(consulTestClassClone);
-	}
-
-	@Test
-	public void checkFindByTypeWithName() {
-		ConsulTestClass consulTestClassOne = new ConsulTestClass();
-		ConsulTestClass consulTestClassTwo = new ConsulTestClass();
-		registry.put("testClassOne", consulTestClassOne);
-		registry.put("testClassTwo", consulTestClassTwo);
-		Map<String, ? extends ConsulTestClass> consulTestClassMap = registry
-				.findByTypeWithName(consulTestClassOne.getClass());
-		registry.remove("testClassOne");
-		registry.remove("testClassTwo");
-		HashMap<String, ConsulTestClass> emptyHashMap = new HashMap<String, ConsulTestClass>();
-		assertNotNull(consulTestClassMap);
-		assertEquals(consulTestClassMap.getClass(), emptyHashMap.getClass());
-		assertEquals(2, consulTestClassMap.size());
-	}
-
-	public void checkFailedFindByTypeWithName() {
-
-	}
-
-	@Test
-	public void storeObject() {
-		ConsulTestClass testObject = new ConsulTestClass();
-		registry.put("objectTestClass", testObject);
-		ConsulTestClass clone = (ConsulTestClass) registry.lookupByName("objectTestClass");
-		assertEquals(clone.hello("World"), "Hello World");
-		registry.remove("objectTestClass");
-	}
-
-	@Test
-	public void findByType() {
-		ConsulTestClass classOne = new ConsulTestClass();
-		registry.put("classOne", classOne);
-		ConsulTestClass classTwo = new ConsulTestClass();
-		registry.put("classTwo", classTwo);
-		Set<? extends ConsulTestClass> results = registry.findByType(classOne.getClass());
-		assertNotNull(results);
-		HashSet<ConsulTestClass> hashSet = new HashSet<ConsulTestClass>();
-		registry.remove("classOne");
-		registry.remove("classTwo");
-		assertEquals(results.getClass(), hashSet.getClass());
-		assertEquals(2, results.size());
-	}
-
-	public void notFindByType() {
-
-	}
-
-	@Test(expected = NoSuchBeanException.class)
-	public void deleteNonExisting() {
-		registry.remove("nonExisting");
-	}
+    private static final long serialVersionUID = -3482971969351609265L;
+    private static ConsulRegistry registry;
+    private static final Logger LOGGER = Logger.getLogger(ConsulRegistryTest.class);
+
+    public class ConsulTestClass implements Serializable {
+        private static final long serialVersionUID = -4815945688487114891L;
+
+        public String hello(String name) {
+            return "Hello " + name;
+        }
+    }
+
+    @BeforeClass
+    public static void setUp() {
+        registry = new ConsulRegistry.Builder("localhost").build();
+    }
+
+    @Test
+    public void storeString() {
+        registry.put("stringTestKey", "stringValue");
+        String result = (String) registry.lookupByName("stringTestKey");
+        registry.remove("stringTestKey");
+        assertNotNull(result);
+        assertEquals("stringValue", result);
+    }
+
+    @Test
+    public void overrideExistingKey() {
+        registry.put("uniqueKey", "stringValueOne");
+        registry.put("uniqueKey", "stringValueTwo");
+        String result = (String) registry.lookupByName("uniqueKey");
+        registry.remove("uniqueKey");
+        assertNotNull(result);
+        assertEquals("stringValueTwo", result);
+    }
+
+    @Test
+    public void checkLookupByName() {
+        registry.put("namedKey", "namedValue");
+        String result = (String) registry.lookupByName("namedKey");
+        registry.remove("namedKey");
+        assertNotNull(result);
+        assertEquals("namedValue", result);
+    }
+
+    @Test
+    public void checkFailedLookupByName() {
+        registry.put("namedKey", "namedValue");
+        registry.remove("namedKey");
+        String result = (String) registry.lookupByName("namedKey");
+        assertNull(result);
+    }
+
+    @Test
+    public void checkLookupByNameAndType() {
+        ConsulTestClass consulTestClass = new ConsulTestClass();
+        registry.put("testClass", consulTestClass);
+        ConsulTestClass consulTestClassClone = registry.lookupByNameAndType("testClass",
consulTestClass.getClass());
+        registry.remove("testClass");
+        assertNotNull(consulTestClassClone);
+        assertEquals(consulTestClass.getClass(), consulTestClassClone.getClass());
+    }
+
+    @Test
+    public void checkFailedLookupByNameAndType() {
+        ConsulTestClass consulTestClass = new ConsulTestClass();
+        registry.put("testClass", consulTestClass);
+        registry.remove("testClass");
+        ConsulTestClass consulTestClassClone = registry.lookupByNameAndType("testClass",
consulTestClass.getClass());
+        assertNull(consulTestClassClone);
+    }
+
+    @Test
+    public void checkFindByTypeWithName() {
+        ConsulTestClass consulTestClassOne = new ConsulTestClass();
+        ConsulTestClass consulTestClassTwo = new ConsulTestClass();
+        registry.put("testClassOne", consulTestClassOne);
+        registry.put("testClassTwo", consulTestClassTwo);
+        Map<String, ? extends ConsulTestClass> consulTestClassMap = registry
+                .findByTypeWithName(consulTestClassOne.getClass());
+        registry.remove("testClassOne");
+        registry.remove("testClassTwo");
+        HashMap<String, ConsulTestClass> emptyHashMap = new HashMap<String, ConsulTestClass>();
+        assertNotNull(consulTestClassMap);
+        assertEquals(consulTestClassMap.getClass(), emptyHashMap.getClass());
+        assertEquals(2, consulTestClassMap.size());
+    }
+
+    public void checkFailedFindByTypeWithName() {
+
+    }
+
+    @Test
+    public void storeObject() {
+        ConsulTestClass testObject = new ConsulTestClass();
+        registry.put("objectTestClass", testObject);
+        ConsulTestClass clone = (ConsulTestClass) registry.lookupByName("objectTestClass");
+        assertEquals(clone.hello("World"), "Hello World");
+        registry.remove("objectTestClass");
+    }
+
+    @Test
+    public void findByType() {
+        ConsulTestClass classOne = new ConsulTestClass();
+        registry.put("classOne", classOne);
+        ConsulTestClass classTwo = new ConsulTestClass();
+        registry.put("classTwo", classTwo);
+        Set<? extends ConsulTestClass> results = registry.findByType(classOne.getClass());
+        assertNotNull(results);
+        HashSet<ConsulTestClass> hashSet = new HashSet<ConsulTestClass>();
+        registry.remove("classOne");
+        registry.remove("classTwo");
+        assertEquals(results.getClass(), hashSet.getClass());
+        assertEquals(2, results.size());
+    }
+
+    public void notFindByType() {
+
+    }
+
+    @Test(expected = NoSuchBeanException.class)
+    public void deleteNonExisting() {
+        registry.remove("nonExisting");
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/aea4ddc6/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index eca9f75..a5f47c2 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -132,7 +132,7 @@
     <commons-vfs2-version>2.0</commons-vfs2-version>
     <compress-lzf-version>1.0.3</compress-lzf-version>
     <consul-client-version>0.12.2</consul-client-version>
-    <consul-client-bundle-version>0.12.2</consul-client-bundle-version>
+    <consul-client-bundle-version>0.12.0_1</consul-client-bundle-version>
     <cobertura-maven-plugin-version>2.7</cobertura-maven-plugin-version>
     <cxf-version>3.1.6</cxf-version>
     <cxf-version-range>[3.0,4.0)</cxf-version-range>


Mime
View raw message