summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-06-16 13:34:31 +0200
committerHarald Musum <musum@verizonmedia.com>2020-06-16 13:34:31 +0200
commit79cafd61bed5f0f140fdb86ba313900a78311798 (patch)
tree69c4cd497c77979f49526a035ace42cc0c02648e /configserver
parent489cf6253298de302c9e48a1562e13ef6ff23684 (diff)
Move method to test class
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java31
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java21
2 files changed, 29 insertions, 23 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java
index e64921e3ea0..cf7740f133f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java
@@ -1,25 +1,32 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.application;
+import com.yahoo.config.model.api.HostInfo;
import com.yahoo.config.model.api.Model;
+import com.yahoo.config.model.api.ServiceInfo;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.vespa.config.server.http.HttpFetcher;
-import com.yahoo.vespa.config.server.http.StaticResponse;
import com.yahoo.vespa.config.server.http.RequestTimeoutException;
+import com.yahoo.vespa.config.server.http.StaticResponse;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER;
+import static com.yahoo.vespa.config.server.application.MockModel.createServiceInfo;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class HttpProxyTest {
+
private final HttpFetcher fetcher = mock(HttpFetcher.class);
private final HttpProxy proxy = new HttpProxy(fetcher);
@@ -29,7 +36,7 @@ public class HttpProxyTest {
@Before
public void setup() {
- Model modelMock = MockModel.createClusterController(hostname, port);
+ Model modelMock = createClusterController();
when(applicationMock.getModel()).thenReturn(modelMock);
}
@@ -52,7 +59,7 @@ public class HttpProxyTest {
// The HttpResponse returned by the fetcher IS the same object as the one returned by the proxy,
// when everything goes well.
- assertTrue(actualResponse == response);
+ assertSame(actualResponse, response);
}
@Test(expected = RequestTimeoutException.class)
@@ -62,4 +69,20 @@ public class HttpProxyTest {
proxy.get(applicationMock, hostname, CLUSTERCONTROLLER_CONTAINER.serviceName,
"clustercontroller-status/v1/clusterName");
}
+
+ private static MockModel createClusterController() {
+ ServiceInfo container = createServiceInfo(
+ hostname,
+ "foo", // name
+ CLUSTERCONTROLLER_CONTAINER.serviceName,
+ ClusterSpec.Type.container,
+ port,
+ "state http external query");
+ ServiceInfo serviceNoStatePort = createServiceInfo(hostname, "storagenode", "storagenode",
+ ClusterSpec.Type.content, 1234, "rpc");
+ HostInfo hostInfo = new HostInfo(hostname, Arrays.asList(container, serviceNoStatePort));
+
+ return new MockModel(Collections.singleton(hostInfo));
+ }
+
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java
index 0da96f9f01d..c9f25451ea4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java
@@ -23,8 +23,6 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER;
-
/**
* Model with two services, one that does not have a state port
*
@@ -45,22 +43,6 @@ public class MockModel implements Model {
return new HostInfo(hostname, Arrays.asList(container, serviceNoStatePort));
}
- // TODO: Move to caller
- static MockModel createClusterController(String hostname, int statePort) {
- ServiceInfo container = createServiceInfo(
- hostname,
- "foo", // name
- CLUSTERCONTROLLER_CONTAINER.serviceName,
- ClusterSpec.Type.container,
- statePort,
- "state http external query");
- ServiceInfo serviceNoStatePort = createServiceInfo(hostname, "storagenode", "storagenode",
- ClusterSpec.Type.content, 1234, "rpc");
- HostInfo hostInfo = new HostInfo(hostname, Arrays.asList(container, serviceNoStatePort));
-
- return new MockModel(Collections.singleton(hostInfo));
- }
-
static MockModel createConfigProxies(List<String> hostnames, int rpcPort) {
Set<HostInfo> hostInfos = new HashSet<>();
hostnames.forEach(hostname -> {
@@ -71,7 +53,7 @@ public class MockModel implements Model {
return new MockModel(hostInfos);
}
- static private ServiceInfo createServiceInfo(
+ static ServiceInfo createServiceInfo(
String hostname,
String name,
String type,
@@ -121,4 +103,5 @@ public class MockModel implements Model {
public AllocatedHosts allocatedHosts() {
throw new UnsupportedOperationException();
}
+
}