summaryrefslogtreecommitdiffstats
path: root/config-proxy
diff options
context:
space:
mode:
authorHarald Musum <musum@yahoo-inc.com>2017-04-05 08:34:32 +0200
committerHarald Musum <musum@yahoo-inc.com>2017-04-05 08:34:32 +0200
commit0fe03b2b89b0c752860758af2051d6f26b2b85f4 (patch)
tree0884d16fe936e61637e85ce1ed607cc7b7d63efc /config-proxy
parent053113bbbbf841a3d4f40421f33ed6a83fabba3a (diff)
Testing changes: Rename config source class, add client class
Diffstat (limited to 'config-proxy')
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java2
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java39
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java (renamed from config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MapBackedConfigSource.java)30
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java6
4 files changed, 51 insertions, 26 deletions
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
index 826a6d58639..ee05e26c37d 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertThat;
*/
public class DelayedResponseHandlerTest {
- private final MapBackedConfigSource source = new MapBackedConfigSource(new MockClientUpdater(new MemoryCache()));
+ private final MockConfigSource source = new MockConfigSource(new MockClientUpdater(new MemoryCache()));
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java
new file mode 100644
index 00000000000..c7f12e671f4
--- /dev/null
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java
@@ -0,0 +1,39 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.proxy;
+
+import com.yahoo.config.subscription.ConfigSource;
+import com.yahoo.vespa.config.ConfigKey;
+import com.yahoo.vespa.config.RawConfig;
+
+import java.util.HashMap;
+
+/**
+ * A simple class to be able to test config proxy without having an RPC config
+ * source.
+ *
+ * @author hmusum
+ * @since 5.1.10
+ */
+class MockConfigSource implements ConfigSource {
+ private final HashMap<ConfigKey<?>, RawConfig> backing = new HashMap<>();
+ private final ClientUpdater clientUpdater;
+
+ MockConfigSource(ClientUpdater clientUpdater) {
+ this.clientUpdater = clientUpdater;
+ }
+
+ MockConfigSource put(ConfigKey<?> key, RawConfig config) {
+ backing.put(key, config);
+ clientUpdater.updateSubscribers(config);
+ return this;
+ }
+
+ RawConfig getConfig(ConfigKey<?> key) {
+ return backing.get(key);
+ }
+
+ void clear() {
+ backing.clear();
+ }
+
+}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MapBackedConfigSource.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java
index 4863fd24d4e..6f673bb3f16 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MapBackedConfigSource.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java
@@ -1,34 +1,22 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import com.yahoo.config.subscription.ConfigSource;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequest;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
/**
- * A simple class to be able to test config proxy without having an RPC config
- * source.
- *
* @author hmusum
- * @since 5.1.10
*/
-public class MapBackedConfigSource implements ConfigSource, ConfigSourceClient {
- private final HashMap<ConfigKey<?>, RawConfig> backing = new HashMap<>();
+public class MockConfigSourceClient implements ConfigSourceClient{
private final ClientUpdater clientUpdater;
+ private final MockConfigSource configSource;
- MapBackedConfigSource(ClientUpdater clientUpdater) {
+ MockConfigSourceClient(ClientUpdater clientUpdater, MockConfigSource configSource) {
this.clientUpdater = clientUpdater;
- }
-
- MapBackedConfigSource put(ConfigKey<?> key, RawConfig config) {
- backing.put(key, config);
- clientUpdater.updateSubscribers(config);
- return this;
+ this.configSource = configSource;
}
@Override
@@ -38,23 +26,19 @@ public class MapBackedConfigSource implements ConfigSource, ConfigSourceClient {
return config;
}
- RawConfig getConfig(ConfigKey<?> configKey) {
- return backing.get(configKey);
+ private RawConfig getConfig(ConfigKey<?> configKey) {
+ return configSource.getConfig(configKey);
}
@Override
public void cancel() {
- clear();
+ configSource.clear();
}
@Override
public void shutdownSourceConnections() {
}
- void clear() {
- backing.clear();
- }
-
@Override
public String getActiveSourceConnection() {
return "N/A";
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
index 4375eb5a7d4..be47a37d6b2 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
@@ -22,7 +22,9 @@ import static org.junit.Assert.*;
public class ProxyServerTest {
private final MemoryCache memoryCache = new MemoryCache();
- private final MapBackedConfigSource source = new MapBackedConfigSource(new MockClientUpdater(memoryCache));
+ private MockClientUpdater clientUpdater = new MockClientUpdater(memoryCache);
+ private final MockConfigSource source = new MockConfigSource(clientUpdater);
+ private MockConfigSourceClient client = new MockConfigSourceClient(clientUpdater, source);
private final ConfigProxyStatistics statistics = new ConfigProxyStatistics();
private ProxyServer proxy;
@@ -42,7 +44,7 @@ public class ProxyServerTest {
source.clear();
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, 0));
source.put(errorConfigKey, createConfigWithNextConfigGeneration(fooConfig, ErrorCode.UNKNOWN_DEFINITION));
- proxy = ProxyServer.createTestServer(source, source, memoryCache, statistics);
+ proxy = ProxyServer.createTestServer(source, client, memoryCache, statistics);
}
@After